Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
vidjil
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1,711
Issues
1,711
List
Boards
Labels
Service Desk
Milestones
Merge Requests
86
Merge Requests
86
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vidjil
vidjil
Commits
8ccbafdb
Commit
8ccbafdb
authored
Mar 11, 2015
by
Marc Duez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
server test: patient.py test file
parent
0f5beb65
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
141 additions
and
0 deletions
+141
-0
server/web2py/applications/vidjil/tests/controllers/patient.py
...r/web2py/applications/vidjil/tests/controllers/patient.py
+141
-0
No files found.
server/web2py/applications/vidjil/tests/controllers/patient.py
0 → 100644
View file @
8ccbafdb
#!/usr/bin/python
import
unittest
from
gluon.globals
import
Request
,
Session
,
Storage
,
Response
from
gluon.tools
import
Auth
from
gluon.contrib.test_helpers
import
form_postvars
from
gluon
import
current
class
PatientController
(
unittest
.
TestCase
):
def
__init__
(
self
,
p
):
global
auth
,
session
,
request
unittest
.
TestCase
.
__init__
(
self
,
p
)
def
setUp
(
self
):
# Load the to-be-tested file
execfile
(
"applications/vidjil/controllers/patient.py"
,
globals
())
# set up default session/request/auth/...
global
response
,
session
,
request
,
auth
session
=
Session
()
request
=
Request
({})
auth
=
Auth
(
globals
(),
db
)
auth
.
login_bare
(
"test@vidjil.org"
,
"1234"
)
# rewrite info / error functions
# for some reasons we lost them between the testRunner and the testCase but we need them to avoid error so ...
def
f
(
a
):
pass
log
.
info
=
f
log
.
error
=
f
log
.
debug
=
f
# for defs
current
.
db
=
db
current
.
auth
=
auth
def
testInfo
(
self
):
request
.
vars
[
"id"
]
=
fake_patient_id
resp
=
info
()
self
.
assertTrue
(
resp
.
has_key
(
'query'
),
"info() has returned an incomplete response"
)
def
testCustom
(
self
):
resp
=
custom
()
self
.
assertTrue
(
resp
.
has_key
(
'query'
),
"custom() has returned an incomplete response"
)
def
testIndex
(
self
):
resp
=
index
()
self
.
assertTrue
(
resp
.
has_key
(
'query'
),
"index() has returned an incomplete response"
)
def
testAdd
(
self
):
resp
=
add
()
self
.
assertTrue
(
resp
.
has_key
(
'message'
),
"add() has returned an incomplete response"
)
def
test1AddForm
(
self
):
request
.
vars
[
"first_name"
]
=
"bob"
request
.
vars
[
"last_name"
]
=
"bob"
request
.
vars
[
"birth"
]
=
"2011-11-11"
request
.
vars
[
"info"
]
=
"test patient kZtYnOipmAzZ"
request
.
vars
[
"id_label"
]
=
"bob"
resp
=
add_form
()
self
.
assertNotEqual
(
resp
.
find
(
'patient added'
),
-
1
,
"add patient failled"
)
def
testEdit
(
self
):
request
.
vars
[
"id"
]
=
fake_patient_id
resp
=
edit
()
self
.
assertTrue
(
resp
.
has_key
(
'message'
),
"edit() has returned an incomplete response"
)
def
testEditForm
(
self
):
request
.
vars
[
"id"
]
=
fake_patient_id
request
.
vars
[
"first_name"
]
=
"bab"
request
.
vars
[
"last_name"
]
=
"bab"
request
.
vars
[
"birth"
]
=
"2010-10-10"
request
.
vars
[
"info"
]
=
"bab"
request
.
vars
[
"id_label"
]
=
"bab"
resp
=
edit_form
()
self
.
assertNotEqual
(
resp
.
find
(
'patient bab bab edited'
),
-
1
,
"edit patient failled"
)
def
testConfirm
(
self
):
request
.
vars
[
"id"
]
=
fake_patient_id
resp
=
confirm
()
self
.
assertTrue
(
resp
.
has_key
(
'message'
),
"confirm() has returned an incomplete response"
)
def
test4Delete
(
self
):
patient_id
=
db
(
db
.
patient
.
info
==
"test patient kZtYnOipmAzZ"
).
select
()[
0
].
id
request
.
vars
[
"id"
]
=
patient_id
resp
=
delete
()
self
.
assertNotEqual
(
resp
.
find
(
'patient ('
+
str
(
patient_id
)
+
') deleted'
),
-
1
,
"delete patient failled"
)
def
test2Permission
(
self
):
patient_id
=
db
(
db
.
patient
.
info
==
"test patient kZtYnOipmAzZ"
).
select
()[
0
].
id
request
.
vars
[
"id"
]
=
patient_id
resp
=
permission
()
self
.
assertTrue
(
resp
.
has_key
(
'query'
),
"permission() has returned an incomplete response"
)
def
test3ChangePermission
(
self
):
patient_id
=
db
(
db
.
patient
.
info
==
"test patient kZtYnOipmAzZ"
).
select
()[
0
].
id
request
.
vars
[
"patient_id"
]
=
patient_id
request
.
vars
[
"group_id"
]
=
1
request
.
vars
[
"permission"
]
=
"popipo"
resp
=
change_permission
()
self
.
assertTrue
(
auth
.
has_permission
(
'popipo'
,
'patient'
,
patient_id
),
"fail to add permission"
)
resp
=
change_permission
()
self
.
assertFalse
(
auth
.
has_permission
(
'popipo'
,
'patient'
,
patient_id
),
"fail to remove permission"
)
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment