def test_org_edit(self, center_builder, dataType):
     '''
     编辑组织机构接口测试
     '''
     # 查询组织机构树
     response = Org().org_nodes(center_builder)
     rootID = response["result_id"][response["result_root"].index(True)]
     # 创建组织机构
     orgName = '接口测试新增机构' + base_utils.generate_random_str()
     org_add = Org().org_orgId_add(center_builder, rootID, orgName=orgName, dataType=dataType)
     org_id = org_add["result_id"][0]
     org_pathId = org_add["result_pathId"][0]
     org_path = org_add["result_path"][0]
     # 编辑组织机构
     newOrgName = '接口测试编辑机构' + base_utils.generate_random_str()
     org_edit = Org().org_orgId_edit(center_builder, orgId=org_id, orgName=newOrgName)
     # 查询组织机构树
     response = Org().org_nodes(center_builder)
     try:
         Assertions().assert_all_code(response, 200, 200)
         # 验证编辑组织接口是否正常
         Assertions().assert_equal_value(org_edit["result_id"][0],org_id)
         Assertions().assert_equal_value(org_edit["result_name"][0],newOrgName)
         Assertions().assert_equal_value(org_edit["result_type"][0],0)
         Assertions().assert_equal_value(org_edit["result_parentId"][0],rootID)
         Assertions().assert_equal_value(org_edit["result_root"][0],False)
         Assertions().assert_equal_value(org_edit["result_dataType"][0],dataType)
         # 验证组织树接口是否返回了新加的组织
         Assertions().assert_in_value(response["result_id"],org_id)
         Assertions().assert_equal_value(response["result_name"][response["result_id"].index(org_id)],newOrgName)
         Assertions().assert_equal_value(response["result_type"][response["result_id"].index(org_id)],0)
         Assertions().assert_equal_value(response["result_parentId"][response["result_id"].index(org_id)],rootID)
         Assertions().assert_equal_value(response["result_root"][response["result_id"].index(org_id)],False)
         Assertions().assert_equal_value(response["result_pathId"][response["result_id"].index(org_id)],org_pathId)
         Assertions().assert_equal_value(response["result_path"][response["result_id"].index(org_id)],org_path)
         Assertions().assert_equal_value(response["result_dataType"][response["result_id"].index(org_id)],dataType)
     finally:
         # 删除组织机构
         Org().org_orgId_del(center_builder, orgId=org_id)
    def test_engineering_template(self, gaolu_login, gaolu_login_luban, env_conf):
        new_template_node1 = "工程划分测试" + base_utils.generate_random_str()
        new_template_node2 = "工程划分测试" + base_utils.generate_random_str()
        new_template_node3 = "工程划分测试" + base_utils.generate_random_str()

        with allure.step("查询工程划分目录"):
            project_tree_resp = Project_template().pageProjectTemplateUsingGET(gaolu_login_luban, pageSize=10000,
                                                                               pageIndex=1)
            if project_tree_resp.get('data_totalCount')[0] == 0:
                print("工程划分节点为空")
            else:
                allure.attach("工程划分节点有: {0} 条数据".format(project_tree_resp.get('data_totalCount')[0]))
        with allure.step("添加工程划分一级节点: {0}".format(new_template_node1)):
            creat_body_node1 = {
                "nameList": [new_template_node1],
                "parentId": "0"
            }
            creat_node1_resp = Project_template().saveProjectTemplateUsingPOST(gaolu_login_luban, creat_body_node1)
            waitForStatus(creat_node1_resp, 200, 200, 15)
        with allure.step("断言添加工程划分一级节点: {0} 添加成功".format(new_template_node1)):
            check_tree_resp1 = Project_template().pageProjectTemplateUsingGET(gaolu_login_luban, pageSize=10000,
                                                                              pageIndex=1)
            Assertions.assert_in_value(check_tree_resp1.get('data_result_name'), new_template_node1)
            allure.attach("断言添加工程划分一级节点: {0} 添加成功".format(new_template_node1))
            node_datas = check_tree_resp1.get('source_response')['data']['result']
            dict_name_id1 = {}
            for data in node_datas:
                dict_name_id1[data['name']] = data['id']
        with allure.step("添加工程划分二级节点: {0}".format(new_template_node2)):
            creat_body_node2 = {
                "nameList": [new_template_node2],
                "parentId": dict_name_id1[new_template_node1]
            }
            creat_node2_resp = Project_template().saveProjectTemplateUsingPOST(gaolu_login_luban, creat_body_node2)
            waitForStatus(creat_node2_resp, 200, 200, 15)
        with allure.step("断言添加工程划分二级节点: {0} 添加成功".format(new_template_node2)):
            check_tree_resp2 = Project_template().pageProjectTemplateUsingGET(gaolu_login_luban, pageSize=10000,
                                                                              pageIndex=1)
            Assertions.assert_in_value(check_tree_resp2.get('data_result_name'), new_template_node2)
            allure.attach("断言添加工程划分二级节点: {0} 添加成功".format(new_template_node2))
            node_datas = check_tree_resp2.get('source_response')['data']['result']
            dict_name_id2 = {}
            for data in node_datas:
                dict_name_id2[data['name']] = data['id']
        with allure.step("添加工程划分三级节点: {0}".format(new_template_node2)):
            creat_body_node3 = {
                "nameList": [new_template_node3],
                "parentId": dict_name_id2[new_template_node2]
            }
            creat_node2_resp = Project_template().saveProjectTemplateUsingPOST(gaolu_login_luban, creat_body_node3)
            waitForStatus(creat_node2_resp, 200, 200, 15)
        with allure.step("断言添加工程划分三级节点: {0} 添加成功".format(new_template_node3)):
            check_tree_resp2 = Project_template().pageProjectTemplateUsingGET(gaolu_login_luban, pageSize=10000,
                                                                              pageIndex=1)
            Assertions.assert_in_value(check_tree_resp2.get('data_result_name'), new_template_node3)
            allure.attach("断言添加工程划分三级节点: {0} 添加成功".format(new_template_node3))
            node_datas = check_tree_resp2.get('source_response')['data']['result']
            dict_name_id3 = {}
            for data in node_datas:
                dict_name_id3[data['name']] = data['id']
        with allure.step("获取资料模板条目列表"):
            resp_temp = Data_template().pageDataTemplateItemUsingGET(gaolu_login_luban, page_size=10000, page_index=1)
            type_dic = {"开工报告": 1,
                        "质量检验(施工)": 2,
                        "交工评定(施工)": 3,
                        "质量检验(监理)": 4,
                        "交工评定(监理)": 5}
            dic_temp = {}
            for data in resp_temp.get('source_response')['data']['result']:
                dic_temp[data['name']] = data['id']
        with allure.step(
                "关联表单模板: {0} 到模板: {1}".format(new_template_node3, env_conf['用例配置']['工程模板']['dataTemplateItemId1'])):
            body1 = {
                "projectTemplateDataTemplates":
                    [{"dataTemplateItemId": dic_temp[env_conf['用例配置']['工程模板']['dataTemplateItemId1']],
                      "type": type_dic['开工报告']}],
                "projectTemplateId": dict_name_id3[new_template_node3]
            }
            bind_resp = Project_template().bindDataTemplate2ProjectTemplateUsingPOST(gaolu_login_luban, body1)
            waitForStatus(bind_resp, 200, 200, 15)
        with allure.step(
                "关联表单模板: {0} 到模板: {1} 成功".format(new_template_node3, env_conf['用例配置']['工程模板']['dataTemplateItemId1'])):
            check_table_resp5 = Project_template().pageProjectTemplateUsingGET(gaolu_login_luban, pageSize=10000,
                                                                               pageIndex=1)
            actual_value = None
            for data in check_table_resp5.get('source_response')['data']['result']:
                if data['name'] == new_template_node3:
                    actual_value = data['projectTemplateDataTemplateResponseList']
            Assertions.assert_in_value(actual_value, env_conf['用例配置']['工程模板']['dataTemplateItemId1'])
        with allure.step(
                "关联表单模板: {0} 到模板: {1}".format(new_template_node3, env_conf['用例配置']['工程模板']['dataTemplateItemId2'])):
            body2 = {
                "projectTemplateDataTemplates":
                    [{"dataTemplateItemId": dic_temp[env_conf['用例配置']['工程模板']['dataTemplateItemId1']],
                      "type": type_dic['开工报告']},
                     {"dataTemplateItemId": dic_temp[env_conf['用例配置']['工程模板']['dataTemplateItemId2']],
                      "type": type_dic['质量检验(施工)']}],
                "projectTemplateId": dict_name_id3[new_template_node3]
            }
            bind_resp = Project_template().bindDataTemplate2ProjectTemplateUsingPOST(gaolu_login_luban, body2)
            waitForStatus(bind_resp, 200, 200, 15)
        with allure.step(
                "关联表单模板: {0} 到模板: {1} 成功".format(new_template_node3, env_conf['用例配置']['工程模板']['dataTemplateItemId2'])):
            check_table_resp5 = Project_template().pageProjectTemplateUsingGET(gaolu_login_luban, pageSize=10000,
                                                                               pageIndex=1)
            actual_value = None
            for data in check_table_resp5.get('source_response')['data']['result']:
                if data['name'] == new_template_node3:
                    actual_value = data['projectTemplateDataTemplateResponseList']
            Assertions.assert_in_value(actual_value, env_conf['用例配置']['工程模板']['dataTemplateItemId2'])
        with allure.step(
                "关联表单模板: {0} 到模板: {1}".format(new_template_node3, env_conf['用例配置']['工程模板']['dataTemplateItemId3'])):
            body3 = {
                "projectTemplateDataTemplates":
                    [{"dataTemplateItemId": dic_temp[env_conf['用例配置']['工程模板']['dataTemplateItemId1']],
                      "type": type_dic['开工报告']},
                     {"dataTemplateItemId": dic_temp[env_conf['用例配置']['工程模板']['dataTemplateItemId2']],
                      "type": type_dic['质量检验(施工)']},
                     {"dataTemplateItemId": dic_temp[env_conf['用例配置']['工程模板']['dataTemplateItemId3']],
                      "type": type_dic['交工评定(施工)']}],
                "projectTemplateId": dict_name_id3[new_template_node3]
            }
            bind_resp = Project_template().bindDataTemplate2ProjectTemplateUsingPOST(gaolu_login_luban, body3)
            waitForStatus(bind_resp, 200, 200, 15)
        with allure.step(
                "关联表单模板: {0} 到模板: {1} 成功".format(new_template_node3, env_conf['用例配置']['工程模板']['dataTemplateItemId3'])):
            check_table_resp5 = Project_template().pageProjectTemplateUsingGET(gaolu_login_luban, pageSize=10000,
                                                                               pageIndex=1)
            actual_value = None
            for data in check_table_resp5.get('source_response')['data']['result']:
                if data['name'] == new_template_node3:
                    actual_value = data['projectTemplateDataTemplateResponseList']
            Assertions.assert_in_value(actual_value, env_conf['用例配置']['工程模板']['dataTemplateItemId3'])
        with allure.step(
                "关联表单模板: {0} 到模板: {1}".format(new_template_node3, env_conf['用例配置']['工程模板']['dataTemplateItemId4'])):
            body4 = {
                "projectTemplateDataTemplates":
                    [{"dataTemplateItemId": dic_temp[env_conf['用例配置']['工程模板']['dataTemplateItemId1']],
                      "type": type_dic['开工报告']},
                     {"dataTemplateItemId": dic_temp[env_conf['用例配置']['工程模板']['dataTemplateItemId2']],
                      "type": type_dic['质量检验(施工)']},
                     {"dataTemplateItemId": dic_temp[env_conf['用例配置']['工程模板']['dataTemplateItemId3']],
                      "type": type_dic['交工评定(施工)']},
                     {"dataTemplateItemId": dic_temp[env_conf['用例配置']['工程模板']['dataTemplateItemId4']],
                      "type": type_dic['质量检验(监理)']}],
                "projectTemplateId": dict_name_id3[new_template_node3]
            }
            bind_resp = Project_template().bindDataTemplate2ProjectTemplateUsingPOST(gaolu_login_luban, body4)
            waitForStatus(bind_resp, 200, 200, 15)
        with allure.step(
                "关联表单模板: {0} 到模板: {1} 成功".format(new_template_node3, env_conf['用例配置']['工程模板']['dataTemplateItemId4'])):
            check_table_resp5 = Project_template().pageProjectTemplateUsingGET(gaolu_login_luban, pageSize=10000,
                                                                               pageIndex=1)
            actual_value = None
            for data in check_table_resp5.get('source_response')['data']['result']:
                if data['name'] == new_template_node3:
                    actual_value = data['projectTemplateDataTemplateResponseList']
            Assertions.assert_in_value(actual_value, env_conf['用例配置']['工程模板']['dataTemplateItemId4'])
        with allure.step(
                "关联表单模板: {0} 到模板: {1}".format(new_template_node3, env_conf['用例配置']['工程模板']['dataTemplateItemId5'])):
            body5 = {
                "projectTemplateDataTemplates":
                    [{"dataTemplateItemId": dic_temp[env_conf['用例配置']['工程模板']['dataTemplateItemId1']],
                      "type": type_dic['开工报告']},
                     {"dataTemplateItemId": dic_temp[env_conf['用例配置']['工程模板']['dataTemplateItemId2']],
                      "type": type_dic['质量检验(施工)']},
                     {"dataTemplateItemId": dic_temp[env_conf['用例配置']['工程模板']['dataTemplateItemId3']],
                      "type": type_dic['交工评定(施工)']},
                     {"dataTemplateItemId": dic_temp[env_conf['用例配置']['工程模板']['dataTemplateItemId4']],
                      "type": type_dic['质量检验(监理)']},
                     {"dataTemplateItemId": dic_temp[env_conf['用例配置']['工程模板']['dataTemplateItemId5']],
                      "type": type_dic['交工评定(监理)']}],
                "projectTemplateId": dict_name_id3[new_template_node3]
            }
            bind_resp = Project_template().bindDataTemplate2ProjectTemplateUsingPOST(gaolu_login_luban, body5)
            waitForStatus(bind_resp, 200, 200, 15)
        with allure.step(
                "关联表单模板: {0} 到模板: {1} 成功".format(new_template_node3, env_conf['用例配置']['工程模板']['dataTemplateItemId5'])):
            check_table_resp5 = Project_template().pageProjectTemplateUsingGET(gaolu_login_luban, pageSize=10000,
                                                                               pageIndex=1)
            actual_value = None
            for data in check_table_resp5.get('source_response')['data']['result']:
                if data['name'] == new_template_node3:
                    actual_value = data['projectTemplateDataTemplateResponseList']
            Assertions.assert_in_value(actual_value, env_conf['用例配置']['工程模板']['dataTemplateItemId5'])
        with allure.step("删除工程划分三级节点"):
            delete_project3 = Project_template().deleteProjectTemplateUsingDELETE(gaolu_login_luban,
                                                                                  dict_name_id3[new_template_node3])
            waitForStatus(delete_project3, 200, 200, 15)
        with allure.step("断言删除工程划分三级节点: {0} 添加成功".format(new_template_node3)):
            check_tree_resp3 = Project_template().pageProjectTemplateUsingGET(gaolu_login_luban, pageSize=10000,
                                                                              pageIndex=1)
            Assertions.assert_not_in_value(check_tree_resp3.get('data_result_name'), new_template_node3)
            allure.attach("断言删除工程划分三级节点: {0} 添加成功".format(new_template_node3))
        with allure.step("删除工程划分二级节点"):
            delete_project2 = Project_template().deleteProjectTemplateUsingDELETE(gaolu_login_luban,
                                                                                  dict_name_id3[new_template_node2])
            waitForStatus(delete_project2, 200, 200, 15)
        with allure.step("断言删除工程划分二级节点: {0} 添加成功".format(new_template_node2)):
            check_tree_resp3 = Project_template().pageProjectTemplateUsingGET(gaolu_login_luban, pageSize=10000,
                                                                              pageIndex=1)
            Assertions.assert_not_in_value(check_tree_resp3.get('data_result_name'), new_template_node2)
            allure.attach("断言删除工程划分二级节点: {0} 添加成功".format(new_template_node2))
        with allure.step("删除工程划分一级节点"):
            delete_project1 = Project_template().deleteProjectTemplateUsingDELETE(gaolu_login_luban,
                                                                                  dict_name_id3[new_template_node1])
            waitForStatus(delete_project1, 200, 200, 15)
        with allure.step("断言删除工程划分一级节点: {0} 添加成功".format(new_template_node1)):
            check_tree_resp3 = Project_template().pageProjectTemplateUsingGET(gaolu_login_luban, pageSize=10000,
                                                                              pageIndex=1)
            Assertions.assert_not_in_value(check_tree_resp3.get('data_result_name'), new_template_node1)
            allure.attach("断言删除工程划分一级节点: {0} 添加成功".format(new_template_node1))
 def test_flow_setting_home_page_deploy(self, gaolu_login,
                                        gaolu_login_luban, env_conf):
     new_flow_mark = 'mark_' + new_flow
     new_flow_1 = "流程1_" + base_utils.generate_random_str()
     new_flow_2 = "流程2_" + base_utils.generate_random_str()
     with allure.step('获取roleName'):
         resp = UserInfo().getUserInfoUsingGET(gaolu_login)
         roleName = resp.get('source_response')['data']['roleName']
         name = resp.get('source_response')['data']['name']
         fullName = resp.get('source_response')['data']['fullName']
         username = resp.get('source_response')['data']['username']
     with allure.step('获取发起人角色信息: {0}'.format(roleName)):
         get_roleName = Roleandrole().findRolesUsingGET(
             gaolu_login_luban, roleName)
         roleIdList = get_roleName.get('data_id')[0]
         Assertions.assert_equal_value(
             get_roleName.get('data_rolename')[0], roleName)
     with allure.step('获取发起人用户信息: {0}'.format(fullName)):
         get_userName = Roleandrole().findUsersUsingGET(gaolu_login_luban)
         userinfo_datas = get_userName.get('source_response')['data']
         userIdList = None
         for data in userinfo_datas:
             if data['truename'] == fullName:
                 userIdList = data['id']
     with allure.step('新建流程: {0}'.format(new_flow)):
         second_id = str(random.randint(1, 4))
         third_id = str(random.randint(5, 9))
         body = {
             "flowChart": {
                 "lineList": [{
                     "id":
                     "1" + "_" + str(random.randint(100, 999)),
                     "nextNodeId":
                     second_id,
                     "prevNodeId":
                     "1"
                 }, {
                     "id":
                     second_id + "_" + str(random.randint(100, 999)),
                     "nextNodeId":
                     third_id,
                     "prevNodeId":
                     second_id
                 }, {
                     "id":
                     third_id + "_" + str(random.randint(100, 999)),
                     "nextNodeId":
                     "endNode",
                     "prevNodeId":
                     third_id
                 }],
                 "nodeList": [{
                     "approvalType": 1,
                     "approverType": 0,
                     "id": "1",
                     "nodeName": "发起人",
                     "nodeType": "TASK_NODE",
                     "roleIdList": [roleIdList],
                     "userIdList": []
                 }, {
                     "approvalType": 1,
                     "approverType": 0,
                     "id": int(second_id),
                     "nodeName": new_flow_1,
                     "nodeType": "TASK_NODE",
                     "signName": 2,
                     "signStamp": 2,
                     "roleIdList": [roleIdList],
                     "userIdList": []
                 }, {
                     "approvalType": 1,
                     "approverType": 1,
                     "id": int(third_id),
                     "nodeName": new_flow_2,
                     "nodeType": "TASK_NODE",
                     "signName": 2,
                     "signStamp": 2,
                     "roleIdList": [],
                     "userIdList": [userIdList]
                 }, {
                     "approvalType": 1,
                     "approverType": 0,
                     "id": "endNode",
                     "nodeName": "结束",
                     "nodeType": "END_NODE",
                     "roleIdList": [],
                     "userIdList": []
                 }]
             },
             "id": "",
             "remark": new_flow_mark,
             "sponsorRoleList": [roleIdList],
             "sponsorType": 1,
             "sponsorUserList": [],
             "typeName": new_flow,
             "module": "INSPECTION"
         }
         post_newCreat = Process_template(
         ).saveOrUpdateProcessTemplateUsingPOST(gaolu_login_luban, body)
         waitForStatus(post_newCreat, 200, 200, 15)
     with allure.step('断言新添加流程: {0} 成功'.format(new_flow)):
         assert_newCreat = Process_template().pageProcessTemplateUsingGET(
             gaolu_login_luban, page_size=10000, page_index=1)
         result_datas = assert_newCreat.get(
             'source_response')['data']['result']
         key_in_listdict(result_datas, new_flow, 'typeName')
         print("\n新建流程: {0} 成功".format(new_flow))
         processTemplateId = None
         for data in result_datas:
             if data['typeName'] == new_flow:
                 processTemplateId = data['key']
     with allure.step('获取表单模板库id'):
         resp_id = Data_template().pageDataTemplateUsingGET(
             gaolu_login_luban, pageSize=50, pageIndex=1)
         dict_form_id = {}
         for data in resp_id.get('source_response')['data']['result']:
             dict_form_id[data['name']] = data['id']
         print("现有表单模板: {0} 成功".format(dict_form_id))
     with allure.step('获取原有关联表单json'):
         list_body = []
         itemId = None
         resp_temp = Data_template().pageDataTemplateItemUsingGET(
             gaolu_login_luban, page_size=10000, page_index=1)
         for data in resp_temp.get('source_response')['data']['result']:
             if data['processTemplateId'] != '':
                 list_body.append({
                     "itemId":
                     data['id'],
                     "processTemplateId":
                     data['processTemplateId']
                 })
             if data['name'] == env_conf['用例配置']['主页']['父表单']:
                 itemId = data['id']
     with allure.step('添加需要关联的表单到原有关联表单json'):
         for data in list_body:
             if data['itemId'] == itemId:
                 list_body.remove(data)
         list_body.append({
             "itemId": itemId,
             "processTemplateId": processTemplateId
         })
     with allure.step('关联流程:{0} 到表单 {1}'.format(
             new_flow, env_conf['用例配置']['主页']['父表单'])):
         templateCode = None
         for data in resp_temp.get('source_response')['data']['result']:
             templateCode = data['templateCode']
         body = {
             "item2formTemplateItemIdList": list_body,
             "templateCode": templateCode
         }
         post_resp = Data_template(
         ).updateDataTemplateItem2ProcessTemplateUsingPOST(
             gaolu_login_luban, body)
         waitForStatus(post_resp, 200, 200, 15)
     with allure.step("断言关联表单成功"):
         resp_result = Data_template().pageDataTemplateItemUsingGET(
             gaolu_login_luban, page_size=10000, page_index=1)
         for data in resp_result.get('source_response')['data']['result']:
             if data['name'] == env_conf['用例配置']['主页']['父表单']:
                 Assertions.assert_equal_value(data['processTemplateId'],
                                               processTemplateId)
         print('关联流程:{0} 到表单: {1} 成功'.format(new_flow,
                                             env_conf['用例配置']['主页']['父表单']))
                 classifier='test_construction'):
    add_sheet_result = {
        "classifier": classifier,
        "projection": "excerpt",
        "projectNodeId": projectNodeId
    }
    group_resp = FormGroup().formGroupsGET(item_fixture, add_sheet_result)
    status = None
    for data in group_resp.get(
            'source_response')['data']['_embedded']['formGroups']:
        if str(data['id']) == formGroup_id:
            status = data['status']
    return status


new_flow = "流程测试" + base_utils.generate_random_str()


@allure.feature("检验评定-新增表单")
class TestInspectionProvisions:
    @allure.story("添加无签名签章审批流程-前置条件")
    @pytest.mark.TestInspectionProvisions
    def test_flow_setting_home_page_deploy(self, gaolu_login,
                                           gaolu_login_luban, env_conf):
        new_flow_mark = 'mark_' + new_flow
        new_flow_1 = "流程1_" + base_utils.generate_random_str()
        new_flow_2 = "流程2_" + base_utils.generate_random_str()
        with allure.step('获取roleName'):
            resp = UserInfo().getUserInfoUsingGET(gaolu_login)
            roleName = resp.get('source_response')['data']['roleName']
            name = resp.get('source_response')['data']['name']
    def test_new_sheet(self, gaolu_login, gaolu_login_luban, env_conf):
        # 新增表单
        with allure.step("查看标段"):
            # section_dict = return_section_dict(gaolu_login, env_conf['用例配置']['增加表单']['section'])
            section_K = return_section_dict(gaolu_login)
            # 获取Kxx 下所有元素
            section_home_arr = return_section_array(
                gaolu_login, section_K, env_conf['用例配置']['增加表单']['section'])
            # 获取3级节点的详细信息
            pid_1 = get_section_home_id(section_home_arr,
                                        env_conf['用例配置']['增加表单']['项目节点'])
            # 获4级节点的详细信息
            pid_2 = get_data(section_home_arr, pid_1,
                             env_conf['用例配置']['增加表单']['文件节点'])
            # 获5级节点的详细信息
            data_temp = get_data(section_home_arr, pid_2['id'],
                                 env_conf['用例配置']['增加表单']['subItem'])
            # 组装为{"name":"id"}
            section_dict = assemble_dict(data_temp)
        with allure.step("获取资料模板条目列表"):
            resp_temp = Data_template().pageDataTemplateItemUsingGET(
                gaolu_login_luban, page_size=10000, page_index=1)
            for data in resp_temp.get('source_response')['data']['result']:
                if data['name'] == env_conf['用例配置']['增加表单']['父表单']:
                    template_id1 = data['formTemplateId']
                    template_db_id1 = data['templateCode']
                elif data['name'] == env_conf['用例配置']['增加表单']['普通表单']:
                    template_id2 = data['formTemplateId']
                    template_db_id2 = data['templateCode']
        with allure.step('添加普通表单'):
            add_sheet_body = {
                "templateId": template_id2,
                "projectNodeId":
                section_dict[env_conf['用例配置']['增加表单']['subItem']],
                "templateDbId": int(template_db_id2),
                "classifier": "report"
            }
            resp_add_normal_sheet = FormGroup().addFormGroupsPOST(
                gaolu_login, add_sheet_body)
            waitForStatus(resp_add_normal_sheet, 200, 200, 15)
            href_formGroup = resp_add_normal_sheet.get(
                'response_header')['Location']
            formGroup_normal_id = href_formGroup.split('/')[-1]
        with allure.step("断言添加普通表单: {0} 成功".format(
                env_conf['用例配置']['增加表单']['普通表单'])):
            add_sheet_result = {
                "classifier": "report",
                "projection": "excerpt",
                "projectNodeId":
                section_dict[env_conf['用例配置']['增加表单']['subItem']]
            }
            normal_group_resp = FormGroup().formGroupsGET(
                gaolu_login, add_sheet_result)
            id_normal_templateName_dict = {}
            for data in normal_group_resp.get(
                    'source_response')['data']['_embedded']['formGroups']:
                id_normal_templateName_dict[str(
                    data['id'])] = data['templateName']
            Assertions.assert_equal_value(
                id_normal_templateName_dict[formGroup_normal_id],
                env_conf['用例配置']['增加表单']['普通表单'])
        # 检验评定添加父表单
        with allure.step('添加父表单'):
            add_parent_sheet_body = {
                "templateId": template_id1,
                "projectNodeId":
                section_dict[env_conf['用例配置']['增加表单']['subItem']],
                "templateDbId": int(template_db_id1),
                "classifier": "report"
            }
            resp_add_parent_sheet = FormGroup().addFormGroupsPOST(
                gaolu_login, add_parent_sheet_body)
            waitForStatus(resp_add_parent_sheet, 200, 200, 15)
            href_formGroup = resp_add_parent_sheet.get(
                'response_header')['Location']
            formGroup_id = href_formGroup.split('/')[-1]
        with allure.step("断言添加父表单: {0} 成功".format(
                env_conf['用例配置']['增加表单']['父表单'])):
            add_sheet_result = {
                "classifier": "report",
                "projection": "excerpt",
                "projectNodeId":
                section_dict[env_conf['用例配置']['增加表单']['subItem']]
            }
            group_resp = FormGroup().formGroupsGET(gaolu_login,
                                                   add_sheet_result)
            id_templateName_dict = {}
            for data in group_resp.get(
                    'source_response')['data']['_embedded']['formGroups']:
                id_templateName_dict[str(data['id'])] = data['templateName']
            Assertions.assert_equal_value(id_templateName_dict[formGroup_id],
                                          env_conf['用例配置']['增加表单']['父表单'])
        with allure.step('添加子表单'):
            body = {
                "classifier": "report",
                "projection": "excerpt",
                "projectNodeId":
                section_dict[env_conf['用例配置']['增加表单']['subItem']]
            }
            formGroup_resp_dict = {}
            formGroup_resp = FormGroup().formGroupsGET(gaolu_login, body)
            for data in formGroup_resp.get(
                    'source_response')['data']['_embedded']['formGroups']:
                formGroup_resp_dict[str(
                    data['id'])] = data['_links']['self']['href']

            sheet_name = "测试表单" + base_utils.generate_random_str()
            sheet_body = {
                "name": sheet_name,
                "toFormInstance": "",
                "formGroup": formGroup_resp_dict[formGroup_id]
            }
            resp_child = FormInstances().formInstancesPOST(
                gaolu_login, sheet_body)
            waitForStatus(resp_child, 200, 200, 15)
            print('添加子表单: {0} 成功'.format(sheet_name))
        # 表单上移
        with allure.step("上移表单"):
            up_down_body = {
                "classifier": "report",
                "projection": "excerpt",
                "projectNodeId":
                section_dict[env_conf['用例配置']['增加表单']['subItem']]
            }
            up_down_resp = FormGroup().formGroupsGET(gaolu_login, up_down_body)

            name_id_dict = {}
            for data in up_down_resp.get(
                    'source_response')['data']['_embedded']['formGroups']:
                name_id_dict[data['templateName']] = data['id']

            id_weight_dict = {}
            for data in up_down_resp.get(
                    'source_response')['data']['_embedded']['formGroups']:
                id_weight_dict[str(data['id'])] = data['weight']

            weight_body_down = {
                "weight":
                id_weight_dict[str(
                    name_id_dict[env_conf['用例配置']['增加表单']['普通表单']])]
            }

            down_form_resp = FormGroup().upDownFormPatch(
                gaolu_login, name_id_dict[env_conf['用例配置']['增加表单']['父表单']],
                weight_body_down)
            waitForStatus(down_form_resp, 200, 200, 15)

            weight_body_up = {
                "weight":
                id_weight_dict[str(
                    name_id_dict[env_conf['用例配置']['增加表单']['父表单']])]
            }
            up_form_resp = FormGroup().upDownFormPatch(
                gaolu_login, name_id_dict[env_conf['用例配置']['增加表单']['普通表单']],
                weight_body_up)
            waitForStatus(up_form_resp, 200, 200, 15)
        with allure.step("断言上移表单成功"):
            up_down_result_body = {
                "classifier": "report",
                "projection": "excerpt",
                "projectNodeId":
                section_dict[env_conf['用例配置']['增加表单']['subItem']]
            }
            up_down_resp = FormGroup().formGroupsGET(gaolu_login,
                                                     up_down_result_body)
            result_weight_dict = {}
            for data in up_down_resp.get(
                    'source_response')['data']['_embedded']['formGroups']:
                result_weight_dict[str(data['id'])] = data['weight']
            Assertions.assert_equal_value(
                result_weight_dict[str(
                    name_id_dict[env_conf['用例配置']['增加表单']['普通表单']])],
                id_weight_dict[str(
                    name_id_dict[env_conf['用例配置']['增加表单']['父表单']])])
        with allure.step("获取资料模板条目列表"):
            resp_temp = Data_template().pageDataTemplateItemUsingGET(
                gaolu_login_luban, page_size=10000, page_index=1)
            for data in resp_temp.get('source_response')['data']['result']:
                if data['name'] == env_conf['用例配置']['增加表单']['应用模板表单']:
                    template_id3 = data['formTemplateId']
                    template_db_id3 = data['templateCode']
        with allure.step("应用模板"):
            add_use_sheet_body = {
                "templateId": template_id3,
                "projectNodeId":
                section_dict[env_conf['用例配置']['增加表单']['subItem']],
                "templateDbId": int(template_db_id3),
                "classifier": "report"
            }
            resp_apply_template = FormGroup().addFormGroupsPOST(
                gaolu_login, add_use_sheet_body)
            waitForStatus(resp_apply_template, 200, 200, 15)
            href_template = resp_apply_template.get(
                'response_header')['Location']
            template_id = href_template.split('/')[-1]
        with allure.step("断言应用模板: {0} 成功".format(
                env_conf['用例配置']['增加表单']['应用模板表单'])):
            add_sheet_result = {
                "classifier": "report",
                "projection": "excerpt",
                "projectNodeId":
                section_dict[env_conf['用例配置']['增加表单']['subItem']]
            }
            up_down_resp = FormGroup().formGroupsGET(gaolu_login,
                                                     add_sheet_result)
            name_id_dict = {}
            for data in up_down_resp.get(
                    'source_response')['data']['_embedded']['formGroups']:
                name_id_dict[data['templateName']] = data['id']
            Assertions.assert_in_key(name_id_dict,
                                     env_conf['用例配置']['增加表单']['应用模板表单'])
        with allure.step("查询可上传的模板"):
            up_body = {"classifier": "report"}
            resp_temp = FormGroup().searchUpTemplatesGET(gaolu_login, up_body)
            up_dict = {}
            for data in resp_temp.get(
                    'source_response')['data']['_embedded']['stashNodes']:
                up_dict[data['name']] = data['id']
        with allure.step('上传模板'):
            up_sheet_result = {
                "classifier": "report",
                "projection": "excerpt",
                "projectNodeId":
                section_dict[env_conf['用例配置']['增加表单']['subItem']]
            }
            up_resp = FormGroup().formGroupsGET(gaolu_login, up_sheet_result)
            body_data = []
            body_params = {"classifier": "report"}
            for data in up_resp.get(
                    'source_response')['data']['_embedded']['formGroups']:
                body_data.append({
                    "templateDbId": data['templateDbId'],
                    "templateId": data['templateId'],
                    "templateName": data['templateName']
                })
            resp = FormGroup().upTemplatesPUT(gaolu_login,
                                              up_dict[new_template_node3],
                                              body_data, body_params)
            waitForStatus(resp, 200, 200, 15)
        # 删除表单
        with allure.step('删除子表单'):
            node = env_conf['用例配置']['增加表单']['subItem']
            body = return_InstanceBody(gaolu_login, section_dict, node,
                                       formGroup_id)
            res = FormInstances().formInstanceSearchGET(gaolu_login, body)
            delete_id = None
            for data in res.get(
                    'source_response')['data']['_embedded']['formInstances']:
                if data['name'] == sheet_name:
                    delete_id = data['id']
            delete_sheet3 = Sort().formInstancesDELETE(gaolu_login, delete_id)
            waitForStatus(delete_sheet3, 200, 200, 15)
        with allure.step('删除父表单'):
            delete_sheet1 = FormGroup().deleteFormGroupsDELETE(
                gaolu_login, formGroup_id)
            waitForStatus(delete_sheet1, 200, 200, 15)
        with allure.step('删除普通表单'):
            delete_sheet2 = FormGroup().deleteFormGroupsDELETE(
                gaolu_login, formGroup_normal_id)
            waitForStatus(delete_sheet2, 200, 200, 15)
        with allure.step('删除应用模板表单'):
            delete_sheet3 = FormGroup().deleteFormGroupsDELETE(
                gaolu_login, template_id)
            waitForStatus(delete_sheet3, 200, 200, 15)
# @TIME    :  2020/12/29
# @Author  :  zhangjingwen
# @File    :  test_add_sheet.py
import pytest, allure
from utils.common import waitForStatus
from utils.common import return_section_array, get_section_home_id, return_section_dict, get_data, assemble_dict
from luban_common.base_assert import Assertions
from luban_common import base_utils
from swagger.api.luban_glxx_user.project_template import Project_template
from swagger.api.luban_glxx_user.data_template import Data_template
from swagger.api.inspection.formInstances import FormInstances
from swagger.api.inspection.sort import Sort
from swagger.api.inspection.form_group import FormGroup
from utils.common import return_InstanceBody

new_template_node1 = "工程划分测试" + base_utils.generate_random_str()
new_template_node2 = "工程划分测试" + base_utils.generate_random_str()
new_template_node3 = "工程划分测试" + base_utils.generate_random_str()


@allure.feature("检验评定-新增表单")
class TestInspectionProvisions:
    @allure.story("添加工程模板划分-前置条件")
    @pytest.mark.TestInspectionProvisions
    def test_add_engineering_template_deploy(self, gaolu_login,
                                             gaolu_login_luban, env_conf):
        # 添加工程模板
        with allure.step("查询工程划分目录"):
            project_tree_resp = Project_template().pageProjectTemplateUsingGET(
                gaolu_login_luban, pageSize=10000, pageIndex=1)
            if project_tree_resp.get('data_totalCount')[0] == 0:
Esempio n. 7
0
 def test_attach_up_download_delete(self, gaolu_login, gaolu_login_luban,
                                    gaolu_login_report, env_conf):
     with allure.step("查看标段"):
         section_K = return_section_dict(gaolu_login)
         # 获取Kxx 下所有元素
         section_home_arr = return_section_array(
             gaolu_login, section_K,
             env_conf['用例配置']['表单审批']['表单附件']['section'])
         # 获取3级节点的详细信息
         pid_1 = get_section_home_id(
             section_home_arr, env_conf['用例配置']['表单审批']['表单附件']['项目节点'])
         # 获4级节点的详细信息
         pid_2 = get_data(section_home_arr, pid_1,
                          env_conf['用例配置']['表单审批']['表单附件']['文件节点'])
         # 获5级节点的详细信息
         data_temp = get_data(section_home_arr, pid_2['id'],
                              env_conf['用例配置']['表单审批']['表单附件']['subItem'])
         # 组装为{"name":"id"}
         section_dict = assemble_dict(data_temp)
     with allure.step("获取资料模板条目列表"):
         resp_temp = Data_template().pageDataTemplateItemUsingGET(
             gaolu_login_luban, page_size=10000, page_index=1)
         for data in resp_temp.get('source_response')['data']['result']:
             if data['name'] == env_conf['用例配置']['表单审批']['表单附件']['父表单']:
                 template_id1 = data['formTemplateId']
                 template_db_id1 = data['templateCode']
     with allure.step('获取roleName'):
         resp = UserInfo().getUserInfoUsingGET(gaolu_login)
         fullName = resp.get('source_response')['data']['fullName']
     with allure.step('获取发起人用户信息: {0}'.format(fullName)):
         get_userName = Roleandrole().findUsersUsingGET(gaolu_login_luban)
         userinfo_datas = get_userName.get('source_response')['data']
         userIdList = None
         for data in userinfo_datas:
             if data['truename'] == fullName:
                 userIdList = data['id']
     # 检验评定添加父表单
     with allure.step('添加父表单: {0}'.format(
             env_conf['用例配置']['表单审批']['表单附件']['父表单'])):
         add_parent_sheet_body = {
             "templateId":
             template_id1,
             "projectNodeId":
             section_dict[env_conf['用例配置']['表单审批']['表单附件']['subItem']],
             "templateDbId":
             int(template_db_id1),
             "classifier":
             "report"
         }
         resp_add_parent_sheet = FormGroup().addFormGroupsPOST(
             gaolu_login, add_parent_sheet_body)
         waitForStatus(resp_add_parent_sheet, 200, 200, 15)
         href_formGroup = resp_add_parent_sheet.get(
             'response_header')['Location']
         formGroup_id = href_formGroup.split('/')[-1]
     with allure.step("断言添加父表单: {0} 成功".format(
             env_conf['用例配置']['表单审批']['表单附件']['父表单'])):
         add_sheet_result = {
             "classifier":
             "report",
             "projection":
             "excerpt",
             "projectNodeId":
             section_dict[env_conf['用例配置']['表单审批']['表单附件']['subItem']]
         }
         group_resp = FormGroup().formGroupsGET(gaolu_login,
                                                add_sheet_result)
         id_templateName_dict = {}
         for data in group_resp.get(
                 'source_response')['data']['_embedded']['formGroups']:
             id_templateName_dict[str(data['id'])] = data['templateName']
         Assertions.assert_equal_value(
             id_templateName_dict[formGroup_id],
             env_conf['用例配置']['表单审批']['表单附件']['父表单'])
     with allure.step('添加子表单'):
         body = {
             "classifier":
             "report",
             "projection":
             "excerpt",
             "projectNodeId":
             section_dict[env_conf['用例配置']['表单审批']['表单附件']['subItem']]
         }
         formGroup_resp_dict = {}
         formGroup_resp = FormGroup().formGroupsGET(gaolu_login, body)
         for data in formGroup_resp.get(
                 'source_response')['data']['_embedded']['formGroups']:
             formGroup_resp_dict[str(
                 data['id'])] = data['_links']['self']['href']
         sheet_name = "测试表单" + base_utils.generate_random_str()
         sheet_body = {
             "name": sheet_name,
             "toFormInstance": "",
             "formGroup": formGroup_resp_dict[formGroup_id]
         }
         resp_child = FormInstances().formInstancesPOST(
             gaolu_login, sheet_body)
         waitForStatus(resp_child, 200, 200, 15)
         print('添加子表单: {0} 成功'.format(sheet_name))
     with allure.step('获取子表单templateId'):
         node = env_conf['用例配置']['表单审批']['表单附件']['subItem']
         body = return_InstanceBody(gaolu_login, section_dict, node,
                                    formGroup_id)
         res = FormInstances().formInstanceSearchGET(gaolu_login, body)
         templateId_ids = {}
         ids = {}
         edit_hrefs = {}
         for data in res.get(
                 'source_response')['data']['_embedded']['formInstances']:
             if data['name'] == sheet_name:
                 templateId_ids[data['name']] = data['templateId']
                 ids[data['name']] = data['id']
                 edit_hrefs[data['name']] = data['_links']['edit']['href']
     with allure.step("获取表单内容"):
         pattern = re.compile(r'[?]id=[A-Za-z0-9]{1,}')
         result = pattern.findall(edit_hrefs[sheet_name])
         edit_id = result[0].split('=')[1]
         ServiceTemplate().rbTemplateGET(gaolu_login_report,
                                         templateId_ids[sheet_name])
         content_resp = ServiceTemplate().rbInstanceGET(
             gaolu_login_report, edit_id)
         body = content_resp.get('source_response')['data']
     with allure.step("获取提交表单id"):
         submit_resp = ServiceTemplate().rbInstancePUT(
             gaolu_login_report, edit_id, body)
         waitForStatus(submit_resp, 200, 200, 15)
         base_utils.file_is_exist(env_conf['用例配置']['表单审批']['表单附件']['文件路径'])
         os.rename(env_conf['用例配置']['表单审批']['表单附件']['文件路径'],
                   "data/" + sheet_name + ".pdf")
         resp = Content().contentGET(gaolu_login, ids[sheet_name])
     with allure.step("提交表单内容"):
         res = Content().contentPOST(
             gaolu_login,
             resp.get('source_response')['data']['id'],
             "data/" + sheet_name + ".pdf", 'application/pdf')
         os.rename("data/" + sheet_name + ".pdf",
                   env_conf['用例配置']['表单审批']['表单附件']['文件路径'])
         waitForStatus(res, 200, 200, 15)
     with allure.step("上传附件png"):
         body = {"source": "upload"}
         res_up = Content().documentsPOST(gaolu_login, body)
         waitForStatus(res_up, 200, 200, 15)
         href_formGroup = res_up.get('response_header')['Location']
         get_id = href_formGroup.split('/')[-1]
         res_id = Content().documentsGET(gaolu_login, get_id)
         href = res_id.get(
             'source_response')['data']['_links']['content']['href']
         up_id = href.split('/')[-1]
         res = Content().contentPOST(
             gaolu_login, up_id, env_conf['用例配置']['表单审批']['表单附件']['图片附件'],
             'image/png')
         waitForStatus(res, 200, 200, 15)
         document_hef = res_id.get(
             'source_response')['data']['_links']['document']['href']
         res_bind = FormInstances().attachmentsPUT(gaolu_login,
                                                   document_hef,
                                                   ids[sheet_name], 'text')
         waitForStatus(res_bind, 200, 200, 15)
     with allure.step('下载附件png'):
         down_resp = Content().downcontentGET(gaolu_login, up_id)
         with open('data/down_png.png', 'wb') as code:
             code.write(down_resp.get('Response_content'))
     with allure.step('删除附件png'):
         delete_bind = FormInstances().attachmentsPUT(
             gaolu_login, '', ids[sheet_name], 'text')
         waitForStatus(delete_bind, 200, 200, 15)
     with allure.step("删除子表单"):
         delete_sheet = Sort().formInstancesDELETE(gaolu_login,
                                                   ids[sheet_name])
         waitForStatus(delete_sheet, 200, 200, 15)
     with allure.step('删除父表单'):
         delete_group_sheet = FormGroup().deleteFormGroupsDELETE(
             gaolu_login, formGroup_id)
         waitForStatus(delete_group_sheet, 200, 200, 15)
Esempio n. 8
0
    def test_approve_batch_form(self, gaolu_login, gaolu_login_luban,
                                gaolu_login_report, env_conf):
        with allure.step("查看标段"):
            section_K = return_section_dict(gaolu_login)
            # 获取Kxx 下所有元素
            section_home_arr = return_section_array(
                gaolu_login, section_K,
                env_conf['用例配置']['表单审批']['批量表单']['section'])
            # 获取3级节点的详细信息
            pid_1 = get_section_home_id(
                section_home_arr, env_conf['用例配置']['表单审批']['批量表单']['项目节点'])
            # 获4级节点的详细信息
            pid_2 = get_data(section_home_arr, pid_1,
                             env_conf['用例配置']['表单审批']['批量表单']['文件节点'])
            # 获5级节点的详细信息
            data_temp = get_data(section_home_arr, pid_2['id'],
                                 env_conf['用例配置']['表单审批']['批量表单']['subItem'])
            # 组装为{"name":"id"}
            section_dict = assemble_dict(data_temp)
        with allure.step("获取资料模板条目列表"):
            resp_temp = Data_template().pageDataTemplateItemUsingGET(
                gaolu_login_luban, page_size=10000, page_index=1)
            for data in resp_temp.get('source_response')['data']['result']:
                if data['name'] == env_conf['用例配置']['表单审批']['批量表单']['父表单']:
                    template_id1 = data['formTemplateId']
                    template_db_id1 = data['templateCode']
        with allure.step('获取roleName'):
            resp = UserInfo().getUserInfoUsingGET(gaolu_login)
            fullName = resp.get('source_response')['data']['fullName']
        with allure.step('获取发起人用户信息: {0}'.format(fullName)):
            get_userName = Roleandrole().findUsersUsingGET(gaolu_login_luban)
            userinfo_datas = get_userName.get('source_response')['data']
            userIdList = None
            for data in userinfo_datas:
                if data['truename'] == fullName:
                    userIdList = data['id']
            # 检验评定添加父表单
        with allure.step('添加父表单: {0}'.format(
                env_conf['用例配置']['表单审批']['批量表单']['父表单'])):
            add_parent_sheet_body = {
                "templateId":
                template_id1,
                "projectNodeId":
                section_dict[env_conf['用例配置']['表单审批']['批量表单']['subItem']],
                "templateDbId":
                int(template_db_id1),
                "classifier":
                "report"
            }
            resp_add_parent_sheet = FormGroup().addFormGroupsPOST(
                gaolu_login, add_parent_sheet_body)
            waitForStatus(resp_add_parent_sheet, 200, 200, 15)
            href_formGroup = resp_add_parent_sheet.get(
                'response_header')['Location']
            formGroup_id = href_formGroup.split('/')[-1]
        with allure.step("断言添加父表单: {0} 成功".format(
                env_conf['用例配置']['表单审批']['批量表单']['父表单'])):
            add_sheet_result = {
                "classifier":
                "report",
                "projection":
                "excerpt",
                "projectNodeId":
                section_dict[env_conf['用例配置']['表单审批']['批量表单']['subItem']]
            }
            group_resp = FormGroup().formGroupsGET(gaolu_login,
                                                   add_sheet_result)
            id_templateName_dict = {}
            for data in group_resp.get(
                    'source_response')['data']['_embedded']['formGroups']:
                id_templateName_dict[str(data['id'])] = data['templateName']
            Assertions.assert_equal_value(
                id_templateName_dict[formGroup_id],
                env_conf['用例配置']['表单审批']['批量表单']['父表单'])
        with allure.step('批量添加子表单'):
            body = {
                "classifier":
                "report",
                "projection":
                "excerpt",
                "projectNodeId":
                section_dict[env_conf['用例配置']['表单审批']['批量表单']['subItem']]
            }
            formGroup_resp_dict = {}
            formGroup_resp = FormGroup().formGroupsGET(gaolu_login, body)
            for data in formGroup_resp.get(
                    'source_response')['data']['_embedded']['formGroups']:
                formGroup_resp_dict[str(
                    data['id'])] = data['_links']['self']['href']

            sheet_name1 = "测试表单" + base_utils.generate_random_str()
            sheet_name2 = "测试表单" + base_utils.generate_random_str()

            sheet_body1 = {
                "name": sheet_name1,
                "toFormInstance": "",
                "formGroup": formGroup_resp_dict[formGroup_id]
            }
            sheet_body2 = {
                "name": sheet_name2,
                "toFormInstance": "",
                "formGroup": formGroup_resp_dict[formGroup_id]
            }
            resp_child1 = FormInstances().formInstancesPOST(
                gaolu_login, sheet_body1)
            waitForStatus(resp_child1, 200, 200, 15)
            print('添加子表单: {0} 成功'.format(sheet_name1))
            resp_child2 = FormInstances().formInstancesPOST(
                gaolu_login, sheet_body2)
            waitForStatus(resp_child2, 200, 200, 15)
            print('添加子表单: {0} 成功'.format(sheet_name2))
        with allure.step('获取子表单templateId'):
            node = env_conf['用例配置']['表单审批']['批量表单']['subItem']
            body = return_InstanceBody(gaolu_login, section_dict, node,
                                       formGroup_id)
            res = FormInstances().formInstanceSearchGET(gaolu_login, body)
            templateId_ids = {}
            ids = {}
            edit_hrefs = {}
            for data in res.get(
                    'source_response')['data']['_embedded']['formInstances']:
                templateId_ids[data['name']] = data['templateId']
                ids[data['name']] = data['id']
                edit_hrefs[data['name']] = data['_links']['edit']['href']
        with allure.step("获取表单内容"):
            pattern = re.compile(r'[?]id=[A-Za-z0-9]{1,}')
            result1 = pattern.findall(edit_hrefs[sheet_name1])
            result2 = pattern.findall(edit_hrefs[sheet_name2])
            edit_id1 = result1[0].split('=')[1]
            edit_id2 = result2[0].split('=')[1]
            ServiceTemplate().rbTemplateGET(gaolu_login_report,
                                            templateId_ids[sheet_name1])
            ServiceTemplate().rbTemplateGET(gaolu_login_report,
                                            templateId_ids[sheet_name2])
            content_resp1 = ServiceTemplate().rbInstanceGET(
                gaolu_login_report, edit_id1)
            content_resp2 = ServiceTemplate().rbInstanceGET(
                gaolu_login_report, edit_id2)
            body1 = content_resp1.get('source_response')['data']
            body2 = content_resp2.get('source_response')['data']
        with allure.step("获取提交表单id1"):
            submit_resp1 = ServiceTemplate().rbInstancePUT(
                gaolu_login_report, edit_id1, body1)
            waitForStatus(submit_resp1, 200, 200, 15)
            base_utils.file_is_exist(env_conf['用例配置']['表单审批']['批量表单']['文件路径'])
            os.rename(env_conf['用例配置']['表单审批']['批量表单']['文件路径'],
                      "data/" + sheet_name1 + ".pdf")
            resp1 = Content().contentGET(gaolu_login, ids[sheet_name1])
        with allure.step("提交表单1内容"):
            res1 = Content().contentPOST(
                gaolu_login,
                resp1.get('source_response')['data']['id'],
                "data/" + sheet_name1 + ".pdf", 'application/pdf')
            waitForStatus(res1, 200, 200, 15)
            os.rename("data/" + sheet_name1 + ".pdf",
                      env_conf['用例配置']['表单审批']['批量表单']['文件路径'])
        with allure.step("获取提交表单id2"):
            submit_resp2 = ServiceTemplate().rbInstancePUT(
                gaolu_login_report, edit_id2, body2)
            waitForStatus(submit_resp2, 200, 200, 15)
            base_utils.file_is_exist(env_conf['用例配置']['表单审批']['批量表单']['文件路径'])
            os.rename(env_conf['用例配置']['表单审批']['批量表单']['文件路径'],
                      "data/" + sheet_name2 + ".pdf")
            resp2 = Content().contentGET(gaolu_login, ids[sheet_name2])
        with allure.step("提交表单2内容"):
            res2 = Content().contentPOST(
                gaolu_login,
                resp2.get('source_response')['data']['id'],
                "data/" + sheet_name2 + ".pdf", 'application/pdf')
            waitForStatus(res2, 200, 200, 15)
            os.rename("data/" + sheet_name2 + ".pdf",
                      env_conf['用例配置']['表单审批']['批量表单']['文件路径'])
        with allure.step("创建委托实例"):
            node = env_conf['用例配置']['表单审批']['批量表单']['subItem']
            body = return_InstanceBody(gaolu_login, section_dict, node,
                                       formGroup_id)
            res = FormInstances().formInstanceSearchGET(gaolu_login, body)
            datas = res.get(
                'source_response')['data']['_embedded']['formInstances']
            id_newDelegate = {}
            for data in datas:
                id_newDelegate[
                    data['name']] = data['_links']['newDelegate']['href']
            pprint.pprint(id_newDelegate)
            formInstances = [
                id_newDelegate[sheet_name1], id_newDelegate[sheet_name2]
            ]
            newDelegate_body = {"formInstances": formInstances}
            resp_create = DelegatesForm().createFormDelegatesPOST(
                gaolu_login, newDelegate_body)
            href_Delegate = resp_create.get('response_header')['Location']
            Delegate_id = href_Delegate.split('/')[-1]
        with allure.step("发起审批"):
            time = datetime.datetime.now().strftime('%Y-%m-%d')
            body = {"deadline": time, "assignee": userIdList}
            start_approve = ApprovalProcess().starApprovePOST(
                gaolu_login, body, ids[sheet_name1])
            waitForStatus(start_approve, 200, 200, 15)
            ApprovalProcess().starApprovePOST(gaolu_login, Delegate_id)
        with allure.step("断言发起审批成功"):
            node = env_conf['用例配置']['表单审批']['批量表单']['subItem']
            result_body = return_InstanceBody(gaolu_login, section_dict, node,
                                              formGroup_id)
            res = FormInstances().formInstanceSearchGET(
                gaolu_login, result_body)
            for data in res.get(
                    'source_response')['data']['_embedded']['formInstances']:
                if data['name'] == sheet_name1:
                    status1 = data['status']
                elif data['name'] == sheet_name2:
                    status2 = data['status']
            Assertions.assert_equal_value(status1, 'PROCESSING')
            Assertions.assert_equal_value(status2, 'PROCESSING')
        with allure.step("审批"):
            body = {
                "deadline": time,
                "comment": "test",
                "assignee": userIdList
            }
            pass_approve = ApprovalProcess().passApprovePOST(
                gaolu_login, body, ids[sheet_name1])
            waitForStatus(pass_approve, 200, 200, 15)
        with allure.step("查询可退回步骤ID"):
            return_step = ApprovalProcess().returnApproveGET(
                gaolu_login, ids[sheet_name1])
            data_arr = return_step.get('source_response')['data']
            for data in data_arr:
                if data['name'] == '发起人':
                    step1 = data['id']
                else:
                    step2 = data['id']
        with allure.step("退回一步"):
            body = {"stepId": step2, "deadline": time, "comment": "pre_step"}
            return_step2 = ApprovalProcess().returnApprovePOST(
                gaolu_login, body, ids[sheet_name1])
            waitForStatus(return_step2, 200, 200, 15)
        with allure.step("断言退回一步成功"):
            node = env_conf['用例配置']['表单审批']['批量表单']['subItem']
            result_body = return_InstanceBody(gaolu_login, section_dict, node,
                                              formGroup_id)
            res = FormInstances().formInstanceSearchGET(
                gaolu_login, result_body)
            for data in res.get(
                    'source_response')['data']['_embedded']['formInstances']:
                if data['name'] == sheet_name1:
                    status1 = data['status']
                    status2 = data['status']
            Assertions.assert_equal_value(status1, 'RETURN')
            Assertions.assert_equal_value(status2, 'RETURN')
        with allure.step("退回到未发起"):
            body = {"stepId": step1, "deadline": time, "comment": "pre"}
            return_step1 = ApprovalProcess().returnApprovePOST(
                gaolu_login, body, ids[sheet_name1])
            waitForStatus(return_step1, 200, 200, 15)
        with allure.step("断言退回到未发起成功"):
            node = env_conf['用例配置']['表单审批']['批量表单']['subItem']
            result_body = return_InstanceBody(gaolu_login, section_dict, node,
                                              formGroup_id)
            res = FormInstances().formInstanceSearchGET(
                gaolu_login, result_body)
            for data in res.get(
                    'source_response')['data']['_embedded']['formInstances']:
                if data['name'] == sheet_name1:
                    status1 = data['status']
                elif data['name'] == sheet_name2:
                    status2 = data['status']
            Assertions.assert_equal_value(status1, 'UNSTART')
            Assertions.assert_equal_value(status2, 'UNSTART')
        with allure.step("删除子表单"):
            delete_sheet1 = Sort().formInstancesDELETE(gaolu_login,
                                                       ids[sheet_name1])
            waitForStatus(delete_sheet1, 200, 200, 15)
            delete_sheet2 = Sort().formInstancesDELETE(gaolu_login,
                                                       ids[sheet_name2])
            waitForStatus(delete_sheet2, 200, 200, 15)
        with allure.step('删除父表单'):
            delete_group_sheet = FormGroup().deleteFormGroupsDELETE(
                gaolu_login, formGroup_id)
            waitForStatus(delete_group_sheet, 200, 200, 15)
Esempio n. 9
0
    def test_advance_form(self, gaolu_login, gaolu_login_luban,
                          gaolu_login_report, env_conf):
        with allure.step("查看标段"):
            section_K = return_section_dict(gaolu_login)
            # 获取Kxx 下所有元素
            section_home_arr = return_section_array(
                gaolu_login, section_K, env_conf['用例配置']['高级表单']['section'])
            # 获取3级节点的详细信息
            pid_1 = get_section_home_id(section_home_arr,
                                        env_conf['用例配置']['高级表单']['项目节点'])
            # 获4级节点的详细信息
            pid_2 = get_data(section_home_arr, pid_1,
                             env_conf['用例配置']['高级表单']['文件节点'])
            # 获5级节点的详细信息
            data_temp = get_data(section_home_arr, pid_2['id'],
                                 env_conf['用例配置']['高级表单']['subItem'])
            # 组装为{"name":"id"}
            section_dict = assemble_dict(data_temp)
        with allure.step("获取资料模板条目列表"):
            resp_temp = Data_template().pageDataTemplateItemUsingGET(
                gaolu_login_luban, page_size=10000, page_index=1)
            for data in resp_temp.get('source_response')['data']['result']:
                if data['name'] == env_conf['用例配置']['高级表单']['父表单']:
                    template_id1 = data['formTemplateId']
                    template_db_id1 = data['templateCode']
        # 检验评定添加父表单
        with allure.step('添加父表单: {0}'.format(env_conf['用例配置']['高级表单']['父表单'])):
            add_parent_sheet_body = {
                "templateId": template_id1,
                "projectNodeId":
                section_dict[env_conf['用例配置']['高级表单']['subItem']],
                "templateDbId": int(template_db_id1),
                "classifier": "report"
            }
            resp_add_parent_sheet = FormGroup().addFormGroupsPOST(
                gaolu_login, add_parent_sheet_body)
            waitForStatus(resp_add_parent_sheet, 200, 200, 15)
            href_formGroup = resp_add_parent_sheet.get(
                'response_header')['Location']
            formGroup_id = href_formGroup.split('/')[-1]
        with allure.step("断言添加父表单: {0} 成功".format(
                env_conf['用例配置']['高级表单']['父表单'])):
            add_sheet_result = {
                "classifier": "report",
                "projection": "excerpt",
                "projectNodeId":
                section_dict[env_conf['用例配置']['高级表单']['subItem']]
            }
            group_resp = FormGroup().formGroupsGET(gaolu_login,
                                                   add_sheet_result)
            id_templateName_dict = {}
            for data in group_resp.get(
                    'source_response')['data']['_embedded']['formGroups']:
                id_templateName_dict[str(data['id'])] = data['templateName']
            Assertions.assert_equal_value(id_templateName_dict[formGroup_id],
                                          env_conf['用例配置']['高级表单']['父表单'])
        with allure.step('添加子表单'):
            body = {
                "classifier": "report",
                "projection": "excerpt",
                "projectNodeId":
                section_dict[env_conf['用例配置']['高级表单']['subItem']]
            }
            formGroup_resp_dict = {}
            formGroup_resp = FormGroup().formGroupsGET(gaolu_login, body)
            for data in formGroup_resp.get(
                    'source_response')['data']['_embedded']['formGroups']:
                formGroup_resp_dict[str(
                    data['id'])] = data['_links']['self']['href']

            sheet_name = "测试表单" + base_utils.generate_random_str()
            sheet_body = {
                "name": sheet_name,
                "toFormInstance": "",
                "formGroup": formGroup_resp_dict[formGroup_id]
            }
            resp_child = FormInstances().formInstancesPOST(
                gaolu_login, sheet_body)
            waitForStatus(resp_child, 200, 200, 15)
            print('添加子表单: {0} 成功'.format(sheet_name))
        with allure.step('获取子表单templateId'):
            node = env_conf['用例配置']['高级表单']['subItem']
            body = return_InstanceBody(gaolu_login, section_dict, node,
                                       formGroup_id)
            res = FormInstances().formInstanceSearchGET(gaolu_login, body)
            templateId_ids = {}
            ids = {}
            edit_hrefs = {}
            for data in res.get(
                    'source_response')['data']['_embedded']['formInstances']:
                templateId_ids[data['name']] = data['templateId']
                ids[data['name']] = data['id']
                edit_hrefs[data['name']] = data['_links']['edit']['href']
        with allure.step("获取表单内容"):
            pattern = re.compile(r'[?]id=[A-Za-z0-9]{1,}')
            result = pattern.findall(edit_hrefs[sheet_name])
            edit_id = result[0].split('=')[1]
            ServiceTemplate().rbTemplateGET(gaolu_login_report,
                                            templateId_ids[sheet_name])
            content_resp = ServiceTemplate().rbInstanceGET(
                gaolu_login_report, edit_id)
            body = content_resp.get('source_response')['data']
        with allure.step("获取提交表单id"):
            submit_resp = ServiceTemplate().rbInstancePUT(
                gaolu_login_report, edit_id, body)
            waitForStatus(submit_resp, 200, 200, 15)
            base_utils.file_is_exist(env_conf['用例配置']['高级表单']['文件路径'])
            os.rename(env_conf['用例配置']['高级表单']['文件路径'],
                      "data/" + sheet_name + ".pdf")
            resp = Content().contentGET(gaolu_login, ids[sheet_name])
        with allure.step("提交表单内容"):
            res = Content().contentPOST(
                gaolu_login,
                resp.get('source_response')['data']['id'],
                "data/" + sheet_name + ".pdf", 'application/pdf')
            os.rename("data/" + sheet_name + ".pdf",
                      env_conf['用例配置']['高级表单']['文件路径'])
            waitForStatus(res, 200, 200, 15)
        with allure.step("删除子表单"):
            delete_sheet3 = Sort().formInstancesDELETE(gaolu_login,
                                                       ids[sheet_name])
            waitForStatus(delete_sheet3, 200, 200, 15)
        with allure.step('删除父表单'):
            delete_sheet1 = FormGroup().deleteFormGroupsDELETE(
                gaolu_login, formGroup_id)
            waitForStatus(delete_sheet1, 200, 200, 15)