Esempio n. 1
0
    def test_unknown_member(self, ctx,
                            mock_member_repository: MemberRepository,
                            member_manager: MemberManager):
        mock_member_repository.get_by_id = MagicMock(
            side_effect=MemberNotFoundError(""))

        with raises(MemberNotFoundError):
            member_manager.validate_subscription(ctx, 0, False)

        mock_member_repository.get_by_id.assert_called_once()
Esempio n. 2
0
    def test_unknown_membership(
            self, ctx, mock_membership_repository: MembershipRepository,
            mock_member_repository: MemberRepository, sample_member: Member,
            member_manager: MemberManager):
        mock_member_repository.get_by_id = MagicMock(
            return_value=(sample_member))
        mock_membership_repository.search = MagicMock(return_value=([], 0))

        with raises(MembershipNotFoundError):
            member_manager.validate_subscription(ctx, sample_member.id, False)

        mock_member_repository.get_by_id.assert_called_once()
        mock_membership_repository.search.assert_called_once()
Esempio n. 3
0
    def test_not_payment_validation(
            self, ctx, mock_membership_repository: MembershipRepository,
            mock_member_repository: MemberRepository, sample_member: Member,
            sample_membership_pending_payment: Membership,
            member_manager: MemberManager):
        mock_member_repository.get_by_id = MagicMock(
            return_value=(sample_member))
        mock_membership_repository.search = MagicMock(
            return_value=([sample_membership_pending_payment], 1))

        with raises(MembershipStatusNotAllowed):
            member_manager.validate_subscription(ctx, sample_member.id, False)

        mock_membership_repository.search.assert_called_once()
        mock_member_repository.get_by_id.assert_called_once()