def test_update_graph(name): graphspace = GraphSpace('*****@*****.**', 'user1') graph1 = GSGraph() if name is not None: graph1.set_name(name) graph1.add_node('a', popup='sample node popup text', label='A updated') graph1.add_node_style('a', shape='ellipse', color='green', width=90, height=90) graph1.add_node('b', popup='sample node popup text', label='B updated') graph1.add_node_style('b', shape='ellipse', color='yellow', width=40, height=40) graph1.set_is_public() graph1.set_data(data={'description': 'my sample graph'}) graph = graphspace.update_graph(graph1) assert type(graph) is Graph assert graph.get_name() == graph1.get_name() and graph.is_public == 1 assert len(graph.graph_json['elements']['edges']) == 0 assert len(graph.graph_json['elements']['nodes']) == 2
def test_post_graph(name=None): graphspace = GraphSpace('*****@*****.**', 'user1') graph1 = GSGraph() if name is not None: graph1.set_name(name) graph1.add_node('a', popup='sample node popup text', label='A') graph1.add_node_style('a', shape='ellipse', color='red', width=90, height=90) graph1.add_node('b', popup='sample node popup text', label='B') graph1.add_node_style('b', shape='ellipse', color='blue', width=40, height=40) graph1.add_edge('a', 'b', directed=True, popup='sample edge popup') graph1.add_edge_style('a', 'b', directed=True, edge_style='dotted') graph1.set_data(data={'description': 'my sample graph'}) graph1.set_tags(['sample']) graph = graphspace.post_graph(graph1) assert type(graph) is Graph assert graph.get_name() == graph1.get_name() return graph
def test_update_graph(name): graphspace = GraphSpace('*****@*****.**', 'user1') graphspace.set_api_host('localhost:8000') graph1 = GSGraph() if name is not None: graph1.set_name(name) graph1.add_node('a', popup='sample node popup text', label='A updated') graph1.add_node_style('a', shape='ellipse', color='green', width=90, height=90) graph1.add_node('b', popup='sample node popup text', label='B updated') graph1.add_node_style('b', shape='ellipse', color='yellow', width=40, height=40) graph1.set_data(data={'description': 'my sample graph'}) response = graphspace.update_graph(name, graph=graph1, is_public=1) assert 'name' in response and response['name'] == graph1.get_name() assert response['is_public'] == 1 assert len(response['graph_json']['elements']['edges']) == 0 assert len(response['graph_json']['elements']['nodes']) == 2
def test_post_graph(name=None): graphspace = GraphSpace('*****@*****.**', 'user1') graphspace.set_api_host('localhost:8000') graph1 = GSGraph() if name is not None: graph1.set_name(name) graph1.add_node('a', popup='sample node popup text', label='A') graph1.add_node_style('a', shape='ellipse', color='red', width=90, height=90) graph1.add_node('b', popup='sample node popup text', label='B') graph1.add_node_style('b', shape='ellipse', color='blue', width=40, height=40) graph1.add_edge('a', 'b', directed=True, popup='sample edge popup') graph1.add_edge_style('a', 'b', directed=True, edge_style='dotted') graph1.set_data(data={'description': 'my sample graph'}) graph1.set_tags(['sample']) response = graphspace.post_graph(graph1) assert 'name' in response and response['name'] == graph1.get_name()
def test_update_graph2(name): graphspace = GraphSpace('*****@*****.**', 'user1') graphspace.set_api_host('localhost:8000') # Retrieving graph graph = graphspace.get_graph(name) # Creating updated graph object G = GSGraph() G.set_graph_json(graph.get('graph_json')) G.set_style_json(graph.get('style_json')) G.set_name(graph.get('name')) G.set_tags(graph.get('name')) # Updating graph response = graphspace.update_graph(name, graph=G, is_public=1) assert 'name' in response and response['name'] == G.get_name() assert response['is_public'] == 1