Пример #1
0
def test_delete_user_failed(admin_user, user):
    correct_dict = get_delete_dict_for_user()
    response = patch_data(user,
                          'change_blocked_status',
                          data=correct_dict,
                          id=user.id)
    assert response.status_code == rest_status.HTTP_403_FORBIDDEN
    response = patch_data(admin_user,
                          'change_blocked_status',
                          data=correct_dict,
                          id=user.id + random.randint(1, 10))
    assert response.status_code == rest_status.HTTP_404_NOT_FOUND
Пример #2
0
def test_change_status_for_add_animal_request(admin_user):
	animal, request = prepare_data_for_add_ro_rent_answer(admin_user)
	answer_to_add_animal_for_rent_request = answer_to_add_animal_request(Statuses.REJECTED.value)
	response = patch_data(admin_user, 'answer_add_animal_for_rent', data=answer_to_add_animal_for_rent_request, id=request.id)
	assert response.status_code == rest_status.HTTP_200_OK
	animal.refresh_from_db()
	assert animal.blocked
Пример #3
0
def test_delete_user_ok(admin_user, user):
    correct_dict = get_delete_dict_for_user()
    response = patch_data(admin_user,
                          'change_blocked_status',
                          data=correct_dict,
                          id=user.id)
    assert response.status_code == rest_status.HTTP_200_OK
    user.refresh_from_db()
    assert user.is_deleted
Пример #4
0
def test_update_user_fail(user):
    correct_dict = get_dict_for_update(user)
    length = random.randint(1, 10)
    correct_dict['repeated_new_password'] = get_random_string(length)
    response = patch_data(user, 'update_user', data=correct_dict)
    assert response.status_code == rest_status.HTTP_400_BAD_REQUEST
    correct_dict = get_dict_for_update(user)
    correct_dict.pop('password')
    assert response.status_code == rest_status.HTTP_400_BAD_REQUEST
Пример #5
0
def test_update_only_phone_user_ok(user):
    correct_dict = get_dict_for_update(user)
    correct_dict_with_only_phone = {
        "phone_number": correct_dict['phone_number'],
        "password": correct_dict['password']
    }
    response = patch_data(user,
                          'update_user',
                          data=correct_dict_with_only_phone)
    assert response.status_code == rest_status.HTTP_200_OK
    user.refresh_from_db()
    assert user.phone_number == correct_dict['phone_number']
Пример #6
0
def test_update_user_ok(user):
    correct_dict = get_dict_for_update(user)
    response = patch_data(user, 'update_user', data=correct_dict)
    assert response.status_code == rest_status.HTTP_200_OK
    user.refresh_from_db()
    assert user.phone_number == correct_dict['phone_number']
Пример #7
0
def test_not_admin_for_add_animal_request(user):
	animal, request = prepare_data_for_add_ro_rent_answer(user)
	answer_to_add_animal_for_rent_request = answer_to_add_animal_request(Statuses.APPROVED.value)
	response = patch_data(user, 'answer_add_animal_for_rent', data=answer_to_add_animal_for_rent_request, id=request.id)
	assert response.status_code == rest_status.HTTP_403_FORBIDDEN