Пример #1
0
    def test_add_segment_updates_dependencies(self):
        oldGraph = QueryGraph()
        node = SqlCTENode("test", "Im the text content of the test node")
        node1 = SqlCTENode("test1", "Im the text content of the test node")
        node3 = SqlCTENode("test3", "Fill me!")
        node.add_dependency_node(node1)
        node.add_dependency_node(node3)
        oldGraph.add_node(node)
        oldGraph.add_node(node1)
        oldGraph.add_node(node3)

        newNode = PlaceholderNode("test", "Im the text content of the test node")
        newNode2 = SqlCTENode("test2", "Im the text content of the test node")
        newNode1 = PlaceholderNode("test1", "Im the text content of the test node")
        newNode.add_dependency_node(newNode2)
        newNode2.add_dependency_node(newNode1)

        newGraph = QueryGraph()

        newGraph.add_node(newNode)
        newGraph.add_node(newNode2)
        newGraph.add_node(newNode1)

        oldGraph.add_query(newGraph)

        self.assertTrue(newNode2 in oldGraph.get_node_by_name("test").get_dependencies())
        self.assertTrue(node3 in oldGraph.get_node_by_name("test").get_dependencies())
Пример #2
0
    def test_add_segment_updates_dependencies(self):
        oldGraph = QueryGraph()
        node = SqlCTENode("test", "Im the text content of the test node")
        node1 = SqlCTENode("test1", "Im the text content of the test node")
        node3 = SqlCTENode("test3", "Fill me!")
        node.add_dependency_node(node1)
        node.add_dependency_node(node3)
        oldGraph.add_node(node)
        oldGraph.add_node(node1)
        oldGraph.add_node(node3)

        newNode = PlaceholderNode("test",
                                  "Im the text content of the test node")
        newNode2 = SqlCTENode("test2", "Im the text content of the test node")
        newNode1 = PlaceholderNode("test1",
                                   "Im the text content of the test node")
        newNode.add_dependency_node(newNode2)
        newNode2.add_dependency_node(newNode1)

        newGraph = QueryGraph()

        newGraph.add_node(newNode)
        newGraph.add_node(newNode2)
        newGraph.add_node(newNode1)

        oldGraph.add_query(newGraph)

        self.assertTrue(
            newNode2 in oldGraph.get_node_by_name("test").get_dependencies())
        self.assertTrue(
            node3 in oldGraph.get_node_by_name("test").get_dependencies())
Пример #3
0
    def test_add_replace_segment_updates_dependencies(self):
        oldGraph = QueryGraph()
        node = SqlCTENode("test", "Im the text content of the test node")
        node1 = SqlCTENode("test1", "Im the text content of the test node")
        node.add_dependency_node(node1)
        oldGraph.add_node(node)
        oldGraph.add_node(node1)

        newNode = PlaceholderNode("test",
                                  "Im the text content of the test node")
        newNode2 = SqlCTENode("test2", "Im the text content of the test node")
        newNode1 = PlaceholderNode("test1",
                                   "Im the text content of the test node")
        newNode.add_dependency_node(newNode2)
        newNode2.add_dependency_node(newNode1)

        newGraph = QueryGraph()

        newGraph.add_node(newNode)
        newGraph.add_node(newNode2)
        newGraph.add_node(newNode1)

        oldGraph.add_query(newGraph)

        self.assertEqual(
            oldGraph.get_node_by_name("test").get_dependencies(), [newNode2])
Пример #4
0
    def test_add_replace_segment_adds_new_node(self):
        oldGraph = QueryGraph()
        node = SqlCTENode("test", "Im the text content of the test node")
        node1 = SqlCTENode("test1", "Im the text content of the test node")
        node.add_dependency_node(node1)
        oldGraph.add_node(node)
        oldGraph.add_node(node1)

        newNode = PlaceholderNode("test",
                                  "Im the text content of the test node")
        newNode2 = SqlCTENode("test2", "Im the text content of the test node")
        newNode1 = PlaceholderNode("test1",
                                   "Im the text content of the test node")
        newNode.add_dependency_node(newNode2)
        newNode2.add_dependency_node(newNode1)

        newGraph = QueryGraph()

        newGraph.add_node(newNode)
        newGraph.add_node(newNode2)
        newGraph.add_node(newNode1)

        oldGraph.add_query(newGraph)

        self.assertTrue(oldGraph.get_node_by_name("test2") is newNode2)
Пример #5
0
    def test_value_replace_updates_text(self):
        oldGraph = QueryGraph()
        oldGraph.add_node(SqlCTENode("test", "Im the text content of the test node"))

        newGraph = QueryGraph()
        newGraph.add_node(SqlCTENode("test", "im the new content"))

        oldGraph.value_replace(newGraph)

        self.assertEqual(oldGraph.get_node_by_name("test").get_text(),"im the new content")
Пример #6
0
    def test_value_replace_updates_text(self):
        oldGraph = QueryGraph()
        oldGraph.add_node(
            SqlCTENode("test", "Im the text content of the test node"))

        newGraph = QueryGraph()
        newGraph.add_node(SqlCTENode("test", "im the new content"))

        oldGraph.value_replace(newGraph)

        self.assertEqual(
            oldGraph.get_node_by_name("test").get_text(), "im the new content")
Пример #7
0
    def test_value_replace_updates_docstring(self):
        oldGraph = QueryGraph()
        node = SqlCTENode("test", "Im the text content of the test node")
        node.set_docstring("im a doc string")
        oldGraph.add_node(node)
        newNode = SqlCTENode("test", "Im the text content of the test node")
        newNode.set_docstring("im a new doc string")
        newGraph = QueryGraph()
        newGraph.add_node(newNode)

        oldGraph.value_replace(newGraph)

        self.assertEqual(oldGraph.get_node_by_name("test").get_docstring(),"im a new doc string")
Пример #8
0
    def test_value_replace_updates_docstring(self):
        oldGraph = QueryGraph()
        node = SqlCTENode("test", "Im the text content of the test node")
        node.set_docstring("im a doc string")
        oldGraph.add_node(node)
        newNode = SqlCTENode("test", "Im the text content of the test node")
        newNode.set_docstring("im a new doc string")
        newGraph = QueryGraph()
        newGraph.add_node(newNode)

        oldGraph.value_replace(newGraph)

        self.assertEqual(
            oldGraph.get_node_by_name("test").get_docstring(),
            "im a new doc string")
Пример #9
0
    def test_add_replace_segment_updates_dependencies(self):
        oldGraph = QueryGraph()
        node = SqlCTENode("test", "Im the text content of the test node")
        node1 = SqlCTENode("test1", "Im the text content of the test node")
        node.add_dependency_node(node1)
        oldGraph.add_node(node)
        oldGraph.add_node(node1)

        newNode = PlaceholderNode("test", "Im the text content of the test node")
        newNode2 = SqlCTENode("test2", "Im the text content of the test node")
        newNode1 = PlaceholderNode("test1", "Im the text content of the test node")
        newNode.add_dependency_node(newNode2)
        newNode2.add_dependency_node(newNode1)

        newGraph = QueryGraph()

        newGraph.add_node(newNode)
        newGraph.add_node(newNode2)
        newGraph.add_node(newNode1)

        oldGraph.add_query(newGraph)

        self.assertEqual(oldGraph.get_node_by_name("test").get_dependencies(), [newNode2])
Пример #10
0
    def test_add_replace_segment_adds_new_node(self):
        oldGraph = QueryGraph()
        node = SqlCTENode("test", "Im the text content of the test node")
        node1 = SqlCTENode("test1", "Im the text content of the test node")
        node.add_dependency_node(node1)
        oldGraph.add_node(node)
        oldGraph.add_node(node1)

        newNode = PlaceholderNode("test", "Im the text content of the test node")
        newNode2 = SqlCTENode("test2", "Im the text content of the test node")
        newNode1 = PlaceholderNode("test1", "Im the text content of the test node")
        newNode.add_dependency_node(newNode2)
        newNode2.add_dependency_node(newNode1)

        newGraph = QueryGraph()

        newGraph.add_node(newNode)
        newGraph.add_node(newNode2)
        newGraph.add_node(newNode1)

        oldGraph.add_query(newGraph)

        self.assertTrue(oldGraph.get_node_by_name("test2") is newNode2)
Пример #11
0
 def test_add_node(self):
     graph = QueryGraph()
     node = SqlCTENode("test", "test")
     graph.add_node(node)
     self.assertEqual(graph.get_node_by_name("test"), node)
Пример #12
0
 def test_add_node(self):
     graph = QueryGraph()
     node = SqlCTENode("test", "test")
     graph.add_node(node)
     self.assertEqual(graph.get_node_by_name("test"), node)