Skip to content
Snippets Groups Projects
Commit c01d27e8 authored by Deaktivert bruker's avatar Deaktivert bruker
Browse files

greg.tests: convert Consent model tests to pytest

Fixes: GREG-14
parent 92ebee2c
No related branches found
No related tags found
1 merge request!11greg.tests: migrate to pytest test runner
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"})
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"}
)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment