def test_phone_number_is_invalid_raises_exception():
    # Arrange
    storage = StorageImplementation()
    phone_number = "7799888142"
    #Act
    with pytest.raises(UserDoesNotExist) as err:
        storage.check_phone_number_exists_in_user(phone_number=phone_number)
示例#2
0
def test_user_profile_with_invalid_user_id_raises_exception():
    #Arrange
    user_ids = [7]
    length = 0
    storage = StorageImplementation()
    #Act
    actual_output = storage.check_user_id_exists_in_user_model(
        user_ids=user_ids)
    assert actual_output == length
def test_user_login_details_return_user_id(user):
    #Arrange
    storage = StorageImplementation()
    expected_output = 1
    phone_number = user.phone_number
    password = '******'
    #Act
    actual_ouptput = storage.check_phone_number_and_password_exists_in_user(
        phone_number=phone_number, password=password)
    #Assert
    assert actual_ouptput == expected_output
示例#4
0
def test_user_profile_with_valid_details_returns_user_dto(user):
    #Arrange
    storage = StorageImplementation()
    user_ids = [1]
    #Act
    actual_output = storage.get_user_profile_dto(user_ids=user_ids)
    #Assert
    assert actual_output[0].username == user.username
    assert actual_output[0].phone_number == user.phone_number
    assert actual_output[0].email == user.email
    assert actual_output[0].gender == user.gender
示例#5
0
    def get_user_details(self, user_ids: List[int]):
        from auth_user.interactors.user_profile_interactor import UserProfileInteractor
        from auth_user.presenters.presenter_implementation import PresenterImplementation
        from auth_user.storages.storage_implementation import StorageImplementation

        interactor = UserProfileInteractor(storage=StorageImplementation(),
                                           presenter=PresenterImplementation())
        return interactor.get_user_dtos(user_ids=user_ids)
示例#6
0
def api_wrapper(*args, **kwargs):
    user = kwargs['user']
    user_id = [user.id]

    storage = StorageImplementation()
    presenter = PresenterImplementation()

    interactor = UserProfileInteractor(storage=storage, presenter=presenter)

    response = interactor.get_user_profile(user_ids=user_id)
    return response
示例#7
0
    def get_user_dto(user_ids: List[int]) -> UserProfileDTO:
        from auth_user.storages.storage_implementation import \
            StorageImplementation
        from auth_user.presenters.presenter_implementation import \
            PresenterImplementation
        storage = StorageImplementation()
        presenter = PresenterImplementation()

        from auth_user.interactors.user_profile_interactor import \
            UserProfileInteractor
        interactor = UserProfileInteractor(storage=storage,
                                           presenter=presenter)

        user_dtos = interactor.get_user_dtos(user_ids=user_ids)
        return user_dtos
示例#8
0
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