コード例 #1
0
ファイル: api_wrapper.py プロジェクト: pavan1296/lets_ride
def api_wrapper(*args, **kwargs):
    user = kwargs['user']
    credentials = kwargs['request_data']

    phone_number = dict(credentials)['phone_number']
    password = dict(credentials)['password']

    storage = StorageImplementation()
    presenter = PresenterImplementation()
    oauth2_storage = OAuth2SQLStorage()
    interactor = UserLoginInteractor(storage=storage,
                                     presenter=presenter,
                                     oauth2_storage=oauth2_storage)
    response_data = interactor.login_validation(phone_number=phone_number,
                                                password=password)

    return response_data
コード例 #2
0
def test_user_login_details_with_phone_number_less_than_ten_chars_raises_exception(
        invalid_phone_number_fixture):
    phone_number = "87456321077"
    password = "******"
    storage = create_autospec(StorageInterface)
    presenter = create_autospec(PresenterInterface)
    oauth2_storage = create_autospec(OAuthUserAuthTokensService)
    token_service = create_autospec(OAuthUserAuthTokensService)
    interactor = UserLoginInteractor(storage=storage,
                                     presenter=presenter,
                                     oauth2_storage=oauth2_storage)
    expected_output = invalid_phone_number_fixture
    presenter.raise_exception_for_invalid_phone_number.return_value = invalid_phone_number_fixture
    # Act
    actual_output = interactor.login_validation(phone_number=phone_number,
                                                password=password)
    #Assert
    presenter.raise_exception_for_invalid_phone_number.assert_called_once()
    assert actual_output == expected_output
コード例 #3
0
def test_user_login_details_with_invalid_password_given_return_response(
        user_does_not_exist_fixture):
    phone_number = "7799888142"
    password = "******"
    storage = create_autospec(StorageInterface)
    presenter = create_autospec(PresenterInterface)
    oauth2_storage = create_autospec(OAuthUserAuthTokensService)
    token_service = create_autospec(OAuthUserAuthTokensService)
    interactor = UserLoginInteractor(storage=storage,
                                     presenter=presenter,
                                     oauth2_storage=oauth2_storage)
    expected_output = user_does_not_exist_fixture
    storage.check_phone_number_and_password_exists_in_user.side_effect = UserDoesNotExist
    presenter.raise_exception_for_user_does_not_exist.return_value = user_does_not_exist_fixture
    # Act
    actual_output = interactor.login_validation(phone_number=phone_number,
                                                password=password)
    #Assert
    presenter.raise_exception_for_user_does_not_exist.assert_called_once()
    assert actual_output == expected_output
コード例 #4
0
def test_user_login_details_return_access_token(access_token_mock,
                                                get_access_token_dto_fixture,
                                                user_access_token_dto_fixture):
    #Arrange
    user_id = 1
    phone_number = "8745632100"
    password = "******"
    storage = create_autospec(StorageInterface)
    presenter = create_autospec(PresenterInterface)
    oauth2_storage = create_autospec(OAuthUserAuthTokensService)
    token_service = create_autospec(OAuthUserAuthTokensService)
    interactor = UserLoginInteractor(storage=storage,
                                     presenter=presenter,
                                     oauth2_storage=oauth2_storage)
    access_token = user_access_token_dto_fixture
    access_token_mock.return_value = get_access_token_dto_fixture
    storage.check_phone_number_and_password_exists_in_user.return_value = user_id
    #Act
    interactor.login_validation(phone_number=phone_number, password=password)
    #Assert
    presenter.user_access_token.assert_called_once_with(
        access_token=access_token)