def test_deletegroup(id_): try: tok = autorization.autorisation() url = 'http://srv-pnew-01-test.ponyex.local:1001/api/v1/user-profile-groups/delete-item' params = {'id': id_ } headers = {'Authorization': 'Bearer ' + tok} r = requests.delete(url, headers = headers, params = params) r.status_code == 200 assert group_existence(tok) == 0 except: print('группа не удалена')
def test_request_14(): with allure.step('тест14'): token = autorization.autorisation() if token == 'ERROR': print('Тест 14 не пройден') return destinationPointId = "4110acc0-137f-4fe6-bf69-50ee2590ded4" r = event_79_request.included_in_consolidation(token, destinationPointId) assert r == 'ERROR' or r['result'] is None, 'Не смог создать блок событий 79 - включён в консолидацию, ' \ 'Тест 14 не пройден ' ''' if r == 'ERROR' or r['result'] is None: print('Не смог создать блок событий 79 - включён в консолидацию') print('Тест 14 не пройден') return ''' destinationPoint = r['result']['destinationPoint'] assert destinationPoint[ 'code'] != '1202', 'Попал в другой блок, Тест 14 не пройден' ''' if destinationPoint['code'] != '1202': print('Попал в другой блок') print('Тест 14 не пройден') return ''' print('Блок успешно создан') id_ = r['result']['id'] number = "99-9999-9999/999" r = event_79_request.add_object(token, id_, number) assert r == 'ERROR', 'Не смог вбить номер места накладной, Тест 14 не пройден' ''' if r == 'ERROR': print('Не смог вбить номер места накладной') print('Тест 14 не пройден') return ''' assert r['metadata']['message'] == "$_PLACE_IS_OUT_OF_RANGE_$", 'Система вернула ошибку «Отсутствует ' \ 'введенное место накладной», Тест 14 пройден ' assert r['metadata'][ 'message'] != "$_PLACE_IS_OUT_OF_RANGE_$", 'Система нашла номер места накладной: ' + number '''
def ad_ID_3(): try: tok = autorization.autorisation() addressId = '2344f4b3-a7bd-4512-686d-08d8c4533103' url = f'http://geography-backend-edu.pegasus.ponyex.local/api/v1/geography/get-polygon-with-coordinates-by-address-id/{addressId}' data = {"addressId": "2344f4b3-a7bd-4512-686d-08d8c4533103"} headers = {'Content-Type': 'application/json', 'Authorization': 'Bearer ' + tok} r = requests.get(url, params=json.dumps(data), headers=headers) answer = json.loads(r.text) if '$_ADDRESS_NOT_FOUND_$' in str(answer['metadata']['message']): print('адреса с таким айди нет') print(answer) except: print('ошибка')
def test_creategroup(): try: tok = autorization.autorisation() url = 'http://srv-pnew-01-test.ponyex.local:1001/api/v1/user-profile-groups/post-item' data = {'displayName': "abc"} headers = {'Content-Type': 'application/json', 'Authorization': 'Bearer ' + tok} r = requests.post(url, data = json.dumps(data), headers = headers) answer = json.loads(r.text) print(answer) id_ = json.loads(r.text)['result']['id'] assert group_existence(tok) == 1 return(id_) except: print('группа не создана')
def test_without_sorting_and_couriers(token): with allure.step('блок событий 71'): try: token = autorization.autorisation() url = 'http://events-backend-edu.pegasus.ponyex.local/api/v1/event-blocks71/post-item' headers = {'Authorization': f'Bearer {token}'} data = {"description": ""} r = requests.post(url, json=data, headers=headers) assert r.status_code == 200, 'успешно' answer = json.loads(r.text) id__ = answer['result']['id'] return id__ except: print('ошибка, блок не создан')
def test_req_number_of_object(): with allure.step('регистрация объекта'): try: tok = autorization.autorisation() url = 'http://events-backend-edu.pegasus.ponyex.local/api/v1/pegasus-events71/post-item' data = {"scannedNumber": "11-1111-1111", "hostName": "abcde", "eventBlockId": "356d56a1-6902-4ec4-b87c-08d8bec28892", "pointId": "07c5c96a-6f52-428d-9332-0004c296067e"} headers = {'Content-Type': 'application/json', 'Authorization': 'Bearer ' + tok} r = requests.post(url, data=json.dumps(data), headers=headers) answer = json.loads(r.text) assert answer['metadata']['message'] == '$_OBJECT_NUMBER_NOT_VALID_$', 'номер объекта не валидный' assert answer['metadata']['message'] == '$_MARK_IS_NOT_BOUND_$', 'Марка не привязана' print(answer) except: print('ошибка')
def ad_ID(): try: tok = autorization.autorisation() id_ = '2344f4b3-a7bd-4512-686d-08d8c4533103' url = f'http://geography-backend-edu.pegasus.ponyex.local/api/v1/addresses/get-by-id/{id_}' data = { "id": "2344f4b3-a7bd-4512-686d-08d8c4533103", "hostName": "abcde" } headers = { 'Content-Type': 'application/json', 'Authorization': 'Bearer ' + tok } r = requests.get(url, params=json.dumps(data), headers=headers) answer = json.loads(r.text) if answer['metadata']['message'] == 'Object not found': print('адреса с таким айди нет') print(answer) except: print('ошибка')
def test_request_13(): with allure.step('тест13'): token = autorization.autorisation() destinationPointId = "4110acc0-137f-4fe6-bf69-50ee2590ded4" r = event_79_request.included_in_consolidation(token, destinationPointId) if r == 'ERROR': print('Тест 13 не пройден') assert 0 #return destinationPoint = r['result']['destinationPoint'] if destinationPoint['code'] == '1202': print('Блок успешно создан') print('Тест 13 пройден') return else: print('Попал в другой блок') print('Тест 13 не пройден') return
'http://delivery-edu.pegasus.ponyex.local/api/manual/index.html', 'http://delivery-backend-edu.pegasus.ponyex.local/api/manual/index.html', 'http://enumerations-backend-edu.pegasus.ponyex.local/api/manual/index.html', 'http://events-edu.pegasus.ponyex.local/api/manual/index.html', 'http://events-backend-edu.pegasus.ponyex.local/api/manual/index.html', 'http://geography-edu.pegasus.ponyex.local/api/manual/index.html', 'http://geography-backend-edu.pegasus.ponyex.local/api/manual/index.html', 'http://localizations-backend-edu.pegasus.ponyex.local/api/manual/index.html', 'http://organization-backend-edu.pegasus.ponyex.local/api/manual/index.html', 'http://warehouses-edu.pegasus.ponyex.local/api/manual/index.html', 'http://warehouses-backend-edu.pegasus.ponyex.local/api/manual/index.html', 'http://waybills-backend-edu.pegasus.ponyex.local/api/manual/index.html' ] """ tok = autorization.autorisation() r1 = requests.get(pathes.urls[0] + 'api/v1/configurations/get-all', headers={'Authorization': 'Bearer ' + tok}) id_ = '359afb0c-b870-4610-9233-524db1d5a029' r2 = requests.get(pathes.urls[1] + f'/api/v1/couriers/get-courier-by-id/ {id_}', headers={ 'Authorization': 'Bearer ' + tok, "id": id_ }) print(r2.status_code) answer = json.loads(r2.text)['result'] print(answer['firstName'] + ' ' + answer['lastName'])
with allure.step('нахождение объекта'): url = f'http://events-backend-edu.pegasus.ponyex.local/api/v1/pegasus-events71/get-events-by-event-block-id/{id_}' headers = {'Authorization': f'Bearer {token}'} data = {'id': id_} r = requests.get(url, headers=headers, params=data) assert r.status_code != 200, 'Запрос вернул код ошибки' assert r.status_code == 200, 'Запрос вернул код успеха' def test_delete_object(token, id_): with allure.step('удаление объекта'): url = f'http://events-backend-edu.pegasus.ponyex.local/api/v1/pegasus-events71/delete-item/{id_}' headers = {'Authorization': f'Bearer {token}'} data = {'id': id_} r = requests.delete(url, headers=headers, params=data) assert r.status_code != 200, 'Запрос вернул код ошибки' assert r.status_code == 200, 'Запрос вернул код успеха' if __name__ == "__main__": token = autorization.autorisation() id_ = test_without_sorting_and_couriers(token) number = "11-1111-1111" waybill_id = test_add_object(token, id_, number) test_find_object(token, id_) test_delete_object(token, waybill_id)