コード例 #1
0
 def test_update_user_surname_to_none(self, base_url, user_dict):
     user_creation_response = UsersApi.create_user(base_url, user_dict)
     assert user_creation_response.status_code == HTTPStatus.CREATED
     update_data = user_dict.copy()
     update_data['name'] = None
     update_user_result = UsersApi.update_user(base_url, user_dict['id'], data=json.dumps(update_data))
     assert update_user_result.status_code == HTTPStatus.BAD_REQUEST
     assert update_user_result.json() == USER_DATA_NOT_SPECIFIED_ERROR
コード例 #2
0
 def test_update_user_surname_to_one_char_value(self, base_url, user_dict):
     user_creation_response = UsersApi.create_user(base_url, user_dict)
     assert user_creation_response.status_code == HTTPStatus.CREATED
     update_data = user_dict.copy()
     update_data['surname'] = random.choice(string.ascii_letters)
     update_user_result = UsersApi.update_user(base_url, user_dict['id'], data=update_data)
     assert update_user_result.status_code == HTTPStatus.OK
     UserTestAssertion.verify_user(update_data, update_user_result.json())
コード例 #3
0
 def test_create_user_with_not_unique_name_and_surname(self, base_url, user_dict):
     first_user_creation_response = UsersApi.create_user(base_url, data=user_dict)
     assert first_user_creation_response.status_code == HTTPStatus.CREATED
     second_user_data = user_dict.copy()
     second_user_data['id'] = randint(1, 999999)
     second_user_creation_response = UsersApi.create_user(base_url, data=second_user_data)
     assert second_user_creation_response.status_code == HTTPStatus.CREATED
     UserTestAssertion.verify_user(second_user_data, second_user_creation_response.json())
コード例 #4
0
 def test_delete_existing_user(self, base_url, user_dict):
     create_user_response = UsersApi.create_user(base_url, user_dict)
     assert create_user_response.status_code == HTTPStatus.CREATED
     delete_user_response = UsersApi.delete_user(base_url, user_dict['id'])
     assert delete_user_response.status_code == HTTPStatus.OK
     assert delete_user_response.json()['ok'] is True
     get_deleted_user_response = UsersApi.get_user(base_url, user_dict['id'])
     assert get_deleted_user_response.status_code == HTTPStatus.NOT_FOUND
コード例 #5
0
 def test_update_users_name_to_int(self, base_url, user_dict):
     creation_user_response = UsersApi.create_user(base_url, user_dict)
     assert creation_user_response.status_code == HTTPStatus.CREATED
     update_data = user_dict.copy()
     update_data['name'] = randint(1, 999999)
     update_user_result = UsersApi.update_user(base_url, user_dict['id'], data=update_data)
     assert update_user_result.status_code == HTTPStatus.BAD_REQUEST
     assert update_user_result.json() == USER_NOT_STRING_ERROR
コード例 #6
0
 def test_update_user_surname_to_spaces(self, base_url, user_dict):
     creation_user_response = UsersApi.create_user(base_url, user_dict)
     assert creation_user_response.status_code == HTTPStatus.CREATED
     update_data = user_dict.copy()
     update_data['surname'] = ' '
     update_user_result = UsersApi.update_user(base_url, user_dict['id'], data=update_data)
     assert update_user_result.status_code == HTTPStatus.BAD_REQUEST
     assert update_user_result.json() == USER_DATA_EMPTY_STRING_ERROR
コード例 #7
0
 def test_update_user_name_with_leading_spaces(self, base_url, user_dict):
     user_creation_response = UsersApi.create_user(base_url, user_dict)
     assert user_creation_response.status_code == HTTPStatus.CREATED
     update_data = user_dict.copy()
     update_data['name'] = '  ' + user_dict['name']
     update_data['surname'] = ' ' + user_dict['surname']
     update_user_result = UsersApi.update_user(base_url, user_dict['id'], data=update_data)
     assert update_user_result.status_code == HTTPStatus.OK
     UserTestAssertion.verify_user(update_data,update_user_result.json())
コード例 #8
0
 def test_change_user_surname(self, base_url, user_dict):
     user_creation_response = UsersApi.create_user(base_url, user_dict)
     assert user_creation_response.status_code == HTTPStatus.CREATED
     update_data = user_dict.copy()
     update_data['surname'] += 'test'
     update_user_result = UsersApi.update_user(base_url, user_dict['id'], data=update_data)
     assert update_user_result.status_code == HTTPStatus.OK
     UserTestAssertion.verify_user(update_data, update_user_result.json())
     get_updated_user_result = UsersApi.get_user(base_url, user_dict['id'])
     assert get_updated_user_result.status_code == HTTPStatus.OK
     assert get_updated_user_result.json()['surname'] == update_data['surname']
コード例 #9
0
 def test_change_user_name(self, base_url, user_dict):
     user_creation_response = UsersApi.create_user(base_url, user_dict)
     assert user_creation_response.status_code == HTTPStatus.CREATED
     data_for_update = user_dict.copy()
     data_for_update['name'] += 'test'
     update_user_result = UsersApi.update_user(base_url, user_dict['id'], data=data_for_update)
     assert update_user_result.status_code == HTTPStatus.OK
     UserTestAssertion.verify_user(data_for_update, update_user_result.json())
     get_updated_user = UsersApi.get_user(base_url, user_dict['id'])
     assert get_updated_user.status_code == HTTPStatus.OK
     assert get_updated_user.json()['name'] == data_for_update['name']
コード例 #10
0
 def test_create_user_with_trailing_spaces(self, base_url, user_dict):
     test_data = user_dict.copy()
     test_data['name'] = user_dict['name'] + ' '
     test_data['surname'] = user_dict['surname'] + ' '
     response = UsersApi.create_user(base_url, data=test_data)
     assert response.status_code == HTTPStatus.CREATED
     UserTestAssertion.verify_user(user_dict, response.json())
コード例 #11
0
 def test_create_user_when_name_is_number(self, base_url, user_dict):
     user_dict['name'] = randint(0, 123456)
     response = UsersApi.create_user(base_url, data=user_dict)
     assert response.status_code == HTTPStatus.BAD_REQUEST
     assert response.json() == USER_NOT_STRING_ERROR
コード例 #12
0
 def test_get_user_by_non_existing_id(self, base_url):
     non_existing_id = 0
     response = UsersApi.get_user(base_url, non_existing_id)
     assert response.status_code == HTTPStatus.NOT_FOUND
     assert response.json() == USER_NOT_FOUND_ERROR
コード例 #13
0
 def test_create_user_with_string_id(self, base_url, user_dict):
     user_dict['id'] = 'test'
     response = UsersApi.create_user(base_url, data=user_dict)
     assert response.status_code == HTTPStatus.BAD_REQUEST
     assert response.json() == USER_ID_IS_NOT_INT_ERROR
コード例 #14
0
 def test_create_user_with_empty_surname(self, base_url, user_dict):
     user_dict['surname'] = ''
     response = UsersApi.create_user(base_url, data=user_dict)
     assert response.status_code == HTTPStatus.BAD_REQUEST
     assert response.json() == USER_DATA_EMPTY_STRING_ERROR
コード例 #15
0
 def test_create_user_with_one_char_surname(self, base_url, user_dict):
     user_dict['surname'] = random.choice(string.ascii_letters)
     response = UsersApi.create_user(base_url, data=user_dict)
     assert response.status_code == HTTPStatus.CREATED
     UserTestAssertion.verify_user(user_dict, response.json())
コード例 #16
0
 def test_create_user_without_id(self, base_url, user_dict):
     user_dict['id'] = None
     response = UsersApi.create_user(base_url, data=json.dumps(user_dict))
     assert response.status_code == HTTPStatus.BAD_REQUEST
     assert response.json() == USER_ID_IS_NOT_INT_ERROR
コード例 #17
0
 def test_create_user_without_surname(self, base_url, user_dict):
     user_dict['surname'] = None
     response = UsersApi.create_user(base_url, data=user_dict)
     assert response.status_code == HTTPStatus.BAD_REQUEST
     assert response.json() == USER_DATA_NOT_SPECIFIED_ERROR
コード例 #18
0
 def test_create_duplicate(self, base_url, user_dict):
     user = UsersApi.create_user(base_url, data=user_dict)
     assert user.status_code == HTTPStatus.CREATED
     duplicate = UsersApi.create_user(base_url, data=user_dict)
     assert duplicate.status_code == HTTPStatus.BAD_REQUEST
     assert duplicate.json() == USER_ALREADY_EXISTS_ERROR.format(id=user_dict["id"])
コード例 #19
0
 def test_delete_non_existing_user(self, base_url, user_dict):
     delete_user_response = UsersApi.delete_user(base_url, user_dict['id'])
     assert delete_user_response.status_code == HTTPStatus.NOT_FOUND
     assert delete_user_response.json() == USER_NOT_FOUND_ERROR
コード例 #20
0
 def user_dict(self, base_url):
     user = UserFactory().__dict__
     yield user
     UsersApi.delete_user(base_url, user_id=user["id"])
コード例 #21
0
 def test_get_user_by_id(self, base_url, user_dict):
     creation_response = UsersApi.create_user(base_url, data=user_dict)
     assert creation_response.status_code == HTTPStatus.CREATED
     get_request = UsersApi.get_user(base_url, user_dict['id'])
     assert get_request.status_code == HTTPStatus.OK
     UserTestAssertion.verify_user(user_dict, get_request.json())
コード例 #22
0
 def test_create_user(self, base_url, user_dict):
     response = UsersApi.create_user(base_url, data=user_dict)
     assert response.status_code == HTTPStatus.CREATED
     UserTestAssertion.verify_user(user_dict, response.json())