Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
scheduling-system
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SMASCH
scheduling-system
Commits
e4f195ec
Commit
e4f195ec
authored
4 years ago
by
Carlos Vega
Browse files
Options
Downloads
Patches
Plain Diff
test confirmation of privacy notice
parent
c5d4164a
No related branches found
No related tags found
1 merge request
!276
Resolve "privacy notice and usage terms"
Pipeline
#34558
passed
4 years ago
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
smash/web/tests/view/test_privacy_notice.py
+70
-5
70 additions, 5 deletions
smash/web/tests/view/test_privacy_notice.py
with
70 additions
and
5 deletions
smash/web/tests/view/test_privacy_notice.py
+
70
−
5
View file @
e4f195ec
from
web.tests.functions
import
get_resource_path
from
web.tests.functions
import
get_resource_path
,
get_test_study
from
web.models
import
PrivacyNotice
from
web.models
import
PrivacyNotice
,
Study
,
Worker
from
web.forms
import
PrivacyNoticeForm
from
web.forms
import
PrivacyNoticeForm
,
WorkerAcceptPrivacyNoticeForm
from
web.tests
import
LoggedInTestCase
from
web.tests
import
LoggedInTestCase
from
django.urls
import
reverse
from
django.urls
import
reverse
from
django.core.files.uploadedfile
import
SimpleUploadedFile
from
django.core.files.uploadedfile
import
SimpleUploadedFile
from
django.contrib.messages
import
get_messages
from
web.models.constants
import
GLOBAL_STUDY_ID
class
PrivacyNoticeTests
(
LoggedInTestCase
):
class
PrivacyNoticeTests
(
LoggedInTestCase
):
def
test_add_privacy_notice
(
self
):
def
test_add_privacy_notice
(
self
):
...
@@ -45,7 +47,6 @@ class PrivacyNoticeTests(LoggedInTestCase):
...
@@ -45,7 +47,6 @@ class PrivacyNoticeTests(LoggedInTestCase):
page
=
reverse
(
'
web.views.privacy_notice_edit
'
,
kwargs
=
{
'
pk
'
:
pn
.
id
})
page
=
reverse
(
'
web.views.privacy_notice_edit
'
,
kwargs
=
{
'
pk
'
:
pn
.
id
})
response
=
self
.
client
.
post
(
page
,
data
=
{
**
form_data
,
**
file_data
})
response
=
self
.
client
.
post
(
page
,
data
=
{
**
form_data
,
**
file_data
})
print
(
response
)
self
.
assertEqual
(
response
.
status_code
,
302
)
self
.
assertEqual
(
response
.
status_code
,
302
)
pn
=
PrivacyNotice
.
objects
.
all
()[
0
]
pn
=
PrivacyNotice
.
objects
.
all
()[
0
]
self
.
assertEqual
(
pn
.
name
,
'
example2
'
)
self
.
assertEqual
(
pn
.
name
,
'
example2
'
)
...
@@ -58,4 +59,68 @@ class PrivacyNoticeTests(LoggedInTestCase):
...
@@ -58,4 +59,68 @@ class PrivacyNoticeTests(LoggedInTestCase):
response
=
self
.
client
.
post
(
page
)
response
=
self
.
client
.
post
(
page
)
self
.
assertEqual
(
response
.
status_code
,
302
)
self
.
assertEqual
(
response
.
status_code
,
302
)
self
.
assertEqual
(
0
,
PrivacyNotice
.
objects
.
count
())
self
.
assertEqual
(
0
,
PrivacyNotice
.
objects
.
count
())
\ No newline at end of file
def
test_privacy_notice_middleware_superuser
(
self
):
self
.
test_add_privacy_notice
()
self
.
login_as_admin
()
#assign privacy notice
pn
=
PrivacyNotice
.
objects
.
all
()[
0
]
study
=
Study
.
objects
.
filter
(
id
=
GLOBAL_STUDY_ID
)[
0
]
study
.
acceptance_of_study_privacy_notice_required
=
True
study
.
study_privacy_notice
=
pn
study
.
save
()
study
=
Study
.
objects
.
filter
(
id
=
GLOBAL_STUDY_ID
)[
0
]
self
.
assertEqual
(
study
.
acceptance_of_study_privacy_notice_required
,
True
)
self
.
assertEqual
(
study
.
study_privacy_notice
.
id
,
pn
.
id
)
self
.
login_as_super
()
self
.
assertEqual
(
self
.
staff_worker
.
privacy_notice_accepted
,
False
)
page
=
reverse
(
'
web.views.appointments
'
)
response
=
self
.
client
.
get
(
page
)
self
.
assertEqual
(
response
.
status_code
,
200
)
messages
=
list
(
get_messages
(
response
.
wsgi_request
))
self
.
assertEqual
(
len
(
messages
),
0
)
def
test_privacy_notice_middleware
(
self
):
self
.
test_add_privacy_notice
()
self
.
login_as_admin
()
#assign privacy notice
pn
=
PrivacyNotice
.
objects
.
all
()[
0
]
study
=
Study
.
objects
.
filter
(
id
=
GLOBAL_STUDY_ID
)[
0
]
study
.
acceptance_of_study_privacy_notice_required
=
True
study
.
study_privacy_notice
=
pn
study
.
save
()
study
=
Study
.
objects
.
filter
(
id
=
GLOBAL_STUDY_ID
)[
0
]
self
.
assertEqual
(
study
.
acceptance_of_study_privacy_notice_required
,
True
)
self
.
assertEqual
(
study
.
study_privacy_notice
.
id
,
pn
.
id
)
self
.
login_as_staff
()
self
.
assertEqual
(
self
.
staff_worker
.
privacy_notice_accepted
,
False
)
page
=
reverse
(
'
web.views.appointments
'
)
response
=
self
.
client
.
get
(
page
)
self
.
assertEqual
(
response
.
status_code
,
302
)
messages
=
list
(
get_messages
(
response
.
wsgi_request
))
self
.
assertEqual
(
len
(
messages
),
1
)
self
.
assertEqual
(
str
(
messages
[
0
]),
"
You can
'
t use the system until you accept the privacy notice.
"
)
#accept privacy notice
form_data
=
dict
(
privacy_notice_accepted
=
True
)
form
=
WorkerAcceptPrivacyNoticeForm
(
form_data
)
self
.
assertTrue
(
form
.
is_valid
())
page
=
reverse
(
'
web.views.accept_privacy_notice
'
,
kwargs
=
{
'
pk
'
:
pn
.
id
})
response
=
self
.
client
.
post
(
page
,
data
=
{
**
form_data
})
self
.
assertEqual
(
response
.
status_code
,
302
)
messages
=
[
m
.
message
for
m
in
get_messages
(
response
.
wsgi_request
)]
self
.
assertIn
(
"
Privacy notice accepted
"
,
messages
)
#check acceptance
worker
=
Worker
.
objects
.
filter
(
id
=
self
.
staff_worker
.
id
).
first
()
self
.
assertEqual
(
worker
.
privacy_notice_accepted
,
True
)
page
=
reverse
(
'
web.views.appointments
'
)
response
=
self
.
client
.
get
(
page
)
self
.
assertEqual
(
response
.
status_code
,
200
)
messages
=
list
(
get_messages
(
response
.
wsgi_request
))
worker
=
Worker
.
get_by_user
(
response
.
wsgi_request
.
user
)
self
.
assertEqual
(
worker
.
privacy_notice_accepted
,
True
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment