Esempio n. 1
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
Esempio n. 2
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
Esempio n. 3
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
Esempio n. 4
0
    def test_users_list_with_long_token(self):
        with allure.step("Send a get list request with long token"):
            users_list_with_long_token = SendRequest(UsersList.get_test_case("test_users_list_with_long_token"))

        with allure.step('Checking msg'):
            allure.attach("Msg contains: " + str(constants.ERR_MSG_LONG_TOKEN), "Expected:")
            allure.attach("Msg: " + str(users_list_with_long_token.get_msg()), "Actual:")
            assert constants.ERR_MSG_LONG_TOKEN in users_list_with_long_token.get_msg()

        with allure.step('Checking Ret'):
            allure.attach("Ret: " + str(constants.RET_400), "Expected:")
            allure.attach("Ret: " + str(users_list_with_long_token.get_ret()), "Actual:")
            assert users_list_with_long_token.get_ret() == constants.RET_400
    def test_users_list_without_app_key(self):
        with allure.step("Send a get list request without app key"):
            users_list_without_app_key = SendRequest(UsersList.get_test_case("test_users_list_without_app_key"))

        with allure.step('Checking msg'):
            allure.attach("Msg contains: " + str(constants.ERR_MSG_WITHOUT_APP_KEY), "Expected:")
            allure.attach("Msg: " + str(users_list_without_app_key.get_msg()), "Actual:")
            assert constants.ERR_MSG_WITHOUT_APP_KEY in users_list_without_app_key.get_msg()

        with allure.step('Checking Ret'):
            allure.attach("Ret: " + str(constants.RET_400), "Expected:")
            allure.attach("Ret: " + str(users_list_without_app_key.get_ret()), "Actual:")
            assert users_list_without_app_key.get_ret() == constants.RET_400
Esempio n. 6
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
    def test_users_list_with_101_per_page(self):
        with allure.step("Send a get list request with 101 per page"):
            users_list_with_101_per_page = SendRequest(
                UsersList.get_test_case("test_users_list_with_101_per_page"))

        with allure.step('Checking msg'):
            allure.attach(
                "Msg: " + str(constants.ERR_MSG_USERS_LIST_101_PER_PAGE),
                "Expected:")
            allure.attach(
                "Msg: " + str(users_list_with_101_per_page.get_msg()),
                "Actual:")
            assert constants.ERR_MSG_USERS_LIST_101_PER_PAGE in users_list_with_101_per_page.get_msg(
            )

        with allure.step('Checking Ret'):
            allure.attach("Ret: " + str(constants.RET_400), "Expected:")
            allure.attach(
                "Ret: " + str(users_list_with_101_per_page.get_ret()),
                "Actual:")
            assert users_list_with_101_per_page.get_ret() == constants.RET_400
Esempio n. 8
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