From c01d27e83698693baebdbb00b7d827f756fca33d Mon Sep 17 00:00:00 2001 From: Andreas Tolfsen <andretol@usit.uio.no> Date: Tue, 27 Jul 2021 15:16:30 +0200 Subject: [PATCH] greg.tests: convert Consent model tests to pytest Fixes: GREG-14 --- greg/tests/models/test_consent.py | 31 +++++++++++++++++++++++++++++++ greg/tests/test_models.py | 27 --------------------------- 2 files changed, 31 insertions(+), 27 deletions(-) create mode 100644 greg/tests/models/test_consent.py diff --git a/greg/tests/models/test_consent.py b/greg/tests/models/test_consent.py new file mode 100644 index 00000000..ad800bd5 --- /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 f7f1b8ed..98119db8 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"} - ) -- GitLab