def test_get_node_by_name(self): name = "test_name" self.assertEqual(_create_test_node(name=name), Nodzgraph.get_node_by_name(name)) name = "another_test_name" self.assertEqual(_create_test_node(name=name), Nodzgraph.get_node_by_name(name))
def initializePlugin(mobject): LOG.info("Initializing CocoNodz") _to_plugin(mobject) # add CocoNodz menu MENU.init() # if there are not events registered reinitialize them if not NODZGRAPH.events.registered_events: NODZGRAPH.register_events() # refresh the attribute editor rebuild_attribute_editor()
def test_load_configuration(self): old_width = Nodzgraph.configuration.scene_width new_width = old_width + 100 Nodzgraph.configuration.scene_width = new_width self.assertEqual(new_width, Nodzgraph.configuration.scene_width) Nodzgraph.load_configuration( os.path.join(os.path.dirname(coconodz.__file__), "nodegraph.config")) self.assertEqual(Nodzgraph.configuration.scene_width, old_width)
def test_display_host_nodes(self): """ visual testing Returns: """ Nodzgraph.display_host_nodes(_nodes_setup(), self._test_attrs_data, self._test_cons_data) Nodzgraph.open() application.exec_()
def test_search_field_available_items(self): self.assertIsInstance(Nodzgraph.search_field.available_items, list) name = "test_search_field" node = _create_test_node(name) # mimic search_field open Nodzgraph.on_search_field_opened() self.assertListEqual([node.name], Nodzgraph.search_field.available_items) Nodzgraph.search_field.signal_input_accepted.emit(name) self.assertTrue(node.isSelected())
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()))
def test_save_configuration(self): tmp_dir = tempfile.gettempdir() config_file = Nodzgraph.save_configuration( os.path.join(tmp_dir, str(time.time()) + "_coconodz.config")) self.assertTrue(os.path.exists(config_file)) try: os.remove(config_file) except OSError: raise
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"])
from coconodz import (Nodzgraph, application, Qt) from coconodz.lib import Backdrop if __name__ == '__main__': # open Nodzgraph standalone if application: text = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet." Nodzgraph.open() #Nodzgraph.graph.creation_field.available_items = ["test", "blabla" "backdrop"] Nodzgraph.attribute_context.mode = "plug" Nodzgraph.attribute_context.available_items = { "blabla": "", "blabla22": "" } node1 = Nodzgraph.graph.create_node("SimNode", node_type="SimNode") node2 = Nodzgraph.graph.create_node("MeshingNode", node_type="MeshingNode") node3 = Nodzgraph.graph.create_node("CachingNode", node_type="CachingNode") application.exec_()
def setUp(self): Nodzgraph.clear()