|
1
|
|
|
import logging |
|
|
|
|
|
|
2
|
|
|
from LORIS.candidates import LORIS_candidates |
|
|
|
|
|
|
3
|
|
|
from LORIS.query import LORIS_query |
|
|
|
|
|
|
4
|
|
|
import unittest |
|
|
|
|
|
|
5
|
|
|
|
|
6
|
|
|
class UT_LORISCandidates(unittest.TestCase): |
|
|
|
|
|
|
7
|
|
|
|
|
8
|
|
|
""" |
|
9
|
|
|
def test_create_subject(): |
|
10
|
|
|
logger = logging.getLogger('UT_LORIS_create_subject_check') |
|
11
|
|
|
response_success, token = LORIS_query.login() |
|
12
|
|
|
|
|
13
|
|
|
if not response_success: |
|
14
|
|
|
raise ConnectionError |
|
15
|
|
|
|
|
16
|
|
|
PSCID = "CNBP8881234" |
|
17
|
|
|
|
|
18
|
|
|
success, DCCID = LORIS_candidates.createCandidateCNBP(token, PSCID) |
|
19
|
|
|
|
|
20
|
|
|
LORIS_candidates.deleteCandidateCNBP(token, DCCID, PSCID) |
|
21
|
|
|
logger.info("UT_LORIS_create_subject_check PASSED") |
|
22
|
|
|
|
|
23
|
|
|
|
|
24
|
|
|
def test_delete_subjects(): |
|
25
|
|
|
logger = logging.getLogger('UT_LORIS_create_subject_check') |
|
26
|
|
|
response_success, token = LORIS_query.login() |
|
27
|
|
|
|
|
28
|
|
|
DCCID = "881417" |
|
29
|
|
|
PSCID = "CNBP9991234" |
|
30
|
|
|
# one time runnable code: |
|
31
|
|
|
LORIS_candidates.deleteCandidateCNBP(token, DCCID, PSCID) |
|
32
|
|
|
logger.info("UT_LORIS_create_subject_check PASSED") |
|
33
|
|
|
""" |
|
34
|
|
|
|
|
35
|
|
|
@staticmethod |
|
36
|
|
|
def test_check_projectID(): |
|
|
|
|
|
|
37
|
|
|
ProjectID = "GL01" |
|
|
|
|
|
|
38
|
|
|
assert LORIS_candidates.check_projectID_compliance(ProjectID) |
|
39
|
|
|
|
|
40
|
|
|
ProjectID = "GL09" |
|
|
|
|
|
|
41
|
|
|
assert not LORIS_candidates.check_projectID_compliance(ProjectID) |
|
42
|
|
|
|
|
43
|
|
|
ProjectID = "AL01" |
|
|
|
|
|
|
44
|
|
|
assert not LORIS_candidates.check_projectID_compliance(ProjectID) |
|
45
|
|
|
|
|
46
|
|
|
ProjectID = "AB01" |
|
|
|
|
|
|
47
|
|
|
assert LORIS_candidates.check_projectID_compliance(ProjectID) |
|
48
|
|
|
|
|
49
|
|
|
@staticmethod |
|
50
|
|
|
def test_CNBP_PSCID(): |
|
|
|
|
|
|
51
|
|
|
PSCID = "VXS" + "GL01" + "0001" |
|
|
|
|
|
|
52
|
|
|
PSCID1 = "VXa" + "GL01" + "0001" |
|
|
|
|
|
|
53
|
|
|
PSCID2 = "VXS" + "GL02" + "0001" |
|
|
|
|
|
|
54
|
|
|
PSCID3 = "VXS" + "GL01" + "0001" |
|
|
|
|
|
|
55
|
|
|
PSCID4 = "VXS" + "GL01" + "0009" |
|
|
|
|
|
|
56
|
|
|
|
|
57
|
|
|
assert(LORIS_candidates.check_PSCID_compliance(PSCID)) |
|
|
|
|
|
|
58
|
|
|
assert not LORIS_candidates.check_PSCID_compliance(PSCID1) |
|
59
|
|
|
assert not LORIS_candidates.check_PSCID_compliance(PSCID2) |
|
60
|
|
|
assert LORIS_candidates.check_PSCID_compliance(PSCID3) |
|
61
|
|
|
assert LORIS_candidates.check_PSCID_compliance(PSCID4) |
|
62
|
|
|
|
|
63
|
|
|
if __name__ == "__main__": |
|
64
|
|
|
UT_LORISCandidates.test_CNBP_PSCID() |
|
|
|
|
|
The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:
If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.