diff --git a/greg/tests/models/test_consent.py b/greg/tests/models/test_consent.py new file mode 100644 index 0000000000000000000000000000000000000000..ad800bd596686e43520556a1acb2ec22aa2a76c6 --- /dev/null +++ b/greg/tests/models/test_consent.py @@ -0,0 +1,31 @@ +import pytest + +from greg.models import ( + Person, + Consent, +) + + +@pytest.fixture +def person() -> Person: + return Person.objects.create( + first_name="Test", + last_name="Tester", + date_of_birth="2000-01-27", + email="test@example.org", + mobile_phone="123456789", + ) + + +@pytest.mark.django_db +def test_add_consent_to_person(person): + consent = Consent.objects.create( + type="it_guidelines", + consent_name_en="IT Guidelines", + consent_name_nb="IT Regelverk", + consent_description_en="IT Guidelines description", + consent_description_nb="IT Regelverk beskrivelse", + consent_link_en="https://example.org/it_guidelines", + user_allowed_to_change=False, + ) + person.consents.add(consent, through_defaults={"consent_given_at": "2021-06-20"}) diff --git a/greg/tests/test_models.py b/greg/tests/test_models.py index f7f1b8edaadca09122b8426fc9d586a0ac8e4e79..98119db8940c0562832c913694ac8c4f77a76b01 100644 --- a/greg/tests/test_models.py +++ b/greg/tests/test_models.py @@ -1,11 +1,9 @@ from django.test import TestCase from greg.models import ( - Person, OrganizationalUnit, Sponsor, SponsorOrganizationalUnit, - Consent, ) @@ -64,28 +62,3 @@ class SponsorModelTests(TestCase): sponsors_for_unit2 = Sponsor.objects.filter(units=unit2.id) self.assertEqual(0, len(sponsors_for_unit2)) - - -class ConsentModelTest(TestCase): - def test_add_consent_to_person(self): - person = Person.objects.create( - first_name="Test", - last_name="Tester", - date_of_birth="2000-01-27", - email="test@example.org", - mobile_phone="123456789", - ) - - consent = Consent.objects.create( - type="it_guidelines", - consent_name_en="IT Guidelines", - consent_name_nb="IT Regelverk", - consent_description_en="IT Guidelines description", - consent_description_nb="IT Regelverk beskrivelse", - consent_link_en="https://example.org/it_guidelines", - user_allowed_to_change=False, - ) - - person.consents.add( - consent, through_defaults={"consent_given_at": "2021-06-20"} - )