Example #1
0
 def test_payment_cached(self):
     mommy.make(
         "aklub.Payment",
         date="2015-05-15",
         amount=200,
         user_donor_payment_channel=self.dpch,
     )
     result = check_last_month_year_payment(self.user)
     self.assertTrue(result)
     self.assertTrue(cache.get(f"{self.user.id}_paid_section"))
Example #2
0
 def get(self, *args, **kwargs):  # noqa
     user = self.request.user
     found_payment = check_last_month_year_payment(user)
     if found_payment:
         try:
             pdf = PdfStorage.objects.get(id=self.kwargs["id"])
         except PdfStorage.DoesNotExist:
             raise PdfDoNotExist()
         return Response(self.serializer_class(pdf).data)
     else:
         raise HasNoPayment()
Example #3
0
 def test_payment_found_month(self):
     """
     Regular payment for last month accepted
     """
     mommy.make(
         "aklub.Payment",
         date="2015-04-15",
         amount=100,
         user_donor_payment_channel=self.dpch,
     )
     result = check_last_month_year_payment(self.user)
     self.assertTrue(result)
Example #4
0
 def test_paymend_expired_month(self):
     """
     Regular payment for last month expired
     """
     mommy.make(
         "aklub.Payment",
         date="2015-02-15",
         amount=200,
         user_donor_payment_channel=self.dpch,
     )
     result = check_last_month_year_payment(self.user)
     self.assertFalse(result)
Example #5
0
    def test_darujme_payment_not_done(self, mock_get):
        self._mock_darujme_url(mock_get)

        self.dpch.money_account = self.api
        self.dpch.save()

        mommy.make(
            "aklub.ProfileEmail",
            email="*****@*****.**",
            is_primary=True,
            user=self.user,
        )

        result = check_last_month_year_payment(self.user)
        self.assertFalse(result)
Example #6
0
    def test_darujme_found_payment(self, mock_get):
        self._mock_darujme_url(mock_get)

        self.dpch.money_account = self.api
        self.dpch.save()

        mommy.make(
            "aklub.ProfileEmail",
            email="*****@*****.**",
            is_primary=True,
            user=self.user,
        )

        result = check_last_month_year_payment(self.user)
        self.assertTrue(result)
        self.assertTrue(cache.get(f"{self.user.id}_paid_section"))
Example #7
0
 def test_paymend_expired_year(self):
     """
     Regular payment for last month accepted, but not enought and last payment for year expired
     """
     mommy.make(
         "aklub.Payment",
         date="2015-04-15",
         amount=50,
         user_donor_payment_channel=self.dpch,
     )
     mommy.make(
         "aklub.Payment",
         date="2012-04-15",
         amount=5000,
         user_donor_payment_channel=self.dpch,
     )
     result = check_last_month_year_payment(self.user)
     self.assertFalse(result)