Example #1
0
    def test_create_connections(self):
        node_setup = _create_nodes_setup()
        Nodzgraph._create_attributes(self._test_attrs_data)
        Nodzgraph._create_connections(self._test_cons_data)

        expected_connections = [
            (x, y) for x, y in self._test_cons_data.iteritems()
            if (x.split(".")[0] in node_setup and y.split(".")[0] in node_setup
                )
        ]

        self.assertListEqual(sorted(expected_connections),
                             sorted(Nodzgraph.graph.evaluateGraph()))
Example #2
0
 def test_create_attributes(self):
     node_setup = _create_nodes_setup()
     x = Nodzgraph.all_node_names
     # create the attributes
     Nodzgraph._create_attributes(self._test_attrs_data)
     # compare created attributes with the expected from _test_attrs_data
     # only considering nodes in node_to_create
     for attr, attr_data in self._test_attrs_data.iteritems():
         node_name = attr.split(".")[0]
         attr_name = attr.split(".")[1]
         if node_name in node_setup:
             self.assertIn(node_name, Nodzgraph.nodes_dict)
             node = Nodzgraph.get_node_by_name(node_name)
             if attr_data["type"] == ("plug" or "slot"):
                 self.assertIn(attr_name, node.plugs)
                 self.assertEqual(node.plugs[attr_name].dataType,
                                  attr_data["data_type"])
             if attr_data["type"] == ("socket" or "slot"):
                 self.assertIn(attr_name, node.sockets)
                 self.assertEqual(node.sockets[attr_name].dataType,
                                  attr_data["data_type"])