def test_au_e_enc_full(self): g = graphistry.bind(source='s', destination='d', edge_color='c', edge_title='t', edge_label='l', edge_weight='w', edge_opacity='o', edge_icon='i', edge_size='s', edge_source_color='sc', edge_destination_color='dc') au = ArrowUploader() assert au.g_to_edge_encodings(g) == \ { 'source': 's', 'destination': 'd', 'edge_color': 'c', 'edge_title': 't', 'edge_label': 'l', 'edge_weight': 'w', 'edge_opacity': 'o', 'edge_icon': 'i', 'edge_size': 's', 'edge_source_color': 'sc', 'edge_destination_color': 'dc' }
def test_au_n_enc_full(self): g = graphistry.bind(node='n', point_color='c', point_size='s', point_title='t', point_label='l', point_weight='w', point_opacity='o', point_icon='i', point_x='x', point_y='y') au = ArrowUploader() assert au.g_to_node_encodings(g) == \ { 'node': 'n', 'node_color': 'c', 'node_size': 's', 'node_title': 't', 'node_label': 'l', 'node_weight': 'w', 'node_opacity': 'o', 'node_icon': 'i', 'node_x': 'x', 'node_y': 'y', }
def test_au_e_enc_full(self): g = graphistry.bind(source='s', destination='d', edge_color='c', edge_title='t', edge_label='l', edge_weight='w', edge_opacity='o', edge_icon='i', edge_size='s', edge_source_color='sc', edge_destination_color='dc') g = g.encode_edge_color('c', ["green"], as_categorical=True) au = ArrowUploader() assert au.g_to_edge_encodings(g) == { 'bindings': { 'source': 's', 'destination': 'd', 'edge_color': 'c', 'edge_title': 't', 'edge_label': 'l', 'edge_weight': 'w', 'edge_opacity': 'o', 'edge_icon': 'i', 'edge_size': 's', 'edge_source_color': 'sc', 'edge_destination_color': 'dc' }, 'complex': { 'default': { 'edgeColorEncoding': { 'graphType': 'edge', 'encodingType': 'color', 'attribute': 'c', 'variation': 'categorical', 'colors': ['green'] } } } }
def test_au_n_enc_full(self): g = graphistry.bind(node='n', point_color='c', point_size='s', point_title='t', point_label='l', point_weight='w', point_opacity='o', point_icon='i', point_x='x', point_y='y') g = g.encode_point_color('c', ["green"], as_categorical=True) au = ArrowUploader() assert au.g_to_node_encodings(g) == { 'bindings': { 'node': 'n', 'node_color': 'c', 'node_size': 's', 'node_title': 't', 'node_label': 'l', 'node_weight': 'w', 'node_opacity': 'o', 'node_icon': 'i', 'node_x': 'x', 'node_y': 'y', }, 'complex': { 'default': { 'pointColorEncoding': { 'graphType': 'point', 'encodingType': 'color', 'attribute': 'c', 'variation': 'categorical', 'colors': ['green'] } } } }
def test_login(self, mock_post): mock_resp = self._mock_response(json_data={'token': '123'}) mock_post.return_value = mock_resp au = ArrowUploader() tok = au.login(username="******", password="******").token assert tok == "123"
def test_au_init_args(self): n = pd.DataFrame({'n': []}) e = pd.DataFrame({'e': []}) sbp = "s" vbp = "v" name = "n" t = "t" d = "d" ne = {"point_color": "c"} ee = {"edge_color": "c"} m = {"n": "n"} ce = False au = ArrowUploader(server_base_path=sbp, view_base_path=vbp, name=name, edges=e, nodes=n, node_encodings=ne, edge_encodings=ee, token=t, dataset_id=d, metadata=m, certificate_validation=ce) assert au.server_base_path == sbp assert au.view_base_path == vbp assert au.name == name assert au.edges is e assert au.nodes is n assert au.edge_encodings == ee assert au.node_encodings == ne assert au.token == t assert au.dataset_id == d assert au.certificate_validation == ce
def test_au_init_plain(self): au = ArrowUploader() with pytest.raises(Exception): au.token with pytest.raises(Exception): au.dataset_id assert au.edges is None assert au.nodes is None assert au.node_encodings == {'bindings': {}} assert au.edge_encodings == {'bindings': {}} assert len(au.name) > 0 assert not (au.metadata is None)
def test_au_n_enc_mt(self): g = graphistry.bind() au = ArrowUploader() assert au.g_to_node_encodings(g) == {'bindings': {}}
def test_au_e_enc_mt(self): g = graphistry.bind() au = ArrowUploader() assert au.g_to_edge_encodings(g) == {}