|
1
|
|
|
import os |
|
|
|
|
|
|
2
|
|
|
import unittest |
|
3
|
|
|
from LORIS.helper import LORIS_helper |
|
|
|
|
|
|
4
|
|
|
from dotenv import load_dotenv |
|
5
|
|
|
from pathlib import Path |
|
|
|
|
|
|
6
|
|
|
|
|
7
|
|
|
class UT_LORISHelper(unittest.TestCase): |
|
|
|
|
|
|
8
|
|
|
|
|
9
|
|
|
@staticmethod |
|
10
|
|
|
def test_number_extraction(): |
|
|
|
|
|
|
11
|
|
|
Prefix = "V" |
|
|
|
|
|
|
12
|
|
|
numbers = [1, 2, 3, 9, 10, 11, 12, 100, 101, 102] |
|
13
|
|
|
|
|
14
|
|
|
global timepoints |
|
|
|
|
|
|
15
|
|
|
timepoints = [] |
|
16
|
|
|
|
|
17
|
|
|
for number in numbers: |
|
18
|
|
|
timepoints.append(Prefix + str(number)) |
|
19
|
|
|
|
|
20
|
|
|
DualList = zip(numbers, timepoints) |
|
|
|
|
|
|
21
|
|
|
|
|
22
|
|
|
for tupleItem in DualList: |
|
|
|
|
|
|
23
|
|
|
assert str(tupleItem[0]) == LORIS_helper.number_extraction(tupleItem[1])[0] |
|
24
|
|
|
|
|
25
|
|
|
|
|
26
|
|
|
@staticmethod |
|
27
|
|
|
def test_ProxyUpload(): |
|
|
|
|
|
|
28
|
|
|
assert load_dotenv() |
|
29
|
|
|
|
|
30
|
|
|
ProxyIP = os.getenv("ProxyIP") |
|
|
|
|
|
|
31
|
|
|
ProxyUsername = os.getenv("ProxyUsername") |
|
|
|
|
|
|
32
|
|
|
ProxyPassword = os.getenv("ProxyPassword") |
|
|
|
|
|
|
33
|
|
|
LORISHostPassword = os.getenv("LORISHostPassword") |
|
|
|
|
|
|
34
|
|
|
LORISHostUsername = os.getenv("LORISHostUsername") |
|
|
|
|
|
|
35
|
|
|
LORISHostIP = os.getenv("LORISHostIP") |
|
|
|
|
|
|
36
|
|
|
Client = LORIS_helper.getProxySSHClient(ProxyIP, ProxyUsername, ProxyPassword, |
|
|
|
|
|
|
37
|
|
|
LORISHostIP, LORISHostUsername, LORISHostPassword) |
|
38
|
|
|
|
|
39
|
|
|
testFile = "test_file.txt" |
|
|
|
|
|
|
40
|
|
|
Path(testFile).touch() |
|
41
|
|
|
|
|
42
|
|
|
LORIS_helper.uploadThroughClient(Client, testFile, testFile) |
|
43
|
|
|
sftp = Client.open_sftp() |
|
44
|
|
|
sftp.remove(testFile) |
|
45
|
|
|
os.remove(testFile) |
|
46
|
|
|
sftp.close() |
|
47
|
|
|
Client.close() |
|
48
|
|
|
|
|
49
|
|
|
if __name__ == '__main__': |
|
50
|
|
|
UT_LORISHelper.test_number_extraction() |
|
|
|
|
|
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.