Пример #1
0
    def test_users_list_get_all(self):
        with allure.step(
                "Send a get list request with role all, page 1 and default 30 per page"
        ):
            all_users_list = SendRequest(
                UsersList.get_test_case("test_users_list_get_all"))

        with allure.step('Checking if per page is less or equal 30'):
            is_per_page_30 = len(all_users_list.get_users_list()) <= int(
                constants.PER_PAGE_30)
            allure.attach("Per page is 330: True", "Expected:")
            allure.attach("Per page is " + str(is_per_page_30), "Actual:")
            assert is_per_page_30 is True

        with allure.step('Checking if all user type return'):
            is_all_users_return = all_users_list.is_all_users_type_in_the_list(
            )
            allure.attach("All users type return: True", "Expected:")
            allure.attach("All users type return: " + str(is_all_users_return),
                          "Actual:")
            assert is_all_users_return is True

        with allure.step('Checking Ret'):
            allure.attach("Ret: " + str(constants.RET_200), "Expected:")
            allure.attach("Ret: " + str(all_users_list.get_ret()), "Actual:")
            assert all_users_list.get_ret() == constants.RET_200

        with allure.step('Checking Err_code'):
            allure.attach("Err_code: " + str(constants.ERR_CODE_0),
                          "Expected:")
            allure.attach("Err_code: " + str(all_users_list.get_err_code()),
                          "Actual:")
            assert all_users_list.get_err_code() == constants.ERR_CODE_0
Пример #2
0
    def test_users_list_get_admin(self):
        with allure.step(
                "Send a get list request with role admin, page 1 and 10 per page"
        ):
            all_admin_list = SendRequest(
                UsersList.get_test_case("test_users_list_get_admin"))

        with allure.step('Checking if per page is less or equal to 10'):
            is_per_page_less_or_equal_10 = len(
                all_admin_list.get_users_list()) <= int(constants.PER_PAGE_10)
            allure.attach("Per page is less or equal to 10: True", "Expected:")
            allure.attach(
                "Per page is less or equal to 10: " +
                str(is_per_page_less_or_equal_10), "Actual:")
            assert is_per_page_less_or_equal_10 is True

        with allure.step('Checking if all users are admin'):
            is_all_users_admin = all_admin_list.is_all_users_admin()
            allure.attach("All users are admin: True", "Expected:")
            allure.attach("All users are admin: " + str(is_all_users_admin),
                          "Actual:")
            assert is_all_users_admin is True

        with allure.step('Checking Ret'):
            allure.attach("Ret: " + str(constants.RET_200), "Expected:")
            allure.attach("Ret: " + str(all_admin_list.get_ret()), "Actual:")
            assert all_admin_list.get_ret() == constants.RET_200

        with allure.step('Checking Err_code'):
            allure.attach("Err_code: " + str(constants.ERR_CODE_0),
                          "Expected:")
            allure.attach("Err_code: " + str(all_admin_list.get_err_code()),
                          "Actual:")
            assert all_admin_list.get_err_code() == constants.ERR_CODE_0
Пример #3
0
    def test_alter_password_success(self):
        with allure.step('Send alter password request(success)'):
            alter_password_success = SendRequest(
                AlterPassword.get_test_case("test_alter_password_success"))

        with allure.step('Checking Ret'):
            allure.attach("Ret: " + str(constants.RET_200), "Expected:")
            allure.attach("Ret: " + str(alter_password_success.get_ret()),
                          "Actual:")
            assert alter_password_success.get_ret() == constants.RET_200

        with allure.step('Checking Err_code'):
            allure.attach("Err_code: " + str(constants.ERR_CODE_0),
                          "Expected:")
            allure.attach(
                "Err_code: " + str(alter_password_success.get_err_code()),
                "Actual:")
            assert alter_password_success.get_err_code(
            ) == constants.ERR_CODE_0

        with allure.step('Checking if the user can log in with new password'):
            login_with_new_password = SendRequest(
                Login.get_test_case("test_login_with_new_password"))

            allure.attach(
                "Ret = " + str(constants.RET_200) + "and Err_code = " +
                str(constants.ERR_CODE_0), "Expected:")
            allure.attach(
                "Ret = " + str(constants.ERR_CODE_0) + "Err_code =  " +
                str(alter_password_success.get_err_code()), "Actual:")
            assert login_with_new_password.get_ret() == constants.RET_200
            assert login_with_new_password.get_err_code(
            ) == constants.ERR_CODE_0
Пример #4
0
    def test_login_with_banned_username(self):
        with allure.step('Send a login request with banned username'):
            login_with_banned_username = SendRequest(
                Login.get_test_case("test_login_with_banned_username"))

        with allure.step('Checking Err_msg'):
            allure.attach(
                "Err_msg contains: " +
                constants.ERR_MSG_WRONG_PASSWORD_OR_BANNED_USERNAME,
                "Expected:")
            allure.attach(
                "Err_msg: " + login_with_banned_username.get_err_msg(),
                "Actual:")
            assert constants.ERR_MSG_WRONG_PASSWORD_OR_BANNED_USERNAME in login_with_banned_username.get_err_msg(
            )

        with allure.step('Checking Ret'):
            allure.attach("Ret: " + str(constants.RET_200), "Expected:")
            allure.attach("Ret: " + str(login_with_banned_username.get_ret()),
                          "Actual:")
            assert login_with_banned_username.get_ret() == constants.RET_200

        with allure.step('Checking Err_code'):
            allure.attach("Err_code: " + str(constants.ERR_CODE_2),
                          "Expected:")
            allure.attach(
                "Err_code: " + str(login_with_banned_username.get_err_code()),
                "Actual:")
            assert login_with_banned_username.get_err_code(
            ) == constants.ERR_CODE_2
Пример #5
0
    def test_register_new_user_success(self):
        with allure.step("Send a users list request before register"):
            users_list_before_register = SendRequest(
                UsersList.get_test_case("test_users_list_get_all"))

        with allure.step("Get number of users before new user registers"):
            num_of_users_before_register = users_list_before_register.get_total(
            )

        with allure.step("Send a register request"):
            register_new_user_success = SendRequest(
                Register.get_test_case("test_register_new_user_success"))

        with allure.step("send a users list request after register"):
            new_username_uuid = register_new_user_success.get_uuid()
            users_list_after_register = SendRequest(
                UsersList.get_test_case("test_users_list_get_all"))

        with allure.step("Get number of users before new user registers"):
            num_of_users_after_register = users_list_after_register.get_total()

        with allure.step('Checking if new user in the list'):
            is_new_user_in_the_list = users_list_after_register.is_user_in_the_list(
                new_username_uuid)
            allure.attach("Is new user in the list: True", "Expected:")
            allure.attach(
                "Is new user in the list: " + str(is_new_user_in_the_list),
                "Actual:")
            assert is_new_user_in_the_list is True

        with allure.step(
                "Checking if total users increased by one after register"):
            is_total_users_increased_by_one = num_of_users_before_register + 1 == num_of_users_after_register
            allure.attach("Is new user in the list: True", "Expected:")
            allure.attach(
                "Is new user in the list: " +
                str(is_total_users_increased_by_one), "Actual:")
            assert is_total_users_increased_by_one

        with allure.step('Checking Ret'):
            allure.attach("Ret: " + str(constants.RET_200), "Expected:")
            allure.attach("Ret: " + str(register_new_user_success.get_ret()),
                          "Actual:")
            assert register_new_user_success.get_ret() == constants.RET_200

        with allure.step('Checking Err_code'):
            allure.attach("Err_code: " + str(constants.ERR_CODE_0),
                          "Expected:")
            allure.attach(
                "Err_code: " + str(register_new_user_success.get_err_code()),
                "Actual:")
            assert register_new_user_success.get_err_code(
            ) == constants.ERR_CODE_0
Пример #6
0
    def test_logout_with_admin_success(self):
        with allure.step("Send an admin logout request"):
            admin_success_logout = SendRequest(Logout.get_test_case(
                "test_logout_with_admin_success", TestLogOutWithAdminSuccess.admin_token))

        with allure.step('Checking Ret'):
            allure.attach("Ret: " + str(constants.RET_200), "Expected:")
            allure.attach("Ret: " + str(admin_success_logout.get_ret()), "Actual:")
            assert admin_success_logout.get_ret() == constants.RET_200

        with allure.step('Checking Err_code'):
            allure.attach("Err_code: " + str(constants.ERR_CODE_0), "Expected:")
            allure.attach("Err_code: " + str(admin_success_logout.get_err_code()), "Actual:")
            assert admin_success_logout.get_err_code() == constants.ERR_CODE_0
Пример #7
0
    def test_login_with_nonexistent_username(self):
        with allure.step('Send a login request with nonexistent username'):
            login_with_nonexistent_username = SendRequest(Login.get_test_case("test_login_with_nonexistent_username"))

        with allure.step('Checking Err_msg'):
            allure.attach("Err_msg contains: " + constants.ERR_MSG_NONEXISTENT_USERNAME, "Expected:")
            allure.attach("Err_msg: " + login_with_nonexistent_username.get_err_msg(), "Actual:")
            assert constants.ERR_MSG_NONEXISTENT_USERNAME in login_with_nonexistent_username.get_err_msg()

        with allure.step('Checking Ret'):
            allure.attach("Ret: " + str(constants.RET_200), "Expected:")
            allure.attach("Ret: " + str(login_with_nonexistent_username.get_ret()), "Actual:")
            assert login_with_nonexistent_username.get_ret() == constants.RET_200

        with allure.step('Checking Err_code'):
            allure.attach("Err_code: " + str(constants.ERR_CODE_1), "Expected:")
            allure.attach("Err_code: " + str(login_with_nonexistent_username.get_err_code()), "Actual:")
            assert login_with_nonexistent_username.get_err_code() == constants.ERR_CODE_1
    def test_alter_password_with_same_password(self):
        with allure.step('Send alter password request with same password'):
            alter_password_same_password = SendRequest(
                AlterPassword.get_test_case("test_alter_password_with_same_password"))

        with allure.step('Checking Err_msg'):
            allure.attach("Err_msg contains: " + constants.ERR_MSG_WRONG_PASSWORD_OR_USERNAME, "Expected:")
            allure.attach("Err_msg: " + alter_password_same_password.get_err_msg(), "Actual:")
            assert constants.ERR_MSG_SAME_PASSWORD in alter_password_same_password.get_err_msg()

        with allure.step('Checking Ret'):
            allure.attach("Ret: " + str(constants.RET_200), "Expected:")
            allure.attach("Ret: " + str(alter_password_same_password.get_ret()), "Actual:")
            assert alter_password_same_password.get_ret() == constants.RET_200

        with allure.step('Checking Err_code'):
            allure.attach("Err_code: " + str(constants.ERR_CODE_2), "Expected:")
            allure.attach("Err_code: " + str(alter_password_same_password.get_err_code()), "Actual:")
            assert alter_password_same_password.get_err_code() == constants.ERR_CODE_2
    def test_register_with_existing_username(self):
        with allure.step("Send a register request with existing username"):
            register_with_existing_username = SendRequest(
                Register.get_test_case("test_register_with_existing_username"))

        with allure.step('Checking Err_msg'):
            allure.attach("Err_msg contains: " + constants.ERR_MSG_EXISTING_USERNAME, "Expected:")
            allure.attach("Err_msg: " + register_with_existing_username.get_err_msg(), "Actual:")
            assert constants.ERR_MSG_EXISTING_USERNAME in register_with_existing_username.get_err_msg()

        with allure.step('Checking Ret'):
            allure.attach("Ret: " + str(constants.RET_200), "Expected:")
            allure.attach("Ret: " + str(register_with_existing_username.get_ret()), "Actual:")
            assert register_with_existing_username.get_ret() == constants.RET_200

        with allure.step('Checking Err_code'):
            allure.attach("Err_code: " + str(constants.ERR_CODE_1), "Expected:")
            allure.attach("Err_code: " + str(register_with_existing_username.get_err_code()), "Actual:")
            assert register_with_existing_username.get_err_code() == constants.ERR_CODE_1
Пример #10
0
    def test_users_list_with_0_per_page(self):
        with allure.step("Send a get list request with 0 per page"):
            users_list_with_0_per_page = SendRequest(UsersList.get_test_case("test_users_list_with_0_per_page"))

        with allure.step('Checking if per page is equal to 0'):
            is_per_page_equal_to_0 = len(users_list_with_0_per_page.get_users_list()) == int(constants.PER_PAGE_0)
            allure.attach("Per page is equal to 0: True", "Expected:")
            allure.attach("Per page is equal to 0" + str(is_per_page_equal_to_0), "Actual:")
            assert is_per_page_equal_to_0 is True

        with allure.step('Checking Ret'):
            allure.attach("Ret: " + str(constants.RET_200), "Expected:")
            allure.attach("Ret: " + str(users_list_with_0_per_page.get_ret()), "Actual:")
            assert users_list_with_0_per_page.get_ret() == constants.RET_200

        with allure.step('Checking Err_code'):
            allure.attach("Err_code: " + str(constants.ERR_CODE_0), "Expected:")
            allure.attach("Err_code: " + str(users_list_with_0_per_page.get_err_code()), "Actual:")
            assert users_list_with_0_per_page.get_err_code() == constants.ERR_CODE_0
Пример #11
0
    def test_users_list_get_regular_user(self):
        with allure.step(
                "Send a get list request with role user, page 2 and 15 per page"
        ):
            all_regular_users_list = SendRequest(
                UsersList.get_test_case("test_users_list_get_regular_users"))

        with allure.step('Checking if per page is less or equal 15'):
            is_per_page_less_or_equal_15 = len(
                all_regular_users_list.get_users_list()) <= int(
                    constants.PER_PAGE_15)
            allure.attach("Per page is less or equal 15: True", "Expected:")
            allure.attach(
                "Per page is less or equal 15" +
                str(is_per_page_less_or_equal_15), "Actual:")
            assert is_per_page_less_or_equal_15 is True

        with allure.step('Checking if all user type return'):
            is_all_users_type_return = all_regular_users_list.is_all_users_type_in_the_list(
            )
            allure.attach("All users type return: True", "Expected:")
            allure.attach(
                "All users type return: " + str(all_regular_users_list),
                "Actual:")
            assert is_all_users_type_return is True

        with allure.step('Checking Ret'):
            allure.attach("Ret: " + str(constants.RET_200), "Expected:")
            allure.attach("Ret: " + str(all_regular_users_list.get_ret()),
                          "Actual:")
            assert all_regular_users_list.get_ret() == constants.RET_200

        with allure.step('Checking Err_code'):
            allure.attach("Err_code: " + str(constants.ERR_CODE_0),
                          "Expected:")
            allure.attach(
                "Err_code: " + str(all_regular_users_list.get_err_code()),
                "Actual:")
            assert all_regular_users_list.get_err_code(
            ) == constants.ERR_CODE_0
    def test_check_user_status_not_logged_in(self):
        with allure.step("Send check user status request(not logged in"):
            check_user_status_not_logged_in = SendRequest(
                CheckUserStatus.get_test_case(
                    "test_check_user_status_not_logged_in"))

        with allure.step('Checking Ret'):
            allure.attach("Ret: " + str(constants.RET_200), "Expected:")
            allure.attach(
                "Ret: " + str(check_user_status_not_logged_in.get_ret()),
                "Actual:")
            assert check_user_status_not_logged_in.get_ret(
            ) == constants.RET_200

        with allure.step('Checking Err_code'):
            allure.attach("Err_code: " + str(constants.ERR_CODE_1),
                          "Expected:")
            allure.attach(
                "Err_code: " +
                str(check_user_status_not_logged_in.get_err_code()), "Actual:")
            assert check_user_status_not_logged_in.get_err_code(
            ) == constants.ERR_CODE_1
    def test_check_admin_status_logged_in(self):
        with allure.step("Send check admin status request(logged in)"):
            check_admin_status_logged_in = SendRequest(
                CheckUserStatus.get_test_case(
                    "test_check_admin_status_logged_in",
                    TestAdminStatusLoggedIn.admin_token))

        with allure.step('Checking Ret'):
            allure.attach("Ret: " + str(constants.RET_200), "Expected:")
            allure.attach(
                "Ret: " + str(check_admin_status_logged_in.get_ret()),
                "Actual:")
            assert check_admin_status_logged_in.get_ret() == constants.RET_200

        with allure.step('Checking Err_code'):
            allure.attach("Err_code: " + str(constants.ERR_CODE_0),
                          "Expected:")
            allure.attach(
                "Err_code: " +
                str(check_admin_status_logged_in.get_err_code()), "Actual:")
            assert check_admin_status_logged_in.get_err_code(
            ) == constants.ERR_CODE_0
Пример #14
0
    def test_login_with_regular_user_success(self):
        with allure.step('Send a valid regular user login request'):
            login_with_regular_user_success = SendRequest(
                Login.get_test_case("test_login_with_regular_user_success"))

        with allure.step('Checking Uuid'):
            allure.attach("Uuid: " + constants.USER_UUID, "Expected:")
            allure.attach(
                "Uuid: " + login_with_regular_user_success.get_uuid(),
                "Actual:")
            assert login_with_regular_user_success.get_uuid(
            ) == constants.USER_UUID

        with allure.step('Checking role'):
            allure.attach("Role: " + constants.ROLE_USER, "Expected:")
            allure.attach(
                "Role: " + login_with_regular_user_success.get_role(),
                "Actual:")
            assert login_with_regular_user_success.get_role(
            ) == constants.ROLE_USER

        with allure.step('Checking Ret'):
            allure.attach("Ret: " + str(constants.RET_200), "Expected:")
            allure.attach(
                "Ret: " + str(login_with_regular_user_success.get_ret()),
                "Actual:")
            assert login_with_regular_user_success.get_ret(
            ) == constants.RET_200

        with allure.step('Checking Err_code'):
            allure.attach("Err_code: " + str(constants.ERR_CODE_0),
                          "Expected:")
            allure.attach(
                "Err_code: " +
                str(login_with_regular_user_success.get_err_code()), "Actual:")
            assert login_with_regular_user_success.get_err_code(
            ) == constants.ERR_CODE_0