def test_adding_one_million_nodes(self): g = Grafellow() other = {} i = 0 node_type = 'test_node' while True: i += 1 if i > 1000000: break g.add_node(i,node_type)
def test_add_non_directed_edge_with_multiple_edges_and_tuples(self): g = Grafellow() g.add_non_directed_edge('zach', 'person', 'laura', 'person', edge_type='friends') g.add_non_directed_edge('zach', 'person', 'jaco', 'robot', edge_type='friends') self.assertTrue(('jaco','robot') in g.node_edges('zach', 'person')) self.assertTrue(('laura','person') in g.node_edges('zach', 'person'))
def test_retrieving_edge_type(self): g = Grafellow(testing=True) g.add_non_directed_edge('zach', 'person', 'laura', 'person', edge_type='friends') g.add_non_directed_edge('zach', 'person', 'jaco', 'robot', edge_type='friends') results = g.node_edges('zach', 'person', edge_types=True) self.assertTrue(('friends', 'jaco', 'robot') in results) self.assertTrue(('friends', 'laura', 'person') in results)
def test_add_non_directed_edge(self): g = Grafellow() g.add_non_directed_edge('zach', 'person', 'laura', 'person', edge_type='friends') self.assertTrue(g.get_node('zach','person') == {}) self.assertTrue(g.get_node('laura','person') == {}) self.assertTrue('laura' in g.node_edges('zach', 'person', other_node_type='person'))
def test_add_node_with_data(self): g = Grafellow() attrs = {'languages': ['python', 'ruby', 'others']} self.assertTrue(g.add_node('zach', 'person', attrs)) self.assertTrue(g.get_node('zach','person'))
def test_add_node(self): g = Grafellow() node_id_should_be = 1 self.assertTrue(g.add_node('zach', 'person') == node_id_should_be)