class Agencies: headers = HEADERS.headers host_8093 = ReadYaml("default.yaml").get_host("host_8093") read_agencies = ReadYaml("agencies_api.yaml") request = Request() def agency_user_edit_submit(self, data): """评估机构:添加员工""" _URL = self.host_8093 + self.read_agencies.agencies("web", "agencyUserEditSubmit") response = self.request.post_request_data(_url=_URL, _data=data, _headers=self.headers) return response def agency_user_list_data(self, data): """评估机构:查询员工ID""" _URL = self.host_8093 + self.read_agencies.agencies("web", "agencyUserListData") response = self.request.post_request_data(_url=_URL, _data=data, _headers=self.headers) return response def get_tasks(self, data): """【适老化--app】:领取任务""" _URL = self.host_8093 + self.read_agencies.agencies("app", "getTasks") response = self.request.post_request_data(_url=_URL, _data=data, _headers=self.headers) return response def list_own_tasks(self, data): """【适老化--app】:我的任务列表""" _URL = self.host_8093 + self.read_agencies.agencies("app", "listOwnTasks") response = self.request.post_request_data(_url=_URL, _data=data, _headers=self.headers) return response def save_answer(self, data): """"【适老化--app】:上传人员评估结果""" _URL = self.host_8093 + self.read_agencies.agencies("app", "saveAnswer") response = self.request.post_request_data(_url=_URL, _data=data, _headers=self.headers) return response def save_env_answer(self, data): """"【适老化--app】:上传环境评估结果""" _URL = self.host_8093 + self.read_agencies.agencies("app", "saveEnvAnswer") response = self.request.post_request_data(_url=_URL, _data=data, _headers=self.headers) return response def save_person_products(self, data): """【适老化--app】:保存人员评估结果选择的产品关系""" _URL = self.host_8093 + self.read_agencies.agencies("app", "savePersonProducts") response = self.request.post_request_data(_url=_URL, _data=data, _headers=self.headers) return response def download_subject(self, data): _URL = self.host_8093 + self.read_agencies.agencies("app", "downloadSubject") response = self.request.post_request_data(_url=_URL, _data=data, _headers=self.headers) return response
def get_data(): arrs = [] for data in ReadYaml("login.yaml").read_yaml().values(): arrs.append((data.get("username"), data.get("password"), data.get("verify_code"), data.get("expect_info"), data.get("expect_msg"))) return arrs
class TestGovernProduct(unittest.TestCase): house = GovernHouse() govern_account = str(ReadYaml("default.yaml").get_account("govern")) pass_word = ReadYaml("default.yaml").get_password("govern") name = "api产品" + str(random.randint(100, 999)) product_id = [] # 产品ID @ddt.data(*ddt_tool.excel_data()) @Login.govern_login(govern_account, pass_word) def test_1_add_product(self, param): """【适老化】:添加产品""" response = self.house.add_product(param=param[4]) print(response.json()) self.assertEqual(200, response.status_code) self.assertEqual(0, response.json()["status"]) self.assertEqual(param[5], response.json()["message"])
class GovernLogin(BasePage): read_yaml_base = ReadYaml(r'govern_base_element.yaml') def login_info(self, username, password): self.send(selector=self.read_yaml_base.get_element_value("user_name"), value=username) self.send(selector=self.read_yaml_base.get_element_value("pass_word"), value=password) self.click(selector=self.read_yaml_base.get_element_value("login_submit")) def switch_groups(self): self.click(selector=self.read_yaml_base.get_element_value("switch_groups")) time.sleep(1) self.click(selector=self.read_yaml_base.get_element_value("button"))
class GovernYangLao(BasePage): read_yaml = ReadYaml(r'govern_yang_lao_element.yaml') def person_click(self): """进入人员管理""" self.click(selector=self.read_yaml.get_element_value("person")) def add_person_click(self): """点击添加人员按钮""" # self.click(selector=self.read_yaml.get_element_value("left")) sleep(1) self.click(selector=self.read_yaml.get_element_value("queyr")) sleep(1) self.click(selector=self.read_yaml.get_element_value("add_person"))
class TestGovernLogin(unittest.TestCase): warnings.simplefilter("ignore", ResourceWarning) log = Logger() read_yaml = ReadYaml() govern_host = read_yaml.get_default_value("govern", "host") user_name = read_yaml.get_default_value("govern", "account") pass_word = read_yaml.get_default_value("govern", "password") driver = webdriver.Chrome() driver.maximize_window() govern_login = GovernLogin(driver=driver) govern_yang_lao = GovernYangLao(driver=driver) @classmethod def setUpClass(cls): cls.log.info( "---------------------------setUpClass--STA-----------------------------" ) cls.govern_login = GovernLogin(driver=cls.driver) cls.driver.get(cls.govern_host + "/Gover") cls.govern_login.login_info(username=cls.user_name, password=cls.pass_word) def test_01_enter_person(self): self.log.info("--------enter_person-STA-------") self.govern_yang_lao.person_click() self.assertEqual("人员信息", self.driver.title) self.log.info("--------enter_person-END-------") def test_02_add_person(self): self.log.info("--------add_person-STA-------") self.govern_yang_lao.add_person_click() self.log.info("--------add_person-END-------") @classmethod def tearDownClass(cls): # self.driver.quit() cls.log.info( "---------------------------tearDownClass--END-----------------------------" )
class TestHouseFlow(unittest.TestCase): read_yaml = ReadYaml("default.yaml") govern_account = read_yaml.get_account("govern") pass_word = read_yaml.get_password("govern") community = read_yaml.get_district("community") default_pwd = "123456" agency_phone = "1353326" + str(random.randint(1000, 9999)) # 评估机构 登录账号 agency_emp_phone = "1373326" + str(random.randint(1000, 9999)) # 评估员账号 construction_phone = "1363326" + str(random.randint(1000, 9999)) # 施工单位 登录账号 con_emp_account = "1383326" + str(random.randint(1000, 9999)) # 施工员账号 @classmethod def setUpClass(cls): print("============================STA============================") cls.id_card = IDCard().idCard(76, 1) cls.house = GovernHouse() # 适老化政府端 cls.agencies = Agencies() # 评估机构端 cls.construction = Construction() # 施工企业端 cls.agency_name = "api评估机构" + str(random.randint(1000, 9999)) # cls.agency_phone = "1353326" + str(random.randint(1000, 9999)) # 评估机构 登录账号 # cls.agency_emp_phone = "1373326" + str(random.randint(1000, 9999)) # 评估员账号 cls.construction_name = "api施工单位" + str(random.randint(1000, 9999)) # cls.construction_phone = "1363326" + str(random.randint(1000, 9999)) # 施工单位 登录账号 # cls.con_emp_account = "1383326" + str(random.randint(1000, 9999)) # 施工员账号 cls.product_name = "api产品" + str(random.randint(1000, 9999)) cls.person_name = "api申请" + str(random.randint(1000, 9999)) cls.con_emp_name = "api施员工" + str(random.randint(1000, 9999)) cls.agency_id = [] # 评估机构ID cls.construction_id = [] # 施工单位ID cls.product_id = [] # 产品ID cls.apply_id = [] # 改造申请ID cls.verify_id = [] # 改造单ID cls.order_id = [] # 订单ID cls.agency_emp_id = [] # 评估员ID cls.person_record_id = [] # 人员评估记录ID cls.env_record_id = [] # 环境评估记录ID cls.con_emp_id = [] # 施工单位员工ID cls.products = [] # 上传环境评估记录时,上传的产品 cls.scheme = [] # 产品方案 @Login.govern_login(govern_account, pass_word) def test_001_add_assess_agency(self): """1.政府端:添加评估机构""" print("评估机构:" + self.agency_name) param = { "licencesNum": self.agency_phone, "password": "******", "loginPhone": self.agency_phone, "legal": "测试", "contactName": "测试", "serviceArea": self.community, "agencyName": self.agency_name, "contactMobile": "15285256626", "address": "测试", "email": "*****@*****.**", "addExist": "", "licencesImg": "", "agencyCertificate": "", "agencyPhoto": "", "idcardImgZ": "", "idcardImgF": "" } response = self.house.add_assess_agency(case_name="政府端:添加评估机构", param=param) print(response.json()) self.assertEqual(200, response.status_code) self.assertEqual(0, response.json()["status"]) self.assertEqual("评估添加成功", response.json()["message"]) def test_002_get_assessment_agencies(self): """2.政府端:根据评估名称,获取评估机构ID""" param = {"agencyName": self.agency_name, "pageNow": 1} response = self.house.get_assessment_agencies( case_name="政府端:根据评估名称,获取评估机构ID", param=param) print(response.json()) self.assertEqual(200, response.status_code) self.assertEqual(0, response.json()["status"]) self.assertEqual("操作成功", response.json()["message"]) self.agency_id.append( response.json()["data"]["records"][0]["agencyId"]) print("评估机构agency_id:%d" % self.agency_id[0]) def test_003_add_construction_business(self): """3.政府端:添加施工单位""" print(self.construction_phone) param = { "account": self.construction_phone, "address": "办公地址", "annexList": [{ "name": "1", "url": "1.txt" }, { "name": "2", "url": "2.png" }], "businessLicense": self.construction_phone, "certificateList": [{ "name": "1", "url": "1.txt" }, { "name": "2", "url": "2.png" }], "constructorCount": 100, "email": "*****@*****.**", "employeeCount": 30, "enable": 1, "legalPerson": "法人代表", "name": self.construction_name, "password": "******", "personInCharge": "测试", "personPhone": self.construction_phone, "serviceAreaList": [{ 'value': 'shequ', 'id': '5101090201' }] } response = self.house.add_construction_business(case_name="政府端:添加施工单位", param=param) print(response.json()) self.assertEqual(200, response.status_code) self.assertEqual("添加成功", response.json()["message"]) self.assertEqual(0, response.json()["status"]) def test_004_get_construction_business_list(self): """4.政府端:根据施工单位名称,获取施工单位ID""" param = {"name": self.construction_name, "pageNow": 1, "enable": 1} print(self.construction_name) response = self.house.get_construction_business_list( case_name="政府端:根据施工单位名称,获取施工单位ID", param=param) print(response.json()) self.assertEqual(200, response.status_code) self.assertEqual(0, response.json()["status"]) self.assertEqual("操作成功", response.json()["message"]) self.construction_id.append( response.json()["data"]["records"][0]["id"]) print("施工单位construction_ID:%d" % self.construction_id[0]) def test_005_add_product(self): """5.政府端:添加产品""" param = { "name": self.product_name, "functionParams": "功能参数", "price": 1000, "remark": "产品备注", "typeIds": [1, 2, 3, 4, 5, 6, 7, 8], "imgPath": [{ "name": "38acfc8085c249628beffed54bccb2c7", "url": "http://file.chinaylzl.com/test/userHead/2018/11/16/38acfc8085c249628beffed54bccb2c7.png" }, { "name": "38acfc8085c249628beffed54bccb2c7", "url": "http://file.chinaylzl.com/test/userHead/2018/11/16/38acfc8085c249628beffed54bccb2c7.png" }, { "name": "38acfc8085c249628beffed54bccb2c7", "url": "http://file.chinaylzl.com/test/userHead/2018/11/16/38acfc8085c249628beffed54bccb2c7.png" }], } response = self.house.add_product(case_name="政府端:添加产品", param=param) print(response.json()) self.assertEqual(200, response.status_code) self.assertEqual(0, response.json()["status"]) self.assertEqual("添加成功", response.json()["message"]) def test_006_get_product_list(self): """6.政府端:根据产品名称获取产品ID""" param = {"enable": 1, "pageNow": 1, "name": self.product_name} response = self.house.get_product_list(case_name="政府端:根据产品名称获取产品ID", param=param) print(response.json()) self.assertEqual(200, response.status_code) self.assertEqual(0, response.json()["status"]) self.product_id.append(response.json()["data"]["records"][0]["id"]) print("产品product_id:%d" % self.product_id[0]) def test_007_get_user_by_id_card(self): """7.政府端:根据身份证查询人员信息""" param = {"idCard": self.id_card} response = self.house.get_user_by_id_card(case_name="政府端:根据身份证查询人员信息", param=param) print(response.json()) self.assertEqual(200, response.status_code) self.assertEqual(0, response.json()["status"]) self.assertEqual("操作成功", response.json()["message"]) # 政府端:添加改造申请 print("申请人name:" + self.person_name) param = { "idCard": self.id_card, "userName": self.person_name, "phone": "13999999999", "addressId": self.community, "addressDetail": "测试地址", "transformContents": "测试内容", "transformCause": "测试", "state": 4, "emergencyContact": [{ "name": "测试", "ralative": 1, "phone": "13777777777" }], "certificates": [], "annex": [] } response = self.house.add_transform_apply(param) print(response.json()) self.assertEqual(200, response.status_code) self.assertEqual(0, response.json()["status"]) def test_008_get_transform_apply_list(self): """8.政府端:添加改造申请""" param = { "idCard": self.id_card, "addressId": self.community, "pageNow": 1 } response = self.house.get_transform_apply_list(case_name="政府端:添加改造申请", data=param) print(response.json()) self.assertEqual(200, response.status_code) self.assertEqual(0, response.json()["status"]) self.assertEqual("操作成功", response.json()["message"]) self.apply_id.append(response.json()["data"]["records"][0]["id"]) print("改造申请apply_id:%d" % self.apply_id[0]) def test_009_get_transform_verify_list(self): """9.政府端:根据身份证号,查询审核ID""" param = {"idCard": self.id_card, "addressId": self.community} response = self.house.get_transform_apply_list( case_name="政府端:根据身份证号,查询审核ID", data=param) print(response.json()) self.assertEqual(200, response.status_code) self.assertEqual(0, response.json()["status"]) self.assertEqual("操作成功", response.json()["message"]) self.verify_id.append(response.json()["data"]["records"][0]["id"]) print("审核verify_id:%d" % self.verify_id[0]) def test_010_verify_transform(self): """10.政府端:根据审核ID,审核通过""" param = {"id": self.verify_id[0], "verifyState": 1} response = self.house.verify_transform(case_name="政府端:根据审核ID,审核通过", data=param) print(response.json()) self.assertEqual(200, response.status_code) self.assertEqual(0, response.json()["status"]) self.assertEqual("审核成功", response.json()["message"]) def test_011_business_apply(self): """11.政府端:添加改造评估申请""" param = { "agencyId": self.agency_id, "agencyName": self.agency_name, "id": self.verify_id[0] } response = self.house.business_apply(case_name="政府端:添加改造评估申请", data=param) print(response.json()) self.assertEqual(200, response.status_code) self.assertEqual(0, response.json()["status"]) self.assertEqual("申请成功", response.json()["message"]) @Login.agencies_login(agency_phone, default_pwd) def test_012_agency_user_edit_submit(self): """13.评估端:添加员工账号""" param = { "name": "api评估员", "sex": 1, "idCardNum": "510104199008079959", "position": "测试api", "account": self.agency_emp_phone } response = self.agencies.agency_user_edit_submit( case_name="评估端:添加员工账号", data=param) print(response.json()) # 根据账号获取员工ID data = {"account": self.agency_emp_phone} response = self.agencies.agency_user_list_data(data=data) print(response.json()) self.agency_emp_id.append(response.json()["data"][0]["id"]) print("评估员工emp_id: %d" % self.agency_emp_id[0]) @Login.agencies_app_login(agency_emp_phone, default_pwd) def test_013_get_tasks(self): """13.评估app:领取任务""" param = { "orderId": self.verify_id[0], "assessmentUserId": self.agency_emp_id[0] } print(param) response = self.agencies.get_tasks(case_name="评估app:领取任务", data=param) print(response.json()) self.assertEqual(200, response.status_code) self.assertEqual(0, response.json()["status"]) self.assertEqual("领取任务成功", response.json()["detail"]) def test_014_list_own_tasks(self): """14.评估app:获取record_id""" param = {"assessmentUserId": self.agency_emp_id[0]} response = self.agencies.list_own_tasks(case_name="评估app:获取record_id", data=param) print(response.json()) self.assertEqual(200, response.status_code) self.assertEqual(0, response.json()["status"]) self.person_record_id.append( response.json()["data"][0]["personRecordId"]) self.env_record_id.append(response.json()["data"][0]["envRecordId"]) print("人员评估申请记录person_record_id:%d" % self.person_record_id[0]) print("环境评估申请记录env_record_id:%d" % self.env_record_id[0]) def test_015_download_subject(self): """15.评估app:下载题目,获取产品信息""" param = {"schemeId": 104} response = self.agencies.download_subject( case_name="评估app:下载题目,获取产品信息", data=param) print(response.json()) self.assertEqual(200, response.status_code) self.assertEqual(0, response.json()["status"]) print(len(response.json()["data"][0]["productList"])) data = { "productId": response.json()["data"][0]["productList"][0]["productId"], "selectedCounts": 1, "typeId": response.json()["data"][0]["productList"][0]["typeId"], "price": response.json()["data"][0]["productList"][0]["price"] } self.products.append(data) def test_016_save_answer_person(self): """16.评估app:人员评估上传评估结果""" id = self.person_record_id[0] param = { 'name': 'assess_token', 'answer': '[{"answerId":1,"parentId":1,"recordId":%d,"subjectId":8},{"answerId":8,"parentId":1,"recordId":%d,"subjectId":11},{"answerId":10,"parentId":1,"recordId":%d,"subjectId":20},{"answerId":12,"parentId":1,"recordId":%d,"subjectId":21},{"answerId":16,"parentId":1,"recordId":%d,"subjectId":22},{"answerId":18,"parentId":1,"recordId":%d,"subjectId":23},{"answerId":22,"parentId":1,"recordId":%d,"subjectId":24},{"answerId":24,"parentId":1,"recordId":%d,"subjectId":25},{"answerId":31,"parentId":1,"recordId":%d,"subjectId":27},{"answerId":36,"parentId":1,"recordId":%d,"subjectId":28},{"answerId":38,"parentId":2,"recordId":%d,"subjectId":32},{"answerId":41,"parentId":2,"recordId":%d,"subjectId":33},{"answerId":44,"parentId":2,"recordId":%d,"subjectId":34},{"answerId":48,"parentId":3,"recordId":%d,"subjectId":39},{"answerId":52,"parentId":3,"recordId":%d,"subjectId":40},{"answerId":57,"parentId":3,"recordId":%d,"subjectId":41},{"answerId":62,"parentId":3,"recordId":%d,"subjectId":42},{"answerId":66,"parentId":4,"recordId":%d,"subjectId":48},{"answerId":70,"parentId":4,"recordId":%d,"subjectId":49},{"answerId":75,"parentId":4,"recordId":%d,"subjectId":50},{"answerId":80,"parentId":4,"recordId":%d,"subjectId":51},{"answerId":85,"parentId":4,"recordId":%d,"subjectId":52},{"answerId":627,"parentId":391,"recordId":%d,"subjectId":393},{"answerId":628,"parentId":391,"recordId":%d,"subjectId":394},{"answerId":625,"parentId":391,"recordId":%d,"subjectId":395}]' % (id, id, id, id, id, id, id, id, id, id, id, id, id, id, id, id, id, id, id, id, id, id, id, id, id), 'agencyId': self.agency_id[0], "conclusion": "" } response = self.agencies.save_answer(case_name="评估app:人员评估上传评估结果", data=param) print(response.json()) self.assertEqual(200, response.status_code) self.assertEqual(0, response.json()["status"]) def test_017_save_answer_env(self): """17.评估app:环境评估上传评估结果""" id = self.env_record_id[0] param = { 'recordId': id, "answers": '[{"answerId":1129,"parentId":635,"recordId":%d,"subjectId":668},{"answerId":1140,"parentId":635,"recordId":%d,"subjectId":673},{"answerId":1135,"parentId":635,"recordId":%d,"subjectId":671},{"answerId":1124,"parentId":635,"recordId":%d,"subjectId":666},{"answerId":1119,"parentId":635,"recordId":%d,"subjectId":664},{"answerId":1130,"parentId":635,"recordId":%d,"subjectId":669},{"answerId":1141,"parentId":635,"recordId":%d,"subjectId":674},{"answerId":1126,"parentId":635,"recordId":%d,"subjectId":667},{"answerId":1137,"parentId":635,"recordId":%d,"subjectId":672},{"answerId":1121,"parentId":635,"recordId":%d,"subjectId":665},{"answerId":1133,"parentId":635,"recordId":%d,"subjectId":670},{"answerId":1118,"parentId":634,"recordId":%d,"subjectId":652},{"answerId":1113,"parentId":634,"recordId":%d,"subjectId":650},{"answerId":1115,"parentId":634,"recordId":%d,"subjectId":651},{"answerId":1098,"parentId":633,"recordId":%d,"subjectId":642},{"answerId":1105,"parentId":633,"recordId":%d,"subjectId":645},{"answerId":1106,"parentId":633,"recordId":%d,"subjectId":646},{"answerId":1109,"parentId":633,"recordId":%d,"subjectId":644},{"answerId":1156,"parentId":636,"recordId":%d,"subjectId":687},{"answerId":1145,"parentId":636,"recordId":%d,"subjectId":682},{"answerId":1151,"parentId":636,"recordId":%d,"subjectId":685},{"answerId":1157,"parentId":636,"recordId":%d,"subjectId":688},{"answerId":1146,"parentId":636,"recordId":%d,"subjectId":683},{"answerId":1153,"parentId":636,"recordId":%d,"subjectId":686},{"answerId":1149,"parentId":636,"recordId":%d,"subjectId":684},{"answerId":1167,"parentId":637,"recordId":%d,"subjectId":697},{"answerId":1162,"parentId":637,"recordId":%d,"subjectId":695},{"answerId":1169,"parentId":637,"recordId":%d,"subjectId":698},{"answerId":1165,"parentId":637,"recordId":%d,"subjectId":696},{"answerId":1160,"parentId":637,"recordId":%d,"subjectId":694}]' % (id, id, id, id, id, id, id, id, id, id, id, id, id, id, id, id, id, id, id, id, id, id, id, id, id, id, id, id, id, id), "products": str(self.products) } print(param) response = self.agencies.save_env_answer(case_name="评估app:环境评估上传评估结果", data=param) print(response.json()) self.assertEqual(200, response.status_code) self.assertEqual(0, response.json()["status"]) def test_018_save_person_products(self): """18.评估app:保存人员评估结果选择的产品关系""" param = {"recordId": self.person_record_id[0], "json": ""} response = self.agencies.save_person_products( case_name="评估app:保存人员评估结果选择的产品关系", data=param) print(response.json()) self.assertEqual(200, response.status_code) self.assertEqual(0, response.json()["status"]) @Login.govern_login(govern_account, pass_word) def test_019_constructor_apply(self): """19.政府端:施工派单""" param = { "constructionId": self.construction_id[0], "id": self.verify_id[0] } response = self.house.constructor_apply(case_name="政府端:施工派单", data=param) print(response.json()) self.assertEqual(200, response.status_code) self.assertEqual(0, response.json()["status"]) self.assertEqual("派单成功", response.json()["message"]) @Login.construction_login(construction_phone, default_pwd) def test_020_add_employee(self): """20.施工单位添加员工""" param = { "account": self.con_emp_account, "addressDetail": "api测试详细地址", "annex": [{ "name": "1", "url": "1.txt" }, { "name": "2", "url": "2.png" }], "idCard": self.id_card, "name": self.con_emp_name, "password": "******", "phone": self.con_emp_account, "post": 1 } response = self.construction.add_employee(case_name="施工单位添加员工", param=param) print(response.json()) self.assertEqual(200, response.status_code) self.assertEqual(0, response.json()["status"]) self.assertEqual("添加成功", response.json()["message"]) def test_021_employee_list(self): """21.施工单位:获取员工ID""" param = {"name": self.con_emp_name, "pageNow": 1} response = self.construction.employee_list(case_name="施工单位:获取员工ID", param=param) print(response.json()) self.assertEqual(200, response.status_code) self.assertEqual(0, response.json()["status"]) self.assertEqual("操作成功", response.json()["message"]) self.con_emp_id.append(response.json()["data"]["records"][0]["id"]) print("施工员工ID:%s" % self.con_emp_id[0]) @Login.construction_app_login(con_emp_account, default_pwd) def test_022_get_task(self): """22.施工app:获取任务""" param = {"recordId": self.verify_id[0]} print(param) response = self.construction.get_task(case_name="施工app:获取任务D", param=param) print(response.json()) self.assertEqual(200, response.status_code) self.assertEqual(0, response.json()["status"]) self.assertEqual("领取成功", response.json()["message"]) def test_023_construction_details(self): """23.施工app:查询任务详情""" param = {"id": self.verify_id} response = self.construction.construction_details( case_name="施工app:查询任务详情", param=param) print(response.json()) self.scheme.append(response.json()["data"]["transformSchemesType"][0] ["transformSchemes"][0]["id"]) self.scheme.append(response.json()["data"]["transformSchemesType"][0] ["transformSchemes"][0]["productImg"]) def test_024_commit_scheme(self): """24.施工app:提交施工产品方案""" param = { "recordId": self.verify_id, "scheme": str({ "id": self.scheme[0], "transformBefore": self.scheme[1], "transformMiddle": "http://file.chinaylzl.com/test/userHead/2018/11/16/38acfc8085c249628beffed54bccb2c7.png", "transformAfter": "http://file.chinaylzl.com/test/userHead/2018/11/16/38acfc8085c249628beffed54bccb2c7.png", "remark": "api施工小程序产品备注" }) } print(param) response = self.construction.commit_scheme(case_name="施工app:提交施工产品方案", data=param) print(response.json()) @Login.govern_login(govern_account, pass_word) def test_025_govern_get_project_inspection_list(self): """25.政府端:项目验收列表分页查询""" param = {"pageNow": 1} response = self.house.get_project_inspection_list( case_name="政府端:项目验收列表分页查询", data=param) print(response.json()) self.assertEqual(200, response.status_code) self.assertEqual(0, response.json()["status"]) self.assertEqual("操作成功", response.json()["message"]) def test_026_govern_check_transform_scheme(self): """26.政府端:验收改造方案""" param = { "schemeId": self.scheme[0], "recordId": self.verify_id, "qualified": 1 } response = self.house.check_transform_scheme(case_name="政府端:验收改造方案", data=param) print(response.json()) self.assertEqual(200, response.status_code) self.assertEqual(0, response.json()["status"]) self.assertEqual("验收成功", response.json()["message"]) def test_027_get_transform_settlement_list(self): """27.政府端:项目结算列表分页查询""" param = {"pageNow": 1} response = self.house.get_transform_settlement_list( case_name="政府端:项目结算列表分页查询", data=param) print(response.json()) self.assertEqual(200, response.status_code) self.assertEqual(0, response.json()["status"]) self.assertEqual("操作成功", response.json()["message"]) def test_028_settlement(self): """28.政府端:结算项目""" param = {"id": self.verify_id} response = self.house.settlement(case_name="政府端:结算项目", data=param) print(response.json()) self.assertEqual(200, response.status_code) self.assertEqual(0, response.json()["status"]) self.assertEqual("结算成功", response.json()["message"]) def test_029_info(self): print("评估机构名称:%s ;账号: %s ;ID:%d" % (self.agency_name, self.agency_phone, self.agency_id[0])) print("施工单位名称:%s ;账号: %s ;ID:%d" % (self.construction_name, self.construction_phone, self.construction_id[0])) print("产品名称:%s ;ID:%d" % (self.product_name, self.product_id[0])) print("人员名称:%s ;id_card: %s ;ID:%d" % (self.person_name, self.id_card, self.apply_id[0])) print("改造申请ID:%s ;改造审核ID: %s " % (self.apply_id[0], self.verify_id[0])) print("评估员账号:%s ;ID: %s " % (self.agency_emp_phone, self.agency_emp_id[0])) print("人员记录person_record_id:%d ; 环境记录env_record_id:%d" % (self.person_record_id[0], self.env_record_id[0])) @classmethod def tearDownClass(cls): print("============================END============================")
class Construction: request = Request() headers = HEADERS.headers read_default = ReadYaml("default.yaml") host_8094 = read_default.get_host("host_8094") house = ReadYaml("house_api.yaml") def add_employee(self, param): """【施工web:添加员工】""" _URL = self.host_8094 + self.house.house_constructor( "web", "addEmployee") response = self.request.post_request_json(_url=_URL, _json=param, _headers=self.headers) return response def update_employee(self, param): """【施工web:添加员工】""" _URL = self.host_8094 + self.house.house_constructor( "web", "updateEmployee") response = self.request.post_request_json(_url=_URL, _json=param, _headers=self.headers) return response def employee_list(self, param): """【施工web:查询列表】""" _URL = self.host_8094 + self.house.house_constructor( "web", "employeeList") response = self.request.get_request(_url=_URL, _data=param, _headers=self.headers) return response def get_task(self, param): """【施工app:领取任务】""" _URL = self.host_8094 + self.house.house_constructor("app", "getTask") response = self.request.post_request_data(_url=_URL, _data=param, _headers=self.headers) return response def get_transform_scheme_detail(self, param): """【施工app: 查看改造方案详情】""" _URL = self.host_8094 + self.house.house_constructor( "app", "getTransFormSchemeDetail") response = self.request.get_request(_url=_URL, _data=param, _headers=self.headers) return response def my_task_list(self, param): """【施工app:我的任务列表】""" _URL = self.host_8094 + self.house.house_constructor( "app", "myTaskList") response = self.request.get_request(_url=_URL, _data=param, _headers=self.headers) return response def construction_details(self, param): """【施工app:查询任务详情】""" _URL = self.host_8094 + self.house.house_constructor( "app", "constructionDetails") response = self.request.get_request(_url=_URL, _data=param, _headers=self.headers) return response def commit_scheme(self, data): """【施工app:提交施工产品方案】""" _URL = self.host_8094 + self.house.house_constructor( "app", "commitScheme") response = self.request.post_request_data(_url=_URL, _data=data, _headers=self.headers) return response def complete_scheme(self, data): """"【施工app:施工完成】""" _URL = self.host_8094 + self.house.house_constructor( "app", "commitScheme") response = self.request.post_request_data(_url=_URL, _data=data, _headers=self.headers) return response def complete_task_list(self, data): """"【施工app:已完成列表】""" _URL = self.host_8094 + self.house.house_constructor( "app", "completeTaskList") response = self.request.get_request(_url=_URL, _data=data, _headers=self.headers) return response
""" @version: 1.0 @author: chenj @file: Login_s.py @time: 2019/6/13 13:32 @desc: """ from conf import HEADERS from tools.read_yaml import ReadYaml from tools.http_request import Request headers = HEADERS.headers request = Request() read_yaml = ReadYaml("default.yaml") govern_host = read_yaml.get_host("govern") # 政府端 business = read_yaml.get_host("business") # 企业端 agencies = read_yaml.get_host("host_8093") # 评估端 host_8094 = read_yaml.get_host("host_8094") # 施工端 cater = read_yaml.get_host("agencies") # 配餐企业端 def construction_app_login(account, password): """施工app登录""" def login(func): def inner(*args): print( "=========================== 【施工web】登录账号:%s ===========================" % account) _URL = host_8094 + "/app/login"
class GovernHouse: request = Request() headers = HEADERS.headers read_default = ReadYaml("default.yaml") govern = read_default.get_host("govern") + "/gov-house" # govern = "http://192.168.100.151:8084" house = ReadYaml("house_api.yaml") # 【产品】 def add_product(self, param): """【政府端--适老化】:添加产品""" print(param) _URL = self.govern + self.house.house_govern("product", "addProduct") print(_URL) response = self.request.post_request_json(_url=_URL, _json=param, _headers=self.headers) return response def get_product_list(self, param): """【政府端--适老化】:分页查询产品列表""" _URL = self.govern + self.house.house_govern("product", "getProductList") response = self.request.get_request(_url=_URL, _data=param, _headers=self.headers) return response def get_product_type_list(self): """【政府端--适老化】:查询产品类型list""" _URL = self.govern + self.house.house_govern("product", "getProductTypeList") response = self.request.get_request(_url=_URL, _headers=self.headers) return response def stop_start_product(self, param): """【政府端--适老化】:产品停启""" _URL = self.govern + self.house.house_govern("product", "stopStartProduct") response = self.request.get_request(_url=_URL, _data=param, _headers=self.headers) return response def update_product(self, param): """【政府端--适老化】:编辑产品信息""" _URL = self.govern + self.house.house_govern("product", "updateProduct") response = self.request.post_request_json(_url=_URL, _json=param, _headers=self.headers) return response def get_unit_data(self): """【政府端--适老化】:获取单位数据""" _URL = self.govern + self.house.house_govern("product", "getUnitData") response = self.request.get_request(_url=_URL, _headers=self.headers) return response def get_product_detail(self, param): """【政府端--适老化】:查看产品详情""" _URL = self.govern + self.house.house_govern("product", "getProductDetail") response = self.request.get_request(_url=_URL, _data=param, _headers=self.headers) return response # 【施工单位】 def add_construction_business(self, param): """【政府端--适老化】:添加施工单位""" _URL = self.govern + self.house.house_govern( "construction", "addConstructionBusiness") response = self.request.post_request_json(_url=_URL, _json=param, _headers=self.headers) return response def get_construction_business_list(self, param): """【政府端--适老化】:分页查询施工单位列表""" _URL = self.govern + self.house.house_govern( "construction", "getConstructionBusinessList") response = self.request.get_request(_url=_URL, _data=param, _headers=self.headers) return response def edit_construction_business(self, param): """【政府端--适老化】:编辑施工单位信息""" _URL = self.govern + self.house.house_govern( "construction", "editConstructionBusiness") response = self.request.post_request_json(_url=_URL, _json=param, _headers=self.headers) return response def get_business_detail(self, param): """【政府端--适老化】:获取施工单位信息""" _URL = self.govern + self.house.house_govern("construction", "getBusinessDetail") response = self.request.get_request(_url=_URL, _data=param, _headers=self.headers) return response def record_construction_list(self, param): """【政府端--适老化】:施工记录""" _URL = self.govern + self.house.house_govern("construction", "recordConstructionList") response = self.request.get_request(_url=_URL, _data=param, _headers=self.headers) return response def get_employee_list(self, param): """【政府端--适老化】:通讯名单""" _URL = self.govern + self.house.house_govern("construction", "getEmployeeList") response = self.request.get_request(_url=_URL, _data=param, _headers=self.headers) return response def stop_or_start_constructor(self, param): """【政府端--适老化】:停启施工单位""" _URL = self.govern + self.house.house_govern("construction", "stopOrStartConstructor") response = self.request.get_request(_url=_URL, _data=param, _headers=self.headers) return response def services_list(self, param): """【政府端--适老化】:结算服务""" _URL = self.govern + self.house.house_govern("construction", "servicesList") response = self.request.get_request(_url=_URL, _data=param, _headers=self.headers) return response # 【评估机构】 def add_assess_agency(self, param): """【政府端--评估机构】:添加评估机构""" _URL = self.govern + self.house.house_govern("agency", "addAssessAgency") response = self.request.post_request_json(_url=_URL, _json=param, _headers=self.headers) return response def assessment_record(self, param): """【政府端--评估机构】:机构评估记录""" _URL = self.govern + self.house.house_govern("agency", "assessmentRecord") response = self.request.get_request(_url=_URL, _data=param, _headers=self.headers) return response def edit_assess_agency(self, param): """【政府端--评估机构】:编辑获取评估机构信息""" _URL = self.govern + self.house.house_govern("agency", "editAssessAgencys") response = self.request.post_request_json(_url=_URL, _json=param, _headers=self.headers) return response def get_agency_detail(self, param): """【政府端--评估机构】:获取评估机构基本信息""" _URL = self.govern + self.house.house_govern("agency", "getAgencyDetail") response = self.request.get_request(_url=_URL, _data=param, _headers=self.headers) return response def get_agency_employee_list(self, param): """【政府端--评估机构】:通讯名单列表""" _URL = self.govern + self.house.house_govern("agency", "getEmployeeList") response = self.request.get_request(_url=_URL, _data=param, _headers=self.headers) return response def get_assessment_agencies(self, param): """【政府端--评估机构】:分页查询评估机构列表""" _URL = self.govern + self.house.house_govern("agency", "getAssessmentAgencies") response = self.request.get_request(_url=_URL, _data=param, _headers=self.headers) return response def get_assessment_scheme(self, param): """【政府端--评估机构】:查询方案列表""" _URL = self.govern + self.house.house_govern("agency", "getAssessmentScheme") response = self.request.get_request(_url=_URL, _data=param, _headers=self.headers) return response def get_settle_service(self, param): """【政府端--评估机构】:结算服务列表""" _URL = self.govern + self.house.house_govern("agency", "getSettleService") response = self.request.get_request(_url=_URL, _data=param, _headers=self.headers) return response def query_agencies_list(self): """【政府端--评估机构】:获取选择评估机构列表""" _URL = self.govern + self.house.house_govern("agency", "queryAgenciesList") response = self.request.get_request(_url=_URL, _headers=self.headers) return response def save_assessment_agency(self, param): """【政府端--评估机构】:保存编辑后评估机构信息""" _URL = self.govern + self.house.house_govern("agency", "saveAssessmentAgency") response = self.request.post_request_json(_url=_URL, _json=param, _headers=self.headers) return response def settle_agency(self, param): """【政府端--评估机构】:结算服务列表""" _URL = self.govern + self.house.house_govern("agency", "settleAgency") response = self.request.get_request(_url=_URL, _data=param, _headers=self.headers) return response def start_or_stop(self, param): """【政府端--评估机构】:机构评估停启用""" _URL = self.govern + self.house.house_govern("agency", "startOrStop") response = self.request.get_request(_url=_URL, _data=param, _headers=self.headers) return response # 【申请】 def get_user_by_id_card(self, param): """【政府端 - -适老化】:根据身份证查询人员信息""" _URL = self.govern + self.house.house_govern("apply", "getUserByIdCard") response = self.request.get_request(_url=_URL, _data=param, _headers=self.headers) return response def add_transform_apply(self, param): """【政府端--适老化】:添加改造申请""" _URL = self.govern + self.house.house_govern("apply", "addTransformApply") response = self.request.post_request_json(_url=_URL, _json=param, _headers=self.headers) return response def apply_transform(self, data): """【政府端--适老化】:改造申请""" _URL = self.govern + self.house.house_govern("apply", "applyTransform") response = self.request.get_request(_url=_URL, _data=data, _headers=self.headers) return response def edit_transform(self, json): """【政府端--适老化】:编辑改造单""" _URL = self.govern + self.house.house_govern("apply", "editTransform") response = self.request.post_request_json(_url=_URL, _json=json, _headers=self.headers) return response def get_relation_data(self): """【政府端--适老化】:获取人员关系数据""" _URL = self.govern + self.house.house_govern("apply", "getRelationData") response = self.request.get_request(_url=_URL, _headers=self.headers) return response def get_transform_apply_list(self, data): """【政府端--适老化】:分页查询改造申请列表""" _URL = self.govern + self.house.house_govern("apply", "getTransformApplyList") response = self.request.get_request(_url=_URL, _data=data, _headers=self.headers) return response def get_transform_detail(self, data): """【政府端--适老化】:获取改造单详情""" _URL = self.govern + self.house.house_govern("apply", "getTransformDetail") response = self.request.get_request(_url=_URL, _data=data, _headers=self.headers) return response # 【改造审核】 def get_transform_verify_list(self, data): """【政府端--适老化】:分页查询改造审核列表""" _URL = self.govern + self.house.house_govern("verify", "getTransformVerifyList") response = self.request.get_request(_url=_URL, _data=data, _headers=self.headers) return response def verify_transform(self, data): """【政府端--适老化】:审核改造单""" _URL = self.govern + self.house.house_govern("verify", "verifyTransform") response = self.request.get_request(_url=_URL, _data=data, _headers=self.headers) return response # 【改造评估】 def business_apply(self, data): """【政府端--适老化】:申请评估机构""" _URL = self.govern + self.house.house_govern("assessment", "businessApply") response = self.request.get_request(_url=_URL, _data=data, _headers=self.headers) return response def cancel_assessment(self, data): """【政府端--适老化】:取消待评估改造""" _URL = self.govern + self.house.house_govern("assessment", "cancelAssessment") response = self.request.get_request(_url=_URL, _data=data, _headers=self.headers) return response def get_assess_apply_list(self, data): """"【政府端--适老化】:评估申请列表分页查询""" _URL = self.govern + self.house.house_govern("assessment", "getAssessApplyList") response = self.request.get_request(_url=_URL, _data=data, _headers=self.headers) return response def get_assessment_list(self, data): """【政府端--适老化】:评估中列表分页查询""" _URL = self.govern + self.house.house_govern("assessment", "getAssessmentList") response = self.request.get_request(_url=_URL, _data=data, _headers=self.headers) return response def get_construction_list(self): """【政府端--适老化】:选择施工单位列表""" _URL = self.govern + self.house.house_govern("assessment", "getConstructionList") response = self.request.get_request(_url=_URL, _headers=self.headers) return response # 【改造施工】 def constructor_apply(self, data): """【政府端--适老化】:派单施工方""" _URL = self.govern + self.house.house_govern("assessment", "constructorApply") response = self.request.get_request(_url=_URL, _data=data, _headers=self.headers) return response # 【项目验收】 def get_project_inspection_list(self, data): """【政府端--适老化】:项目验收列表分页查询""" _URL = self.govern + self.house.house_govern( "project", "getProjectInspectionList") response = self.request.get_request(_url=_URL, _data=data, _headers=self.headers) return response def check_transform_scheme(self, data): """【政府端--适老化】:验收改造方案""" _URL = self.govern + self.house.house_govern("project", "checkTransformScheme") response = self.request.get_request(_url=_URL, _data=data, _headers=self.headers) return response def get_transform_settlement_list(self, data): """【政府端--适老化】:项目结算列表分页查询""" _URL = self.govern + self.house.house_govern( "project", "getTransformSettlementList") response = self.request.get_request(_url=_URL, _data=data, _headers=self.headers) return response def settlement(self, data): """【政府端--适老化】:结算项目""" _URL = self.govern + self.house.house_govern("project", "settlement") response = self.request.get_request(_url=_URL, _data=data, _headers=self.headers) return response
# -*- coding: utf-8 -*- from selenium import webdriver from tools.logger import Logger from tools.read_yaml import ReadYaml yaml = ReadYaml() logger = Logger(logger='Browser').getlog() class Browser(object): def open_browser(self): ''' 设置浏览器属性 :return: 返回浏览器实例 ''' cfg = yaml.read_yaml() if cfg['browser']['type'] == 'chrome': options = webdriver.ChromeOptions() # options.add_argument('headless') # 浏览器不提供可视化页面. linux下如果系统不支持可视化不加这条会启动失败 options.add_argument('start-maximized') # 最大化浏览器 options.add_argument('disable-infobars') # 去除浏览器黄条警告 options.add_argument('disable-extensions') # 禁用浏览器扩展 options.add_argument('disable-popup-blocking') # 禁止弹出拦截信息 options.add_argument('disable-gpu') # 规避chrome浏览器bug browser = webdriver.Chrome(options=options) logger.info('启动Chrome浏览器') elif cfg['browser']['type'] == 'ie': browser = webdriver.Ie() elif cfg['browser']['type'] == 'firefox': browser = webdriver.Firefox() else:
class TestGovernAgencies(unittest.TestCase): house = GovernHouse() govern_account = str(ReadYaml("default.yaml").get_account("govern")) pass_word = ReadYaml("default.yaml").get_password("govern") agencyId = [] agencyName = "api评估机构" + str(random.randint(10, 99)) @Login.govern_login(govern_account, pass_word) def test_001_add_assess_agency(self): """【政府端-适老化-评估机构】:添加评估机构""" param = { "licencesNum": str(random.randint(100000, 99999999)), "password": "******", "loginPhone": "152852566" + str(random.randint(10, 99)), "legal": "测试", "contactName": "测试", "serviceArea": "51010906", "agencyName": self.agencyName, "contactMobile": "15285256626", "address": "测试", "email": "*****@*****.**", "addExist": "", "licencesImg": "", "agencyCertificate": "", "agencyPhoto": "", "idcardImgZ": "", "idcardImgF": "" } response = self.house.add_assess_agency(case_name="适老化:添加评估机构", param=param) print(response.json()) self.assertEqual(200, response.status_code) self.assertEqual(0, response.json()["status"]) self.assertEqual("评估添加成功", response.json()["message"]) def test_002_get_assessment_agencies(self): """【政府端--评估机构】:分页查询评估机构列表""" param = { "agencyName": self.agencyName, "pageNow": 1 } response = self.house.get_assessment_agencies(case_name="分页查询评估机构列表", param=param) print(response.json()) self.assertEqual(200, response.status_code) self.assertEqual(0, response.json()["status"]) self.assertEqual("操作成功", response.json()["message"]) self.agencyId.append(response.json()["data"]["records"][0]["agencyId"]) print(self.agencyId[0]) def test_003_save_assessment_agency(self): """【政府端--评估机构】:编辑获取评估机构信息""" param = { "agencyId": self.agencyId[0], "password": "******", "legal": "测试(update)", "contactName": "测试(update)", "serviceArea": "51010906", "agencyName": self.agencyName + "(update)", "contactMobile": "15285256626", "address": "测试(update)", "email": "*****@*****.**", "addExist": 0, "licencesImg": "https://file.chinaylzl.com/test/house/gover/img/2019/06/05/" "timg_884ce9dd38e848129cf7c86e914f4bdd.gif", "agencyCertificate": "https://file.chinaylzl.com/test/house/gover/img/2019/06/05/" "timg_884ce9dd38e848129cf7c86e914f4bdd.gif", "agencyPhoto": "https://file.chinaylzl.com/test/house/gover/img/2019/06/05/" "timg_884ce9dd38e848129cf7c86e914f4bdd.gif", "idcardImgZ": "https://file.chinaylzl.com/test/house/gover/img/2019/06/05/" "timg_884ce9dd38e848129cf7c86e914f4bdd.gif", "idcardImgF": "https://file.chinaylzl.com/test/house/gover/img/2019/06/05/" "timg_884ce9dd38e848129cf7c86e914f4bdd.gif" } print(param) response = self.house.save_assessment_agency(case_name="编辑获取评估机构信息", param=param) print(response.json()) self.assertEqual(200, response.status_code) self.assertEqual(0, response.json()["status"]) self.assertEqual("评估保存成功", response.json()["message"]) def test_query_agencies_list(self): """【政府端--评估机构】:获取选择评估机构列表""" response = self.house.query_agencies_list(case_name="获取选择评估机构列表") print(response.json()) self.assertEqual(200, response.status_code) self.assertEqual(0, response.json()["status"])
class Agencies(unittest.TestCase): construction = Construction() house = GovernHouse() govern_account = str(ReadYaml("default.yaml").get_account("govern")) pass_word = ReadYaml("default.yaml").get_password("govern") id_card = IDCard().idCard(75, 2) con_emp_id = [] con_emp_account = "1525621" + str(random.randint(1000, 9999)) con_emp_name = "api施员工" + str(random.randint(1000, 9999)) scheme = [] @Login.construction_login("13633262703", "123456") def test_add_employee(self): """【施工web:添加员工】""" print(self.con_emp_name) param = { "account": self.con_emp_account, "addressDetail": "api测试详细地址", "annex": "apiannex", "bid": 99, "idCard": self.id_card, "name": self.con_emp_name, "password": "******", "phone": self.con_emp_account, "post": 1 } response = self.construction.add_employee(case_name="添加员工", param=param) print(response.json()) self.assertEqual(200, response.status_code) self.assertEqual(0, response.json()["status"]) self.assertEqual("添加成功", response.json()["message"]) def test_employee_list(self): """施工单位:查询员工列表""" param = {"name": self.con_emp_name, "pageNow": 1} response = self.construction.employee_list(case_name="查询员工列表", param=param) print(response.json()) self.assertEqual(200, response.status_code) self.assertEqual(0, response.json()["status"]) self.assertEqual("操作成功", response.json()["message"]) print(len(response.json()["data"]["records"])) self.con_emp_id.append(response.json()["data"]["records"][0]["id"]) print(self.con_emp_id[0]) @Login.construction_app_login("13633269651", "123456") def test_get_task(self): """施工app:获取任务""" param = { # self.con_emp_id[0], "recordId": 63 } response = self.construction.get_task(case_name="获取任务", param=param) print(response.json()) self.assertEqual(200, response.status_code) self.assertEqual(0, response.json()["status"]) self.assertEqual("领取成功", response.json()["message"]) def test_my_task_list(self): """【施工app:我的任务列表】""" param = {"pageNow": 1} response = self.construction.my_task_list(case_name="我的任务列表", param=param) print(response.json()) self.assertEqual(200, response.status_code) self.assertEqual(0, response.json()["status"]) self.assertEqual("操作成功", response.json()["message"]) def test_construction_details(self): """【施工app:查询任务详情】""" param = {"id": 91} response = self.construction.construction_details(case_name="查询任务详情", param=param) print(response.json()) self.scheme.append(response.json()["data"]["transformSchemesType"][0] ["transformSchemes"][0]["id"]) self.scheme.append(response.json()["data"]["transformSchemesType"][0] ["transformSchemes"][0]["productImg"]) def test_commit_scheme(self): """【施工app:提交施工产品方案】""" param = { "recordId": 91, "scheme": str({ "id": self.scheme[0], "transformBefore": self.scheme[1], "transformMiddle": "http://file.chinaylzl.com/test/userHead/2018/11/16/38acfc8085c249628beffed54bccb2c7.png", "transformAfter": "http://file.chinaylzl.com/test/userHead/2018/11/16/38acfc8085c249628beffed54bccb2c7.png", "remark": "api施工小程序产品备注" }) } print(param) response = self.construction.commit_scheme(case_name="提交施工产品方案", data=param) print(response.json()) @Login.govern_login(govern_account, pass_word) def test_03_govern_get_project_inspection_list(self): """【政府端--适老化】:项目验收列表分页查询""" param = {"pageNow": 1} response = self.house.get_project_inspection_list( case_name="项目验收列表分页查询", data=param) print(response.json()) self.assertEqual(200, response.status_code) self.assertEqual(0, response.json()["status"]) self.assertEqual("操作成功", response.json()["message"]) def test_04_govern_check_transform_scheme(self): """【政府端--适老化】:验收改造方案""" param = {"schemeId": 83, "recordId": 91, "qualified": 1} response = self.house.check_transform_scheme(case_name="验收改造方案", data=param) print(response.json()) self.assertEqual(200, response.status_code) self.assertEqual(0, response.json()["status"]) self.assertEqual("验收成功", response.json()["message"]) def test_05_get_transform_settlement_list(self): """项目结算""" param = {"pageNow": 1} response = self.house.get_transform_settlement_list(case_name="项目结算", data=param) print(response.json()) def test_06_settlement(self): """【政府端--适老化】:结算项目""" param = {"id": 91} response = self.house.settlement(case_name="适老化:结算项目", data=param) print(response.json())
class TestGovernApply(unittest.TestCase): house = GovernHouse() govern_account = str(ReadYaml("default.yaml").get_account("govern")) pass_word = ReadYaml("default.yaml").get_password("govern") id_card = IDCard().idCard(85, 1) name = "张三" + str(random.randint(0, 100)) apply_id = [] # 申请ID v_id = [] # 改造单ID @Login.govern_login(govern_account, pass_word) def test_001_get_user_by_id_card(self): """【政府端 - -适老化】:根据身份证查询人员信息""" param = {"idCard": self.id_card} response = self.house.get_user_by_id_card(case_name="根据身份证查询人员信息", param=param) print(response.json()) self.assertEqual(200, response.status_code) self.assertEqual(0, response.json()["status"]) self.assertEqual("操作成功", response.json()["message"]) @Login.govern_login("13999999995", pass_word) def test_002_add_apply(self): """【政府端--适老化】:添加改造申请""" print("申请人name:" + self.name) param = { "idCard": self.id_card, "userName": self.name, "phone": "13999999999", "addressId": "51010915", "addressDetail": "测试地址", "transformContents": "测试内容", "transformCause": "测试", "state": 4, "emergencyContact": [{ "name": "测试", "ralative": 1, "phone": "13777777777" }], "certificates": [], "annex": [] } response = self.house.add_transform_apply(case_name="添加改造申请", param=param) print(response.json()) def test_003_get_transform_apply_list(self): """【政府端--适老化】:分页查询改造申请列表""" param = {"idCard": self.id_card, "addressId": "510109", "pageNow": 1} response = self.house.get_transform_apply_list(case_name="分页查询改造申请列表", data=param) print(response.json()) self.assertEqual(200, response.status_code) self.assertEqual(0, response.json()["status"]) self.assertEqual("操作成功", response.json()["message"]) self.apply_id.append(response.json()["data"]["records"][0]["id"]) def test_004_edit_transform(self): """【政府端--适老化】:编辑改造单""" param = { "id": self.apply_id[0], "idCard": self.id_card, "userName": self.name + "(edit)", "phone": "13999999999", "addressDetail": "测试地址(edit)", "transformContents": "测试内容(edit)", "transformCause": "测试(edit)", "emergencyContact": [{ "ralative": 1, "phone": "13777777787", "name": "测试(edit)" }], "certificates": [{ "name": "timg.gif", "url": "blob:https://test.chinaylzl.com/df5e890d-d6e3-454a-8d28-1786b9230e31" }], "state": 1, "version": 1 } response = self.house.edit_transform(case_name="编辑改造单", json=param) print(response.json()) self.assertEqual(200, response.status_code) self.assertEqual(0, response.json()["status"]) self.assertEqual("编辑成功", response.json()["message"]) def test_005_get_transform_verify_list(self): """【政府端--适老化】:分页查询改造审核列表""" param = {"idCard": self.id_card, "addressId": "510109"} response = self.house.get_transform_apply_list(case_name="分页查询改造审核列表", data=param) print(response.json()) self.assertEqual(200, response.status_code) self.assertEqual(0, response.json()["status"]) self.assertEqual("操作成功", response.json()["message"]) self.v_id.append(response.json()["data"]["records"][0]["id"]) print("改造ID:%s" % self.v_id) def test_006_verify_transform(self): """【政府端--适老化】:审核改造单""" param = {"id": self.v_id[0], "verifyState": 1} response = self.house.verify_transform(case_name="审核改造单", data=param) print(response.json()) self.assertEqual(200, response.status_code) self.assertEqual(0, response.json()["status"]) self.assertEqual("审核成功", response.json()["message"]) def test_007_business_apply(self): """【政府端--适老化】:评估中列表分页查询""" param = { "agencyId": 189, "agencyName": "api评估机构5951", "id": self.v_id[0] } response = self.house.business_apply(case_name="评估中列表分页查询", data=param) print(response.json()) self.assertEqual(200, response.status_code) self.assertEqual(0, response.json()["status"]) self.assertEqual("申请成功", response.json()["message"]) def test_008_get_assessment_list(self): """【政府端--适老化】:评估中列表分页查询""" param = {"idCard": self.id_card, "addressId": "510109", "pageNow": 1} response = self.house.get_assessment_list(case_name="评估中列表分页查询", data=param) print(response.json()) self.assertEqual(200, response.status_code) self.assertEqual(0, response.json()["status"]) self.assertEqual("操作成功", response.json()["message"])
class TestGovernProduct(unittest.TestCase): house = GovernHouse() govern_account = str(ReadYaml("default.yaml").get_account("govern")) pass_word = ReadYaml("default.yaml").get_password("govern") name = "api产品" + str(random.randint(100, 999)) product_id = [] # 产品ID @Login.govern_login(govern_account, pass_word) def test_1_add_product(self): """【适老化】:添加产品""" param = { "imgPath": [{ "name": "123", "url": "http://file.chinaylzl.com/test/userHead/2018/11/16/38acfc8085c249628beffed54bccb2c7.png" }, { "name": "456", "url": "http://file.chinaylzl.com/test/userHead/2018/11/16/38acfc8085c249628beffed54bccb2c7.png" }, { "name": "789", "url": "http://file.chinaylzl.com/test/userHead/2018/11/16/38acfc8085c249628beffed54bccb2c7.png" }], "enable": 1, "enableText": "启用", "functionParams": "功能参数", "name": self.name, "price": 100, "remark": "产品备注", "typeIds": [] } response = self.house.add_product(case_name="添加产品", param=param) print(response.json()) self.assertEqual(200, response.status_code) self.assertEqual(0, response.json()["status"]) self.assertEqual("添加成功", response.json()["message"]) def test_2_get_product_list(self): """【适老化】:分页查询产品列表""" param = {"enable": 1, "pageNow": 1, "name": self.name} response = self.house.get_product_list(case_name="分页查询产品列表", param=param) print(response.json()) self.product_id.append(response.json()["data"]["records"][0]["id"]) self.assertEqual(200, response.status_code) self.assertEqual(0, response.json()["status"]) self.assertEqual("操作成功", response.json()["message"]) def test_3_update_product(self): """【适老化】:编辑产品信息""" param = { "id": self.product_id[0], "functionParams": "功能参数(update)", "name": self.name + "(update)", "price": 156.36, "remark": "产品备注(update)", "typeIds": [1, 7, 5, 3], "imgPath": [{ "name": "1", "url": "1.png" }, { "name": "3", "url": "3.png" }, { "name": "5", "url": "5.png" }] } response = self.house.update_product(param=param) print(response.json()) self.assertEqual(200, response.status_code) self.assertEqual(0, response.json()["status"]) self.assertEqual("编辑成功", response.json()["message"]) def test_4_stop_start_product(self): """【适老化】:产品停启""" param = {"enable": 0, "pId": self.product_id[0]} response = self.house.stop_start_product(case_name="产品停启", param=param) print(response.json()) self.assertEqual(200, response.status_code) self.assertEqual(0, response.json()["status"]) self.assertEqual("操作成功", response.json()["message"]) def test_5_get_product_detail(self): """【适老化】:查看产品详情""" param = {"id": self.product_id[0]} response = self.house.get_product_detail(case_name="查看产品详情", param=param) print(response.json()) self.assertEqual(200, response.status_code) self.assertEqual(0, response.json()["status"]) self.assertEqual("操作成功", response.json()["message"]) self.assertEqual(self.name + "(update)", response.json()["data"]["name"])
class TestBusiness2(unittest.TestCase): business = Business() yang_lao = YangLao() id_card = IDCard.IDCard().idCard(66, 2) uid = [] order_id = [] read_yaml = ReadYaml("default.yaml") pass_word = read_yaml.get_password("govern") @Login.govern_login("13551042646", pass_word) def test_001(self): """添加人员-级别为:居家养老服务补贴""" print("添加人员身份证号:%s" % self.id_card) param = { "idcard": self.id_card, "username": "******" + self.id_card + "_2", "nationality": "汉族", "maritalstatus": 0, "level": 2, "contact1": "15212365478", "residenceaddress": "5101090201", "address": "测试详细地址", "emergencycontact1name": "测试", "emergencycontact1address": "测试地址", "emergencycontact1relationship": 0, "emergencycontact1phone": "152133655", "epJsonString": "[{'epName':'养老','ephone':'028-1236548','epSex':'','epOtherPhone':'','epIdcard':''," "'epRelation':'','epAddress':'','epUnits':'','epWorkAddress':''}]", 'headImage': 'http://file.chinaylzl.com/test/userHead/2018/11/16/38acfc8085c249628beffed54bccb2c7.png' } res = self.yang_lao.add_survey_user(case_name="添加居家养老服务补贴", param=param) print("【添加人员-级别为:居家养老服务补贴】:%s" % res.json()) @Login.govern_login("18048054262", pass_word) def test_002(self): """政府端:根据身份证号查询UID""" param = {"idCard": self.id_card, "pageIndex": 1, "isBind": ""} res = self.yang_lao.list_users_new(case_name="根据身份证号查询UID", param=param) u_id = res.json()["pageView"]["records"][0]["id"] self.uid.append(u_id) print("【根据身份证获取uid】 :%s" % res.json()) self.assertEqual("", res.json()["detail"]) def test_003(self): """积分充值""" param = { "uid": self.uid[0], "balance": 100, "remark": 0, "source": "api" } res = self.yang_lao.single_recharge(case_name="添加居家养老服务补贴", param=param) print("【积分充值】:%s" % res.json()) self.assertEqual("充值成功", res.json()["detail"]) @Login.business_login("849001", pass_word) def test_004(self): """服务订单生成--查询信息""" param = {"classification": 1, "groupId": 2, "idcard": self.id_card} res = self.business.query_pai_user_info(case_name="服务订单生成--查询信息", param=param) print("【普通人员:服务订单生成】:%s" % res.json()) def test_005(self): """创建服务订单""" end_date = str( datetime.datetime.now().strftime('%Y-%m-%d')) + " 23:59:59" param = { "classification": 1, "groupId": 2, "idcard": self.id_card, "uid": self.uid[0], "mark": "api", "itemsId": "310", "number": 1, "endDate": end_date } res = self.business.create_orders(case_name="创建服务订单", param=param) print("【创建服务订单】: %s" % res.json()) def test_006(self): """获取订单ID""" param = {"idCard": self.id_card} res = self.business.query_pai_order_send(case_name="获取订单ID", param=param) print("【获取订单ID】:%s" % res.json()) self.order_id.append(res.json()['pageView']['records'][0]['orderId']) self.assertEqual("获取成功", res.json()["detail"]) def test_007(self): """订单派工""" param = {"buid": "1182", "orderId": self.order_id[0]} res = self.business.save_service_record(case_name="订单派工", param=param) print("【订单派工】: %s" % res.json()) @Login.business_app_login("626753", pass_word) def test_008(self): """派工助手--开始服务""" param = { 'orderId': self.order_id[0], 'startPosition': '104.081859,30.546299' } res = self.business.start_service(case_name="派工助手--开始服务", param=param) print("【派工助手--开始服务】: %s" % res.json()) def test_009(self): """派工助手--完成服务""" param = { 'type': '2', 'endPosition': '104.081849,30.54631', 'orderId': self.order_id[0], 'images': 'https://file.chinaylzl.com/test/serviceImages/2018/11/15/4a6f2a0ffff54ca88aed5132f482a4aa.jpg,' } res = self.business.complete_service(case_name="派工助手--完成服务", param=param) print("【派工助手--完成服务】: %s" % res.json()) def test_010(self): """派工助手--评价订单""" param = {'orderId': self.order_id[0], 'degree': '100'} res = self.business.update_service_degree(case_name="派工助手--评价订单", param=param) print("【派工助手--评价订单】: %s" % res.json())
class TestGovernConstruction(unittest.TestCase): house = GovernHouse() govern_account = str(ReadYaml("default.yaml").get_account("govern")) pass_word = ReadYaml("default.yaml").get_password("govern") b_id = [] name = "api施工单位" + str(random.randint(100, 999)) phone = "139825556" + str(random.randint(100, 999)) @Login.govern_login(govern_account, pass_word) def test_001_add_construction_business(self): """【政府端--适老化】:添加施工单位""" param = { "account": self.phone, "address": "办公地址", "annexList": [{ "name": "1", "url": "1.txt" }, { "name": "2", "url": "2.png" }], "businessLicense": random.randint(1000000, 9999999), "certificateList": [{ "name": "1", "url": "1.txt" }, { "name": "2", "url": "2.png" }], "constructorCount": 100, "email": "*****@*****.**", "employeeCount": 30, "enable": 1, "legalPerson": "法人代表", "name": self.name, "password": "******", "personInCharge": "测试", "personPhone": "15282566260", "serviceArea": ["510109"] } response = self.house.add_construction_business(case_name="添加施工单位", param=param) print(response.json()) self.assertEqual(200, response.status_code) self.assertEqual(0, response.json()["status"]) self.assertEqual("添加成功", response.json()["message"]) def test_002_get_construction_business_list(self): """【政府端--适老化】:分页查询施工单位列表""" param = {"name": self.name, "pageNow": 1, "enable": 1} response = self.house.get_construction_business_list( case_name="分页查询施工单位列表", param=param) print(response.json()) self.b_id.append(response.json()["data"]["records"][0]["id"]) print(self.b_id[0]) self.assertEqual(200, response.status_code) self.assertEqual(0, response.json()["status"]) self.assertEqual("操作成功", response.json()["message"]) def test_003_edit_construction_business(self): """【政府端--适老化】:编辑施工单位信息""" param = { "id": self.b_id[0], "account": self.phone, "businessLicense": "123456789", "address": "办公地址(update)", "annex": [{ "name": "1(update)", "url": "1.txt" }, { "name": "2(update)", "url": "2.png" }], "certificate": [{ "name": "1", "url": "1.txt" }, { "name": "2", "url": "2.png" }], "constructorCount": 100, "email": "*****@*****.**", "employeeCount": 30, "enable": 1, "legalPerson": "法人代表(update)", "name": self.name + "(update)", "password": "******", "personInCharge": "测试(update)", "serviceArea": ["51010901", "51010902", "51010903"] } response = self.house.edit_construction_business(case_name="编辑施工单位信息", param=param) print(response.json()) self.assertEqual(200, response.status_code) self.assertEqual(0, response.json()["status"]) self.assertEqual("修改成功", response.json()["message"]) def test_004_get_business_detail(self): """【政府端 - -适老化】:获取施工单位信息""" param = {"bid": self.b_id[0]} response = self.house.get_business_detail(case_name="获取施工单位信息", param=param) print(response.json()) self.assertEqual(200, response.status_code) self.assertEqual(0, response.json()["status"]) self.assertEqual("操作成功", response.json()["message"]) self.assertEqual(self.phone, response.json()["data"]["account"]) def test_005_record_construction_list(self): """【政府端--适老化】:施工记录""" param = {"constructionId": self.b_id[0], "pageNow": 1} response = self.house.record_construction_list(case_name="施工记录", param=param) print(response.json()) self.assertEqual(200, response.status_code) self.assertEqual(0, response.json()["status"]) self.assertEqual("操作成功", response.json()["message"]) def test_006_stop_or_start_constructor(self): """【政府端--适老化】:停启施工单位""" param = {"bId": self.b_id[0], "enable": 0} response = self.house.stop_or_start_constructor(case_name="停启施工单位", param=param) print(response.json()) self.assertEqual(200, response.status_code) self.assertEqual(0, response.json()["status"])