Beispiel #1
0
    def test_no_account_type_adherent(
            self, ctx, mock_member_repository: MemberRepository,
            mock_account_type_repository: AccountTypeRepository,
            member_manager: MemberManager):
        # Given...
        mock_member_repository.get_by_login = MagicMock(return_value=(None))
        mock_account_type_repository.search_by = MagicMock(return_value=([],
                                                                         0))

        # When...
        with pytest.raises(AccountTypeNotFoundError):
            member_manager.create(ctx, body=MemberBody(username="******", ))

        # Expect...
        mock_account_type_repository.search_by.assert_called_once_with(
            ctx, terms="Adhérent")
Beispiel #2
0
    def test_member_already_exist(self, ctx,
                                  mock_member_repository: MemberRepository,
                                  sample_member: AbstractMember,
                                  member_manager: MemberManager):
        # Given...
        mock_member_repository.get_by_login = MagicMock(
            return_value=(sample_member))

        # When...
        with pytest.raises(MemberAlreadyExist):
            member_manager.create(
                ctx, body=MemberBody(username=sample_member.username))

        # Expect...
        mock_member_repository.get_by_login.assert_called_once_with(
            ctx, sample_member.username)