'Test construction (editing) of the scheme through the scene.'

def test_scheme_construction(self):

    test_scheme = scheme.Scheme()
    self.scene.set_scheme(test_scheme)
    node_items = []
    link_items = []
    self.scene.node_item_added.connect(node_items.append)
    self.scene.node_item_removed.connect(node_items.remove)
    self.scene.link_item_added.connect(link_items.append)
    self.scene.link_item_removed.connect(link_items.remove)
    (file_desc, disc_desc, bayes_desc) = self.widget_desc()
    file_node = scheme.SchemeNode(file_desc)
    file_item = self.scene.add_node(file_node)
    self.scene.commit_scheme_node(file_node)
    self.assertSequenceEqual(self.scene.node_items(), [file_item])
    self.assertSequenceEqual(node_items, [file_item])
    self.assertSequenceEqual(test_scheme.nodes, [file_node])
    disc_node = scheme.SchemeNode(disc_desc)
    bayes_node = scheme.SchemeNode(bayes_desc)
    disc_item = self.scene.add_node(disc_node)
    bayes_item = self.scene.add_node(bayes_node)
    self.assertSequenceEqual(self.scene.node_items(), [file_item, disc_item, bayes_item])
    self.assertSequenceEqual(self.scene.node_items(), node_items)
    self.assertSequenceEqual(test_scheme.nodes, [file_node])
    self.scene.remove_node(disc_node)
    self.scene.remove_node(bayes_node)
    self.assertSequenceEqual(self.scene.node_items(), [file_item])
    self.assertSequenceEqual(node_items, [file_item])
    self.assertSequenceEqual(test_scheme.nodes, [file_node])
    disc_item = self.scene.add_node(disc_node)
    bayes_item = self.scene.add_node(bayes_node)
    self.scene.commit_scheme_node(disc_node)
    self.scene.commit_scheme_node(bayes_node)
    self.assertSequenceEqual(self.scene.node_items(), [file_item, disc_item, bayes_item])
    self.assertSequenceEqual(self.scene.node_items(), node_items)
    self.assertSequenceEqual(test_scheme.nodes, [file_node, disc_node, bayes_node])
    link1 = scheme.SchemeLink(file_node, 'Data', disc_node, 'Data')
    link2 = scheme.SchemeLink(disc_node, 'Data', bayes_node, 'Data')
    link_item1 = self.scene.add_link(link1)
    link_item2 = self.scene.add_link(link2)
    self.assertSequenceEqual(self.scene.link_items(), [link_item1, link_item2])
    self.assertSequenceEqual(self.scene.link_items(), link_items)
    self.assertSequenceEqual(test_scheme.links, [])
    self.scene.commit_scheme_link(link1)
    self.scene.commit_scheme_link(link2)
    self.assertSequenceEqual(self.scene.link_items(), [link_item1, link_item2])
    self.assertSequenceEqual(self.scene.link_items(), link_items)
    self.assertSequenceEqual(test_scheme.links, [link1, link2])
    self.app.exec_()
