-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#792 View license še vedno kaže vplačano licenco, ne preostale (#147)
* addes todos * test for remaining license
- Loading branch information
1 parent
26b2973
commit 303eee1
Showing
1 changed file
with
21 additions
and
0 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
django_project_base/notifications/tests/api/test_remainig_license.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"]) |