Esempio n. 1
0
 def setup(self) -> None:
     self._mock_user_repository = mock(
         UserRepository,
         ['find_email_and_refresh_token', 'save_and_publish'])
     self._mock_user_notifier = mock(UserNotifier,
                                     ['notify_user_password_resetted'])
     self._sut = UserPasswordResetterService(self._mock_user_repository,
                                             self._mock_user_notifier)
Esempio n. 2
0
 def setup(self) -> None:
     self._mock_auth_repository = mock(AuthRepository, ['find'])
     self._mock_token_factory = mock(TokenFactory, ['generate'])
     self._expiration_days = 14
     self._token_type = 'Bearer'
     self._sut = TokenGeneratorService(
         self._mock_auth_repository,
         self._mock_token_factory,
         self._expiration_days,
         self._token_type,
     )
Esempio n. 3
0
async def test_event_publishers() -> None:
    event_publisher_mock1 = mock(EventPublisher, ['publish'])
    event_publisher_mock2 = mock(EventPublisher, ['publish'])
    event_publisher_mock3 = mock(EventPublisher, ['publish'])

    event_publisher_mock1.publish.return_value = None
    event_publisher_mock2.publish.return_value = None
    event_publisher_mock3.publish.return_value = None

    publisher = EventPublishers(publishers=[event_publisher_mock1])
    publisher.add(publishers=event_publisher_mock2)
    publisher.add(publishers=[event_publisher_mock3])

    await publisher.publish(events=[mock(Event)])

    event_publisher_mock1.publish.assert_called_once()
    event_publisher_mock2.publish.assert_called_once()
    event_publisher_mock3.publish.assert_called_once()
Esempio n. 4
0
 def setup(self) -> None:
     self._mock_command_bus = mock(CommandBus, ['dispatch'])
     self._sut = NotifyUserRegisteredOnUserRegisteredEventHandler(
         self._mock_command_bus)
     self._kwargs = {
         'events': [
             UserRegistered(
                 UserRegistered.Attributes(
                     UserIdMother.random(),
                     UserEmailMother.random(),
                 )),
         ],
     }
Esempio n. 5
0
async def test_internal_event_publisher() -> None:
    event_bus_mock = mock(EventBus, ['notify'])

    class _EventTest(Event):
        pass

    event = _EventTest()

    event_bus_mock.notify.return_value = None

    publisher = InternalEventPublisher(event_bus=event_bus_mock)

    await publisher.publish(events=[event])

    event_bus_mock.notify.assert_called_once()
 def setup(self) -> None:
     self._mock_user_repository = mock(UserRepository, ['find_email', 'save_and_publish'])
     self._mock_user_notifier = mock(UserNotifier, ['notify_user_password_forgotten'])
     self._sut = UserPasswordForgetService(self._mock_user_repository, self._mock_user_notifier)
 def setup(self) -> None:
     self._mock_token_factory = mock(TokenFactory, ['read'])
     self._sut = AuthenticatorService(self._mock_token_factory)
 def setup(self) -> None:
     self._mock_user_repository = mock(UserRepository, ['find', 'delete_and_publish'])
     self._sut = UserDeleterService(self._mock_user_repository)
Esempio n. 9
0
 def setup(self) -> None:
     self._mock_user_repository = mock(UserRepository, ['find_all'])
     self._sut = UsersFinderService(self._mock_user_repository)
 def setup(self) -> None:
     self._mock_user_repository = mock(UserRepository, ['find', 'save_and_publish'])
     self._sut = UserPasswordChangerService(self._mock_user_repository)
Esempio n. 11
0
 def setup(self) -> None:
     self._mock_user_repository = mock(UserRepository,
                                       ['search', 'save_and_publish'])
     self._sut = UserRegisterService(self._mock_user_repository)