Exemplo n.º 1
0
 def test_update_edge_mapping(self):
     """
     更新边映射
     """
     self.test_add_edge_mapping()
     graph_id, job_id, file_id, edge_id = ID.get_edgeMapping_id()
     # 发行于
     edge_issue = {
         "label": "发行于",
         "source_fields": ["名称"],
         "target_fields": ["发行时间"],
         "field_mapping": [],
         "value_mapping": [],
         "null_values": {
             "checked": ["NULL", "null"],
             "customized": ["EMPTY"]
         }
     }
     code, res = Mapping.update_edge_mapping(body=edge_issue, graph_id=graph_id, job_id=job_id, file_id=file_id,
                                             edge_id=edge_id)
     self.assertEqual(code, 200, "响应状态码不正确")
     self.assertEqual(res['status'], 200, "修改边映射状态码不正确")
     self.assertEqual(res['data']['edge_mappings'][0]['label'], edge_issue['label'], "修改边映射有误")
     self.assertEqual(res['data']['edge_mappings'][0]['null_values']['customized'],
                      edge_issue['null_values']['customized'], "边映射空值列表修改有误")
Exemplo n.º 2
0
 def test_update_vertex_mapping(self):
     """
     更新顶点映射
     """
     self.test_add_vertex_mapping()
     graph_id, job_id, file_id, vertex_id = ID.get_vertexMapping_id()
     vertex_movie = {
         "label": "电影",
         "id_fields": ["名称"],
         "field_mapping": [{
             "column_name": "发行时间",
             "mapped_name": "发行时间_更新"
         }, {
             "column_name": "类型",
             "mapped_name": "类型"
         }],
         "value_mapping": [],
         "null_values": {
             "checked": ["NULL", "null"],
             "customized": []
         }
     }
     code, res = Mapping.update_vertex_mapping(body=vertex_movie, graph_id=graph_id, job_id=job_id, file_id=file_id,
                                               vertex_id=vertex_id)
     self.assertEqual(code, 200, "响应状态码不正确")
     self.assertEqual(res['status'], 200, "修改顶点映射状态码不正确")
     self.assertEqual(res['data']['vertex_mappings'][1]['field_mapping'][0]['mapped_name'],
                      vertex_movie['field_mapping'][0]['mapped_name'], "顶点映射修改有误")
Exemplo n.º 3
0
 def test_delete_load_job(self):
     """
     删除任务
     """
     self.test_stop_load()
     graph_id, job_id, file_id, task_id = ID.get_task_id()
     code, res = Load.delete_load_job(graph_id=graph_id, job_id=job_id)
     self.assertEqual(code, 200, "响应状态码不正确")
     self.assertEqual(res['status'], 200, "删除任务状态码不正确,删除任务失败")
Exemplo n.º 4
0
 def test_delete_edge_mapping(self):
     """
     删除单个边映射
     """
     self.test_add_edge_mapping()
     graph_id, job_id, file_id, edge_id = ID.get_edgeMapping_id()
     code, res = Mapping.delete_edge_mapping(graph_id=graph_id, job_id=job_id, file_id=file_id, edge_id=edge_id)
     self.assertEqual(code, 200, "响应状态码不正确")
     self.assertEqual(res['status'], 200, "删除边映射状态码不正确")
Exemplo n.º 5
0
 def test_get_load_task(self):
     """
     查询导入任务
     """
     self.test_stop_load()
     graph_id, job_id, file_id, task_id = ID.get_task_id()
     param = "task_id=%d" % task_id
     code, res = Load.query_load_task(graph_id=graph_id, job_id=job_id, param=param)
     self.assertEqual(code, 200, "响应状态码不正确")
     self.assertEqual(res['status'], 200, "查询导入状态码不正确,查询导入任务失败")
Exemplo n.º 6
0
    def test_delete_vertex_mapping(self):
        """
        删除一个顶点映射
        """
        self.test_add_vertex_mapping()
        graph_id, job_id, file_id, vertex_id = ID.get_vertexMapping_id()

        code, res = Mapping.delete_vertex_mapping(graph_id=graph_id, job_id=job_id, file_id=file_id,
                                                  vertex_id=vertex_id)
        self.assertEqual(code, 200, "响应状态码不正确")
        self.assertEqual(res['status'], 200, "删除顶点映射状态码不正确")
Exemplo n.º 7
0
 def test_retry_load(self):
     """
     点击重试导入
     """
     self.test_stop_load()
     graph_id, job_id, file_id, task_id = ID.get_task_id()
     param = "task_id=%d" % task_id
     code, res = Load.retry_load(graph_id=graph_id, job_id=job_id, param=param)
     self.assertEqual(code, 200, "响应状态码不正确")
     self.assertEqual(res['status'], 200, "重试导入状态码不正确,重试导入失败")
     self.assertEqual(res['data']['status'], 'RUNNING', "重试导入错误")
Exemplo n.º 8
0
 def test_stop_load(self):
     """
     点击停止导入
     """
     self.test_resume_load()
     graph_id, job_id, file_id, task_id = ID.get_task_id()
     param = "task_id=%d" % task_id
     code, res = Load.stop_load(graph_id=graph_id, job_id=job_id, param=param)
     self.assertEqual(code, 200, "响应状态码不正确")
     self.assertEqual(res['status'], 200, "停止导入状态码不正确,停止导入失败")
     self.assertEqual(res['data']['status'], 'STOPPED', "停止导入错误")
Exemplo n.º 9
0
 def test_pause_load(self):
     """
     点击暂停导入
     """
     self.test_start_load()
     graph_id, job_id, file_id, task_id = ID.get_task_id()
     param = "task_id=%d" % task_id
     code, res = Load.pause_load(graph_id=graph_id, job_id=job_id, param=param)
     self.assertEqual(code, 200, "响应状态码不正确")
     self.assertEqual(res['status'], 200, "暂停导入状态码不正确,暂停导入失败")
     self.assertEqual(res['data']['status'], 'PAUSED', "暂停导入错误")
Exemplo n.º 10
0
 def test_start_load(self):
     """
     点击开始导入
     """
     self.test_add_load_setting()
     graph_id, job_id, file_id = ID.get_file_id()
     param = "file_mapping_ids=%d" % file_id
     code, res = Load.start_load(graph_id=graph_id, job_id=job_id, param=param)
     self.assertEqual(code, 200, "响应状态码不正确")
     self.assertEqual(res['status'], 200, "开始导入状态码不正确,开始导入失败")
     self.assertEqual(res['data'][0]['status'], 'RUNNING', "开始导入错误")
Exemplo n.º 11
0
 def test_create_load_job(self):
     """
     创建导入任务
     """
     graph_id = ID.get_graph_id()
     body = {"job_name": "load_01", "job_remarks": "第一次导入"}
     code, res = Load.create_load_job(body=body, graph_id=graph_id)
     self.assertEqual(code, 200, "响应状态码不正确")
     self.assertEqual(res['status'], 200, "创建导入任务状态码不正确")
     self.assertEqual(res['data']['job_name'], body['job_name'], "导入任务名称有误")
     self.assertEqual(res['data']['job_remarks'], body['job_remarks'], "任务备注有误")
Exemplo n.º 12
0
 def test_update_load_job(self):
     """
     修改导入任务名称和备注
     """
     self.test_get_load_job()
     graph_id, job_id = ID.get_job_id()
     body = {"job_name": "load_01_update", "job_remarks": "修改任务名称和备注"}
     code, res = Load.update_load_job(body=body, graph_id=graph_id, job_id=job_id)
     self.assertEqual(code, 200, "响应状态码不正确")
     self.assertEqual(res['status'], 200, "修改导入任务名称和备注状态码不正确,修改导入任务名称和备注失败")
     self.assertEqual(res['data']['job_name'], body['job_name'], "修改导入任务名称有误")
     self.assertEqual(res['data']['job_remarks'], body['job_remarks'], "修改导入任务备注有误")
Exemplo n.º 13
0
 def test_resume_load(self):
     """
     点击继续导入
     """
     self.test_pause_load()
     graph_id, job_id, file_id, task_id = ID.get_task_id()
     param = "task_id=%d" % task_id
     time.sleep(1)
     code, res = Load.resume_load(graph_id=graph_id, job_id=job_id, param=param)
     self.assertEqual(code, 200, "响应状态码不正确")
     self.assertEqual(res['status'], 200, "继续导入状态码不正确,继续导入失败")
     self.assertEqual(res['data']['status'], 'RUNNING', "继续导入错误")
Exemplo n.º 14
0
 def test_upload_file(self):
     """
     上传文件
     """
     self.test_create_load_job()
     graph_id, job_id = ID.get_job_id()
     res = File.get_loadfile_token(graph_id=graph_id, job_id=job_id, param="names=movie.csv")
     token = res[1]["data"]["movie.csv"]
     param = "total=1&index=1&name=movie.csv&token=%s" % token
     files = {"file": open(current_path + "/../../../config/dataset/movie/movie.csv", 'rb')}
     code, res = File.upload_file(graph_id=graph_id, job_id=job_id, files=files, param=param)
     self.assertEqual(code, 200, "响应状态码不正确")
     self.assertEqual(res['status'], 200, "上传文件状态码不正确")
     self.assertEqual(res['data']['name'], "movie.csv", "上传文件有误")
     self.assertEqual(res['data']['status'], "SUCCESS", "上传文件失败")
Exemplo n.º 15
0
 def test_add_load_setting(self):
     """
     设置导入参数
     """
     self.test_add_edge_mapping()
     graph_id, job_id = ID.get_job_id()
     body = {
         "check_vertex": False,
         "insert_timeout": 60,
         "max_parse_errors": 500,
         "max_insert_errors": 500,
         "retry_times": 3,
         "retry_interval": 10
     }
     # 点击下一步
     Step.mapping_complete_next_step(graph_id=graph_id, job_id=job_id)
     code, res = Load.add_load_setting(body=body, graph_id=graph_id, job_id=job_id)
     self.assertEqual(code, 200, "响应状态码不正确")
     self.assertEqual(res['status'], 200, "设置导入参数状态码不正确")
Exemplo n.º 16
0
 def test_add_vertex_mapping(self):
     """
     设置顶点映射
     """
     self.test_add_file_setting()
     graph_id, job_id, file_id = ID.get_file_id()
     vertex_movie = {
         "label": "电影",
         "id_fields": ["名称"],
         "field_mapping": [{
             "column_name": "发行时间",
             "mapped_name": "发行时间"
         }, {
             "column_name": "类型",
             "mapped_name": "类型"
         }],
         "value_mapping": [],
         "null_values": {
             "checked": ["NULL", "null"],
             "customized": []
         }
     }
     # 年份
     vertex_time = {
         "label": "年份",
         "id_fields": ["发行时间"],
         "field_mapping": [],
         "value_mapping": [],
         "null_values": {
             "checked": ["NULL", "null"],
             "customized": []
         },
     }
     code, res = Mapping.add_vertex_mapping(body=vertex_movie, graph_id=graph_id, job_id=job_id, file_id=file_id)
     Mapping.add_vertex_mapping(body=vertex_time, graph_id=graph_id, job_id=job_id, file_id=file_id)
     self.assertEqual(code, 200, "响应状态码不正确")
     self.assertEqual(res['status'], 200, "文件添加顶点映射状态码不正确")
     self.assertEqual(res['data']['vertex_mappings'][0]['label'], vertex_movie['label'], "映射的顶点类型有误")
     self.assertEqual(res['data']['vertex_mappings'][0]['id_fields'], vertex_movie['id_fields'], "ID列有误")
     self.assertEqual(res['data']['vertex_mappings'][0]['field_mapping'], vertex_movie['field_mapping'], "列映射错误")
Exemplo n.º 17
0
 def test_add_file_setting(self):
     """
     添加文件设置
     """
     self.test_upload_file()
     graph_id, job_id, file_id = ID.get_file_id()
     # 点击下一步
     Step.upload_file_next_step(graph_id=graph_id, job_id=job_id)
     body = {
         "has_header": True,
         "delimiter": ",",
         "format": "CSV",
         "charset": "UTF-8",
         "date_format": "yyyy",
         "time_zone": "GMT+8",
         "skipped_line": "(^#^//).*"
     }
     code, res = Mapping.add_file_setting(body=body, graph_id=graph_id, job_id=job_id, file_id=file_id)
     self.assertEqual(code, 200, "响应状态码不正确")
     self.assertEqual(res['status'], 200, "文件设置状态码不正确")
     self.assertEqual(res['data']['file_setting']['has_header'], body['has_header'], "文件头设置有误")
     self.assertEqual(res['data']['file_setting']['delimiter'], body['delimiter'], "文件分隔符设置有误")
     self.assertEqual(res['data']['file_setting']['date_format'], body['date_format'], "文件时间格式设置有误")
Exemplo n.º 18
0
 def test_add_edge_mapping(self):
     """
     设置边映射
     """
     self.test_add_vertex_mapping()
     graph_id, job_id, file_id = ID.get_file_id()
     # 发行于
     edge_issue = {
         "label": "发行于",
         "source_fields": ["名称"],
         "target_fields": ["发行时间"],
         "field_mapping": [],
         "value_mapping": [],
         "null_values": {
             "checked": ["NULL", "null"],
             "customized": []
         }
     }
     code, res = Mapping.add_edge_mapping(body=edge_issue, graph_id=graph_id, job_id=job_id, file_id=file_id)
     self.assertEqual(code, 200, "响应状态码不正确")
     self.assertEqual(res['status'], 200, "文件添加边映射状态码不正确")
     self.assertEqual(res['data']['edge_mappings'][0]['label'], edge_issue['label'], "映射的边类型有误")
     self.assertEqual(res['data']['edge_mappings'][0]['source_fields'], edge_issue['source_fields'], "起点映射有误")
     self.assertEqual(res['data']['edge_mappings'][0]['target_fields'], edge_issue['target_fields'], "终点映射有误")