def test_addEdgeLabel(self): """ 添加边类型 """ self.test_addVertexLabel_PRIMARYKEY() code, res = GraphConnection().get_graph_connect() graph_id = res['data']['records'][0]['id'] body = { "name": "link1", "source_label": "vertexLabel1", "target_label": "vertexLabel1", "link_multi_times": False, "properties": [], "sort_keys": [], "property_indexes": [], "open_label_index": False, "style": { "color": "#112233", "with_arrow": True, "thickness": "FINE", "display_fields": ["~id"], "join_symbols": ["-"] } } code, res = Schema.create_edgeLabel(body, graph_id) self.assertEqual(code, 200, "响应状态码不正确") self.assertEqual(res['status'], 200, "添加边类型状态码不正确")
def test_addVertexLabel_PRIMARYKEY(self): """ 添加顶点类型,ID策略(主键) """ self.test_addProperty_textSingle() code, res = GraphConnection().get_graph_connect() graph_id = res['data']['records'][0]['id'] body = { "name": "vertexLabel1", "id_strategy": "PRIMARY_KEY", "properties": [{ "name": "string1", "nullable": False }], "primary_keys": ["string1"], "property_indexes": [], "open_label_index": False, "style": { "color": "#569380", "icon": None } } code, res = Schema.create_vertexLabel(body, graph_id) self.assertEqual(code, 200, "响应状态码不正确") self.assertEqual(res['status'], 200, "添加顶点类型状态码不正确")
def test_addVertexLabel_PRIMARYKEY_labelIndexNotNull_PRIMARYKEYPropertyNull( self): """ 异常case,添加顶点类型,ID策略(主键),类型索引不为空,主键属性为空 """ self.test_addProperty_textSingle() code, res = GraphConnection().get_graph_connect() graph_id = res['data']['records'][0]['id'] body = { "name": "vertexLabel1", "id_strategy": "PRIMARY_KEY", "properties": [{ "name": "string1", "nullable": False }], "primary_keys": [], "property_indexes": [], "open_label_index": True, "style": { "color": "#569380", "icon": None } } code, res = Schema.create_vertexLabel(body, graph_id) self.assertEqual(code, 200, "响应状态码不正确") self.assertEqual(res['status'], 400, "添加顶点类型状态码不正确") self.assertEqual(res['message'], "顶点类型 vertexLabel1 的主键属性不能为空", "message信息提示错误")
def test_addProperty_blobSet(self): """ 添加属性,数据类型为BLOB,基数为set """ self.test_add_graph_connect() code, res = GraphConnection().get_graph_connect() graph_id = res['data']['records'][0]['id'] body = {"name": "blob3", "data_type": "BLOB", "cardinality": "SET"} code, res = Schema.create_property(body, graph_id) self.assertEqual(code, 200, "响应状态码不正确") self.assertEqual(res['status'], 200, "添加属性状态码不正确")
def test_addProperty_dateList(self): """ 添加属性,数据类型为DATE,基数为list """ self.test_add_graph_connect() code, res = GraphConnection().get_graph_connect() graph_id = res['data']['records'][0]['id'] body = {"name": "date2", "data_type": "DATE", "cardinality": "LIST"} code, res = Schema.create_property(body, graph_id) self.assertEqual(code, 200, "响应状态码不正确") self.assertEqual(res['status'], 200, "添加属性状态码不正确")
def test_addProperty_uuidSingle(self): """ 添加属性,数据类型为UUID,基数为single """ self.test_add_graph_connect() code, res = GraphConnection().get_graph_connect() graph_id = res['data']['records'][0]['id'] body = {"name": "uuid1", "data_type": "UUID", "cardinality": "SINGLE"} code, res = Schema.create_property(body, graph_id) self.assertEqual(code, 200, "响应状态码不正确") self.assertEqual(res['status'], 200, "添加属性状态码不正确")
def test_queryEdgeLabel(self): """ 查看边类型 """ self.test_addEdgeLabel() code, res = GraphConnection().get_graph_connect() graph_id = res['data']['records'][0]['id'] code, res = Schema.get_edgeLabel(graph_id) self.assertEqual(code, 200, "响应状态码不正确") self.assertEqual(res['status'], 200, "查询边类型状态码不正确") self.assertEqual(res['data']["records"][0]["name"], "link1", "查询边类型结果不正确")
def test_queryVertexLabel(self): """ 查看顶点类型 """ self.test_addVertexLabel_PRIMARYKEY() code, res = GraphConnection().get_graph_connect() graph_id = res['data']['records'][0]['id'] code, res = Schema.get_vertexLabel(graph_id) self.assertEqual(code, 200, "响应状态码不正确") self.assertEqual(res['status'], 200, "查询顶点类型状态码不正确") self.assertEqual(res['data']["records"][0]["name"], "vertexLabel1", "查询顶点类型结果不正确")
def test_deleteEdgeLabel(self): """ 删除边类型 """ self.test_addEdgeLabel() code, res = GraphConnection().get_graph_connect() graph_id = res['data']['records'][0]['id'] code, res = Schema.delete_edgeLabel(param={ "names": "link1", "skip_using": False }, graph_id=graph_id) self.assertEqual(code, 200, "响应状态码不正确") self.assertEqual(res['status'], 200, "删除边类型状态码不正确")
def test_deleteVertexLabel(self): """ 删除顶点类型 """ self.test_addVertexLabel_PRIMARYKEY() code, res = GraphConnection().get_graph_connect() graph_id = res['data']['records'][0]['id'] code, res = Schema.delete_vertexLabel(param={ "names": "vertexLabel1", "skip_using": False }, graph_id=graph_id) self.assertEqual(code, 200, "响应状态码不正确") self.assertEqual(res['status'], 200, "删除顶点类型状态码不正确")
def test_deleteProperty(self): """ 删除属性 """ self.test_addProperty_textSingle() code, res = GraphConnection().get_graph_connect() graph_id = res['data']['records'][0]['id'] code, res = Schema.delete_property(param={ "names": "string1", "skip_using": False }, graph_id=graph_id) self.assertEqual(code, 200, "响应状态码不正确") self.assertEqual(res['status'], 200, "删除属性状态码不正确")
def test_queryProperty(self): """ 查看属性 """ self.test_addProperty_textSingle() code, res = GraphConnection().get_graph_connect() graph_id = res['data']['records'][0]['id'] code, res = Schema.get_property(graph_id) self.assertEqual(code, 200, "响应状态码不正确") self.assertEqual(res['status'], 200, "查看属性状态码不正确") self.assertEqual(res['data']["records"][0]["name"], "string1", "查看属性名称不正确") self.assertEqual(res['data']["records"][0]["data_type"], "TEXT", "查看属性类型不正确") self.assertEqual(res['data']["records"][0]["cardinality"], "SINGLE", "查看属性基数不正确")