Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
greg
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
it-bott-integrasjoner
greg
Merge requests
!292
Add tests of has_mandatory_consents property
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Add tests of has_mandatory_consents property
tests/mandatory_consents
into
master
Overview
0
Commits
1
Pipelines
2
Changes
1
Merged
Andreas Ellewsen
requested to merge
tests/mandatory_consents
into
master
3 years ago
Overview
0
Commits
1
Pipelines
2
Changes
1
Expand
0
0
Merge request reports
Viewing commit
3468e18e
Show latest version
1 file
+
50
−
0
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Verified
3468e18e
Add tests of has_mandatory_consents property
· 3468e18e
Andreas Ellewsen
authored
3 years ago
greg/tests/models/test_person.py
+
50
−
0
Options
@@ -5,6 +5,9 @@ import pytest
from
django.utils
import
timezone
from
greg.models
import
(
Consent
,
ConsentChoice
,
ConsentType
,
OrganizationalUnit
,
Person
,
Identity
,
@@ -190,3 +193,50 @@ def test_person_str(person: Person):
@pytest.mark.django_db
def
test_person_repr
(
person
:
Person
):
assert
repr
(
person
)
==
"
Person(id=1, first_name=
'
Test
'
, last_name=
'
Tester
'
)
"
@pytest.mark.django_db
def
test_person_has_mandatory_consents
(
person
):
"""
No consents exists.
Should return True
"""
assert
person
.
has_mandatory_consents
is
True
@pytest.mark.django_db
def
test_person_has_mandatory_consents_only_optional
(
person
):
"""
An optional consent exists, and the person has not given consent.
Should return True
"""
ConsentType
.
objects
.
create
(
user_allowed_to_change
=
True
)
assert
person
.
has_mandatory_consents
is
True
@pytest.mark.django_db
def
test_person_has_mandatory_consents_mandatory_exists
(
person
):
"""
A mandatory consent exists, and the person has not given it.
Should return False
"""
ConsentType
.
objects
.
create
(
user_allowed_to_change
=
True
,
mandatory
=
True
)
assert
person
.
has_mandatory_consents
is
False
@pytest.mark.django_db
def
test_person_has_mandatory_consents_mandatory_given
(
person
):
"""
A mandatory consent exists, and the person has given it.
Should return True
"""
ct
=
ConsentType
.
objects
.
create
(
user_allowed_to_change
=
True
,
mandatory
=
True
)
cc
=
ConsentChoice
.
objects
.
create
(
consent_type
=
ct
)
Consent
.
objects
.
create
(
person
=
person
,
type
=
ct
,
choice
=
cc
,
consent_given_at
=
timezone
.
now
()
)
assert
person
.
has_mandatory_consents
is
True
Loading