From 303eee124f566a3d4e8ce119dc0034fc28770509 Mon Sep 17 00:00:00 2001 From: KlemenSpruk Date: Tue, 17 Oct 2023 08:56:38 +0200 Subject: [PATCH] =?UTF-8?q?#792=20View=20license=20=C5=A1e=20vedno=20ka?= =?UTF-8?q?=C5=BEe=20vpla=C4=8Dano=20licenco,=20ne=20preostale=20(#147)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * addes todos * test for remaining license --- .../tests/api/test_remainig_license.py | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 django_project_base/notifications/tests/api/test_remainig_license.py diff --git a/django_project_base/notifications/tests/api/test_remainig_license.py b/django_project_base/notifications/tests/api/test_remainig_license.py new file mode 100644 index 00000000..d9ba9120 --- /dev/null +++ b/django_project_base/notifications/tests/api/test_remainig_license.py @@ -0,0 +1,21 @@ +from django.contrib.contenttypes.models import ContentType + +from django_project_base.licensing.logic import LogAccessService, MONTHLY_ACCESS_LIMIT_IN_CURRENCY_UNITS +from django_project_base.licensing.models import LicenseAccessUse +from django_project_base.notifications.tests.notifications_transaction_test_case import NotificationsTransactionTestCase + + +class TestRemainingLicense(NotificationsTransactionTestCase): + def test_remaining_license(self): + used_amount = 10 + mail = self.create_notification_email_object().send() + LicenseAccessUse.objects.create( + type=LicenseAccessUse.UseType.USE, + user_id=str(self.test_user.pk), + content_type_object_id=str(mail.pk), + content_type=ContentType.objects.get_for_model(mail._meta.model), + amount=used_amount, + comment=dict(comment="", count=10, item_price=1, sender=""), + ) + usage = LogAccessService().report(user=self.test_user) + self.assertEqual(MONTHLY_ACCESS_LIMIT_IN_CURRENCY_UNITS - used_amount, usage["remaining_credit"])