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
5b3cd420
Commit
5b3cd420
authored
6 years ago
by
Carlos Vega
Browse files
Options
Downloads
Patches
Plain Diff
fixed tests
parent
9bb11e41
No related branches found
No related tags found
1 merge request
!192
Feature/add way to change password and PERMISSIONS
Pipeline
#7554
passed
6 years ago
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
smash/web/tests/__init__.py
+12
-1
12 additions, 1 deletion
smash/web/tests/__init__.py
smash/web/tests/view/test_configuration.py
+11
-0
11 additions, 0 deletions
smash/web/tests/view/test_configuration.py
smash/web/tests/view/test_worker.py
+4
-13
4 additions, 13 deletions
smash/web/tests/view/test_worker.py
with
27 additions
and
14 deletions
smash/web/tests/__init__.py
+
12
−
1
View file @
5b3cd420
...
...
@@ -4,8 +4,10 @@ from django.conf import settings
from
django.contrib.auth.models
import
User
from
django.test
import
Client
from
django.test
import
TestCase
from
web.models
import
Worker
from
web.decorators
import
PermissionDecorator
from
functions
import
create_worker
from
functions
import
create_worker
,
create_user
,
add_permissions_to_worker
settings
.
MEDIA_ROOT
=
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)),
'
data
'
)
...
...
@@ -14,6 +16,15 @@ logger = logging.getLogger(__name__)
class
LoggedInTestCase
(
TestCase
):
def
setUp
(
self
):
self
.
password
=
'
abcd1234
'
#superuser
self
.
super_worker
=
create_worker
(
user
=
User
.
objects
.
create_superuser
(
username
=
'
super
'
,
password
=
self
.
password
,
email
=
'
a@mail.com
'
))
#admin
self
.
admin_worker
=
Worker
.
get_by_user
(
create_user
(
username
=
'
admin
'
,
password
=
self
.
password
))
add_permissions_to_worker
(
self
.
admin_worker
,
PermissionDecorator
.
codenames
)
#staff
self
.
staff_worker
=
Worker
.
get_by_user
(
create_user
(
username
=
'
staff
'
,
password
=
self
.
password
))
self
.
client
=
Client
()
username
=
'
piotr
'
password
=
'
top_secret
'
...
...
This diff is collapsed.
Click to expand it.
smash/web/tests/view/test_configuration.py
+
11
−
0
View file @
5b3cd420
...
...
@@ -2,8 +2,19 @@ from django.urls import reverse
from
web.tests
import
LoggedInTestCase
import
logging
logger
=
logging
.
getLogger
(
__name__
)
class
ConfigurationViewTests
(
LoggedInTestCase
):
def
test_visit_details_request
(
self
):
self
.
client
.
logout
()
self
.
client
.
login
(
username
=
'
admin
'
,
password
=
self
.
password
)
response
=
self
.
client
.
get
(
reverse
(
'
web.views.configuration
'
))
self
.
assertEqual
(
response
.
status_code
,
200
)
def
test_visit_details_request_without_permissions
(
self
):
self
.
client
.
logout
()
self
.
client
.
login
(
username
=
'
staff
'
,
password
=
self
.
password
)
response
=
self
.
client
.
get
(
reverse
(
'
web.views.configuration
'
))
self
.
assertEqual
(
response
.
status_code
,
302
)
This diff is collapsed.
Click to expand it.
smash/web/tests/view/test_worker.py
+
4
−
13
View file @
5b3cd420
...
...
@@ -7,7 +7,7 @@ from web.forms import WorkerForm
from
web.models
import
Worker
from
web.models.worker_study_role
import
WORKER_STAFF
,
ROLE_CHOICES_DOCTOR
,
WORKER_HEALTH_PARTNER
,
WORKER_VOUCHER_PARTNER
from
web.tests
import
create_worker
from
web.tests.functions
import
add_permissions_to_worker
,
create_user
,
create_language
,
create_location
,
create_availability
,
format_form_field
from
web.tests.functions
import
create_user
,
create_language
,
create_location
,
create_availability
,
format_form_field
from
..
import
LoggedInTestCase
from
web.models.constants
import
GLOBAL_STUDY_ID
...
...
@@ -15,16 +15,6 @@ logger = logging.getLogger(__name__)
class
WorkerViewTests
(
LoggedInTestCase
):
def
setUp
(
self
):
self
.
password
=
'
abcd1234
'
#superuser
self
.
super_worker
=
create_worker
(
user
=
User
.
objects
.
create_superuser
(
username
=
'
super
'
,
password
=
self
.
password
,
email
=
'
a@mail.com
'
))
#admin
self
.
admin_worker
=
Worker
.
get_by_user
(
create_user
(
username
=
'
admin
'
,
password
=
self
.
password
))
add_permissions_to_worker
(
self
.
admin_worker
,
[
'
change_worker
'
,
'
add_worker
'
])
#staff
self
.
staff_worker
=
Worker
.
get_by_user
(
create_user
(
username
=
'
staff
'
,
password
=
self
.
password
))
def
test_render_workers_list_request
(
self
):
self
.
client
.
logout
()
self
.
client
.
login
(
username
=
'
staff
'
,
password
=
self
.
password
)
...
...
@@ -66,7 +56,8 @@ class WorkerViewTests(LoggedInTestCase):
self
.
assertEqual
(
response
.
status_code
,
200
)
def
test_render_worker_added_request
(
self
):
self
.
assertEqual
(
3
,
User
.
objects
.
all
().
count
())
self
.
assertEqual
(
3
,
Worker
.
objects
.
all
().
count
())
self
.
assertEqual
(
4
,
User
.
objects
.
all
().
count
())
self
.
client
.
logout
()
self
.
client
.
login
(
username
=
'
admin
'
,
password
=
self
.
password
)
...
...
@@ -82,7 +73,7 @@ class WorkerViewTests(LoggedInTestCase):
self
.
assertEqual
(
response
.
status_code
,
302
)
self
.
assertEqual
(
4
,
Worker
.
objects
.
all
().
count
())
self
.
assertEqual
(
4
,
User
.
objects
.
all
().
count
())
self
.
assertEqual
(
5
,
User
.
objects
.
all
().
count
())
def
create_add_worker_form_data
(
self
,
language
,
location
):
form_data
=
self
.
get_form_data
(
Worker
())
...
...
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