|
1
|
|
|
import logging |
|
|
|
|
|
|
2
|
|
|
from LORIS.candidates import LORIS_candidates |
|
|
|
|
|
|
3
|
|
|
from LORIS.query import LORIS_query |
|
|
|
|
|
|
4
|
|
|
import unittest |
|
|
|
|
|
|
5
|
|
|
import sys |
|
|
|
|
|
|
6
|
|
|
|
|
7
|
|
|
logging.basicConfig(stream=sys.stdout, level=logging.INFO) |
|
8
|
|
|
logger = logging.getLogger(__name__) |
|
|
|
|
|
|
9
|
|
|
|
|
10
|
|
|
class UT_LORISCandidates(unittest.TestCase): |
|
|
|
|
|
|
11
|
|
|
|
|
12
|
|
|
@staticmethod |
|
13
|
|
|
def test_create_delete_subject(): |
|
14
|
|
|
""" |
|
15
|
|
|
Check both the creation and deletion of the subject for LORIS. |
|
16
|
|
|
:return: |
|
17
|
|
|
""" |
|
18
|
|
|
|
|
19
|
|
|
response_success, token = LORIS_query.login() |
|
20
|
|
|
|
|
21
|
|
|
if not response_success: |
|
22
|
|
|
raise ConnectionError |
|
23
|
|
|
|
|
24
|
|
|
# Example PSCI ID. |
|
25
|
|
|
PSCID = "CNBP9990987" |
|
|
|
|
|
|
26
|
|
|
|
|
27
|
|
|
success, DCCID = LORIS_candidates.createCandidateCNBP(token, PSCID) |
|
|
|
|
|
|
28
|
|
|
assert success |
|
29
|
|
|
LORIS_candidates.deleteCandidateCNBP(DCCID, PSCID) |
|
30
|
|
|
|
|
31
|
|
|
@staticmethod |
|
32
|
|
|
def test_check_projectID(): |
|
|
|
|
|
|
33
|
|
|
ProjectID = "GL01" |
|
|
|
|
|
|
34
|
|
|
assert LORIS_candidates.check_projectID_compliance(ProjectID) |
|
35
|
|
|
|
|
36
|
|
|
ProjectID = "GL09" |
|
|
|
|
|
|
37
|
|
|
assert not LORIS_candidates.check_projectID_compliance(ProjectID) |
|
38
|
|
|
|
|
39
|
|
|
ProjectID = "AL01" |
|
|
|
|
|
|
40
|
|
|
assert not LORIS_candidates.check_projectID_compliance(ProjectID) |
|
41
|
|
|
|
|
42
|
|
|
ProjectID = "AB01" |
|
|
|
|
|
|
43
|
|
|
assert LORIS_candidates.check_projectID_compliance(ProjectID) |
|
44
|
|
|
|
|
45
|
|
|
@staticmethod |
|
46
|
|
|
def test_CNBP_PSCID(): |
|
|
|
|
|
|
47
|
|
|
PSCID = "VXS" + "GL01" + "0001" |
|
|
|
|
|
|
48
|
|
|
PSCID1 = "VXa" + "GL01" + "0001" |
|
|
|
|
|
|
49
|
|
|
PSCID2 = "VXS" + "GL02" + "0001" |
|
|
|
|
|
|
50
|
|
|
PSCID3 = "VXS" + "GL01" + "0001" |
|
|
|
|
|
|
51
|
|
|
PSCID4 = "VXS" + "GL01" + "0009" |
|
|
|
|
|
|
52
|
|
|
|
|
53
|
|
|
assert(LORIS_candidates.check_PSCID_compliance(PSCID)) |
|
|
|
|
|
|
54
|
|
|
assert not LORIS_candidates.check_PSCID_compliance(PSCID1) |
|
55
|
|
|
assert not LORIS_candidates.check_PSCID_compliance(PSCID2) |
|
56
|
|
|
assert LORIS_candidates.check_PSCID_compliance(PSCID3) |
|
57
|
|
|
assert LORIS_candidates.check_PSCID_compliance(PSCID4) |
|
58
|
|
|
|
|
59
|
|
|
if __name__ == "__main__": |
|
60
|
|
|
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.