Example #1
0
    def test_not_found(self, ctx, sample_member,
                       mock_member_repository: MemberRepository,
                       member_manager: MemberManager):
        # Given...
        mock_member_repository.get_by_id = MagicMock(
            return_value=(None), side_effect=MemberNotFoundError(""))

        # When...
        with raises(MemberNotFoundError):
            member_manager.get_by_id(ctx, id=sample_member.id)

        # Expect...
        mock_member_repository.get_by_id.assert_called_once_with(
            ctx, sample_member.id)
Example #2
0
    def test_happy_path(self, ctx, mock_member_repository: MemberRepository,
                        mock_membership_repository: MembershipRepository,
                        sample_member: Member, member_manager: MemberManager):
        # Given...
        mock_member_repository.get_by_id = MagicMock(
            return_value=(sample_member))
        mock_membership_repository.search = MagicMock(return_value=([], 0))

        # When...
        result = member_manager.get_by_id(ctx, id=sample_member.id)

        # Expect...
        assert sample_member == result
        mock_member_repository.get_by_id.assert_called_once_with(
            ctx, sample_member.id)