Exemplo n.º 1
0
 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信息提示错误")
Exemplo n.º 2
0
 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, "添加边类型状态码不正确")
Exemplo n.º 3
0
 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, "添加顶点类型状态码不正确")
Exemplo n.º 4
0
 def setUp(self):
     """
     每条case的前提条件
     :return:
     """
     init_graph()
     GraphConnection().add_graph_connect(body={
         "name": _cfg.graph_name + "_test1",
         "graph": _cfg.graph_name,
         "host": _cfg.graph_host,
         "port": _cfg.server_port
     })
     query = {
         "content": "graph.schema().propertyKey('名称').asText().ifNotExist().create();"
                    "graph.schema().propertyKey('类型').asText().valueSet().ifNotExist().create();"
                    "graph.schema().propertyKey('发行时间').asDate().ifNotExist().create();"
                    "graph.schema().vertexLabel('电影').useCustomizeStringId().properties('名称', '类型', '发行时间')"
                    ".nullableKeys('类型','发行时间').ifNotExist().create();"
                    "graph.schema().vertexLabel('艺人').useCustomizeStringId().ifNotExist().create();"
                    "graph.schema().vertexLabel('类型').useCustomizeStringId().ifNotExist().create();"
                    "graph.schema().vertexLabel('年份').useCustomizeStringId().ifNotExist().create();"
                    "graph.schema().edgeLabel('导演').link('艺人', '电影').ifNotExist().create();"
                    "graph.schema().edgeLabel('演出').link('艺人', '电影').ifNotExist().create();"
                    "graph.schema().edgeLabel('属于').link('电影', '类型').properties('发行时间').ifNotExist().create();"
                    "graph.schema().edgeLabel('发行于').link('电影', '年份').ifNotExist().create();"
     }
     Gremlin().gremlin_post(query=query["content"], host=_cfg.graph_host, port=_cfg.server_port)
Exemplo n.º 5
0
 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, "添加属性状态码不正确")
Exemplo n.º 6
0
 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, "添加属性状态码不正确")
Exemplo n.º 7
0
 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, "添加属性状态码不正确")
Exemplo n.º 8
0
 def test_addCollectionStatement(self):
     """
     添加收藏语句
     """
     self.test_add_graph_connect()
     code, res = GraphConnection().get_graph_connect()
     graph_id = res['data']['records'][0]['id']
     body = {"name": "collection1", "content": "g.V()"}
     code, res = Collection.collect_query_statement(body, graph_id)
     self.assertEqual(code, 200, "响应状态码不正确")
     self.assertEqual(res['status'], 200, "添加收藏语句状态码不正确")
Exemplo n.º 9
0
 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",
                      "查询顶点类型结果不正确")
Exemplo n.º 10
0
def init_graph():
    """
    对测试环境进行初始化操作
    """

    code, res = GraphConnection().get_graph_connect()
    assert code == 200
    connection_list = res['data']['records']
    for each in connection_list:
        each_id = each['id']
        each_graph = each['graph']
        each_host = each['host']
        each_port = each['port']
        # clear graph
        if _cfg.server_backend == 'cassandra':
            clear_graph(graph_name=each_graph, graph_host=each_host, graph_port=each_port)
        else:
            Gremlin().gremlin_post('graph.truncateBackend();')  # 适用gremlin语句进行truncate操作
        # delete graph_connection
        code, res = GraphConnection().delete_graph_connect(each_id)
        assert code == 200
Exemplo n.º 11
0
 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",
                      "查询边类型结果不正确")
Exemplo n.º 12
0
 def test_updateGraphConnect_updateGraphId(self):
     """
     修改图链接,修改图id
     """
     self.test_add_graph_connect()
     body = {
         "name": _cfg.graph_name + "_update1",
         "graph": _cfg.graph_name,
         "host": _cfg.graph_host,
         "port": _cfg.server_port
     }
     code, res = GraphConnection().get_graph_connect()
     graph_id = res['data']['records'][0]['id']
     code, res = GraphConnection().update_graph_connect(body=body,
                                                        graph_id=graph_id)
     self.assertEqual(code, 200, "响应状态码不正确")
     self.assertEqual(res['status'], 200, "添加图链接状态码不正确")
     self.assertEqual(res['data']['name'], body['name'], "图id有误")
     self.assertEqual(res['data']['graph'], body['graph'], "图名称有误")
     self.assertEqual(res['data']['host'], body['host'], "图主机名有误")
     self.assertEqual(res['data']['port'], body['port'], "图端口号有误")
Exemplo n.º 13
0
 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, "删除边类型状态码不正确")
Exemplo n.º 14
0
 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, "删除顶点类型状态码不正确")
Exemplo n.º 15
0
 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, "删除属性状态码不正确")
Exemplo n.º 16
0
 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",
                      "查看属性基数不正确")
Exemplo n.º 17
0
 def test_add_graph_connect(self):
     """
     添加图链接
     """
     body = {
         "name": _cfg.graph_name + "_test1",
         "graph": _cfg.graph_name,
         "host": _cfg.graph_host,
         "port": _cfg.server_port
     }
     code, res = GraphConnection().add_graph_connect(body=body)
     self.assertEqual(code, 200, "响应状态码不正确")
     self.assertEqual(res['status'], 200, "添加图链接状态码不正确")
     self.assertEqual(res['data']['name'], body['name'], "图id有误")
     self.assertEqual(res['data']['graph'], body['graph'], "图名称有误")
     self.assertEqual(res['data']['host'], body['host'], "图主机名有误")
     self.assertEqual(res['data']['port'], body['port'], "图端口号有误")