def test_get_upi_id_response():

    # Arrrange
    upi_id = "123456890@SBI"
    expected_upi_id_dict = {"upi_id": upi_id}
    storage = UserPresenterImplementation()

    # Act
    actual_upi_id_dict = storage.get_upi_id_response(upi_id=upi_id)

    # Assert
    assert actual_upi_id_dict == expected_upi_id_dict
Exemplo n.º 2
0
def test_raise_transaction_id_already_exists_exception():

    # Arrange
    exception_messages = TRANSACTION_ID_ALREADY_EXISTS[0]
    exception_res_status = TRANSACTION_ID_ALREADY_EXISTS[1]
    presenter = UserPresenterImplementation()

    # Act
    with pytest.raises(NotFound) as exception:
        presenter.raise_transaction_id_already_exist_exception()

    # Assert
    assert exception.value.message == exception_messages
    assert exception.value.res_status == exception_res_status
Exemplo n.º 3
0
def test_raise_invalid_payment_exception():

    # Arrange
    exception_message = INVALID_PAYMENT[0]
    exception_res_status = INVALID_PAYMENT[1]
    user_presenter = UserPresenterImplementation()

    # Act
    with pytest.raises(NotFound) as exception:
        user_presenter.raise_invalid_payment_exception()

    # Assert
    assert exception.value.message == exception_message
    assert exception.value.res_status == exception_res_status
Exemplo n.º 4
0
def test_raise_username_already_exists_exception():

    # Arrange
    exception_message = USERNAME_ARLEADY_EXISTS[0]
    exception_res_status = USERNAME_ARLEADY_EXISTS[1]
    user_presenter = UserPresenterImplementation()

    # Act
    with pytest.raises(Forbidden) as exception:
        user_presenter.raise_username_already_exists_exception()

    # Assert
    assert exception.value.message == exception_message
    assert exception.value.res_status == exception_res_status
def test_get_user_transactions_interactor(
        get_user_transaction_dto_and_expected_dict):

    # Arrange
    my_wallet_dto = get_user_transaction_dto_and_expected_dict[0]
    expected_dict = get_user_transaction_dto_and_expected_dict[1]
    presenter = UserPresenterImplementation()

    # Act
    actual_dict = presenter.get_user_transactions_response(
        my_wallet_dto=my_wallet_dto)

    # Assert
    assert actual_dict == expected_dict
def test_invalid_user_name_exception():

    # Arrange
    exception_message = INVALID_USER_NAME[0]
    exception_res_status = INVALID_USER_NAME[1]
    user_presenter = UserPresenterImplementation()

    # Act
    with pytest.raises(NotFound) as exception:
        user_presenter.raise_invalid_username_exception()

    # Assert
    assert exception.value.message == exception_message
    assert exception.value.res_status == exception_res_status
def api_wrapper(*args, **kwargs):

    user_storage = UserStorageImplementation()
    user_presenter = UserPresenterImplementation()
    interactor = GetAdminAccountDetailsInteractor(
        user_storage=user_storage, user_presenter=user_presenter)

    upi_id_dict = interactor.get_admin_account_details()

    upi_id_dict_json = json.dumps(upi_id_dict)
    response_data = HttpResponse(upi_id_dict_json, status=200)

    return response_data
def test_get_access_token_response_with_valid_details_return_dto():

    # Arrange
    access_token_dto = UserAuthTokensDTO(user_id=1,
                                         access_token="QTRTUGFTTTBBBBNS1334",
                                         refresh_token="WQEDRTT#$%^REDET",
                                         expires_in=datetime.datetime(
                                             2020, 10, 10, 0, 0, 0))
    expected_access_token_dict = {
        "user_id": 1,
        "access_token": "QTRTUGFTTTBBBBNS1334",
        "refresh_token": "WQEDRTT#$%^REDET",
        "expires_in": "2020-10-10 00:00:00.000000"
    }
    user_presenter = UserPresenterImplementation()

    # Act
    actual_access_token_dict = user_presenter.get_access_token_response(
        access_token_dto)

    # Assert
    assert actual_access_token_dict == expected_access_token_dict
Exemplo n.º 9
0
def api_wrapper(*args, **kwargs):

    user = kwargs["user"]
    user_id = user.id
    transaction_dict = kwargs["request_data"]

    user_storage = UserStorageImplementation()
    user_presenter = UserPresenterImplementation()
    interactor = CreateTransactionRequestInteractor(
        user_storage=user_storage, user_presenter=user_presenter)

    interactor.create_transaction_request(user_id=user_id,
                                          transaction_dict=transaction_dict)

    response_data = HttpResponse(status=201)
    return response_data
def api_wrapper(*args, **kwargs):

    user = kwargs["user"]
    user_id = user.id

    user_storage = UserStorageImplementation()
    user_presenter = UserPresenterImplementation()
    interactor = GetUserTransactionsInteractor(user_storage=user_storage,
                                               user_presenter=user_presenter)

    transaction_details_dict = interactor.get_user_transactions(
        user_id=user_id)

    transaction_details_dict_json = json.dumps(transaction_details_dict)
    response_data = HttpResponse(transaction_details_dict_json, status=200)

    return response_data
def api_wrapper(*args, **kwargs):

    request_data = kwargs["request_data"]
    username = request_data["username"]
    password = request_data["password"]

    user_storage = UserStorageImplementation()
    user_presenter =  UserPresenterImplementation()
    oauth2_storage = OAuth2SQLStorage()
    interactor = UserLoginInteractor(user_storage=user_storage,
                                     user_presenter=user_presenter,
                                     oauth2_storage=oauth2_storage)

    access_token_dict = interactor.user_login(username=username,
                                              password=password)

    access_token_dict_json = json.dumps(access_token_dict)

    response = HttpResponse(access_token_dict_json, status=200)
    return response
Exemplo n.º 12
0
def api_wrapper(*args, **kwargs):

    request_data = kwargs["request_data"]
    name = request_data["name"]
    username = request_data["username"]
    password = request_data["password"]

    user_storage = UserStorageImplementation()
    user_presenter = UserPresenterImplementation()
    oauth2_storage = OAuth2SQLStorage()
    interactor = CreateUserSignUpInteractor(user_storage=user_storage,
                                            user_presenter=user_presenter,
                                            oauth2_storage=oauth2_storage)

    access_tocken_dict = interactor.create_signup(name=name,
                                                  username=username,
                                                  password=password)

    access_tocken_dict_json = json.dumps(access_tocken_dict)
    response_data = HttpResponse(access_tocken_dict_json, status=201)

    return response_data