Unit test user app

* adds unit test for User model and forms
* refactors functions from user_checks.py into User class and drops user_checks.py
This commit is contained in:
2023-09-13 09:49:40 +02:00
parent 19baf7ba86
commit 9117abd1d8
14 changed files with 263 additions and 70 deletions

View File

@@ -6,12 +6,12 @@ Created on: 08.09.23
"""
from django.test import RequestFactory
from django.utils.timezone import now
from intervention.forms.modals.share import ShareModalForm
from konova.models import DeadlineType
from konova.models import DeadlineType, Resubmission
from konova.settings import ZB_GROUP
from konova.tests.test_views import BaseTestCase
from konova.utils.user_checks import is_default_group_only
from user.models import UserAction
@@ -171,8 +171,8 @@ class ShareableObjectMixinTestCase(BaseTestCase):
self.intervention.share_with_user(self.user)
self.intervention.share_with_user(self.superuser)
self.assertTrue(is_default_group_only(self.user))
self.assertFalse(is_default_group_only(self.superuser))
self.assertTrue(self.user.is_default_group_only())
self.assertFalse(self.superuser.is_default_group_only())
self.assertTrue(self.intervention.is_shared_with(self.user))
self.assertTrue(self.intervention.is_shared_with(self.superuser))
@@ -180,3 +180,22 @@ class ShareableObjectMixinTestCase(BaseTestCase):
self.intervention.unshare_with_default_users()
self.assertFalse(self.intervention.is_shared_with(self.user))
self.assertTrue(self.intervention.is_shared_with(self.superuser))
class ResubmissionTestCase(BaseTestCase):
def test_send_resubmission_mail(self):
resubmission = Resubmission.objects.create(
user=self.user,
resubmit_on=now().date(),
comment="Test",
)
self.intervention.resubmissions.add(resubmission)
self.assertFalse(resubmission.resubmission_sent)
resubmission.send_resubmission_mail(
self.intervention.identifier,
[
"Test_municipal_1"
],
)
self.assertTrue(resubmission.resubmission_sent)