1 | #!/usr/bin/env python |
---|
2 | # -*- coding: utf-8 -*- |
---|
3 | |
---|
4 | import os |
---|
5 | import sys |
---|
6 | #import unittest |
---|
7 | import pytest |
---|
8 | |
---|
9 | sys.path.append('../') |
---|
10 | import _config |
---|
11 | from tools import init128, to_param_id, my_error, read_ecenv |
---|
12 | |
---|
13 | |
---|
14 | class TestTools(): |
---|
15 | ''' |
---|
16 | ''' |
---|
17 | |
---|
18 | def setUp(self): |
---|
19 | pass |
---|
20 | |
---|
21 | def test_get_cmdline_arguments(self): |
---|
22 | assert True |
---|
23 | |
---|
24 | def test_init128(self): |
---|
25 | ''' |
---|
26 | ''' |
---|
27 | table128 = init128(_config.PATH_GRIBTABLE) |
---|
28 | expected = {'078': 'TCLW', '130': 'T', '034': 'SST'} |
---|
29 | # check a sample of parameters which must have been read in |
---|
30 | result = all((k in table128 and table128[k]==v) for k,v in expected.iteritems()) |
---|
31 | assert result == True |
---|
32 | |
---|
33 | |
---|
34 | def test_to_param_id(self): |
---|
35 | ''' |
---|
36 | ''' |
---|
37 | table128 = init128(_config.PATH_GRIBTABLE) |
---|
38 | pars = to_param_id("T/SP/LSP/SSHF", table128) |
---|
39 | for par in pars: |
---|
40 | assert par in [130, 134, 142, 146] |
---|
41 | |
---|
42 | def test_error_notifcation(self): |
---|
43 | ''' |
---|
44 | ''' |
---|
45 | with pytest.raises(SystemExit) as pytest_wrapped_e: |
---|
46 | my_error(['${USER}', 'anne.philipp@univie.ac.at'], 'Failed!') |
---|
47 | assert pytest_wrapped_e.type == SystemExit |
---|
48 | assert pytest_wrapped_e.value.code == 1 |
---|
49 | |
---|
50 | def test_read_ecenv(self): |
---|
51 | ''' |
---|
52 | ''' |
---|
53 | envs_ref = {'ECUID': 'km4a', |
---|
54 | 'ECGID': 'at', |
---|
55 | 'GATEWAY': 'srvx8.img.univie.ac.at', |
---|
56 | 'DESTINATION': 'annep@genericSftp' |
---|
57 | } |
---|
58 | envs = read_ecenv(os.getcwd() + '/TestData/ECMWF_ENV') |
---|
59 | |
---|
60 | assert envs_ref == envs |
---|
61 | |
---|
62 | |
---|
63 | def test_clean_up(self): |
---|
64 | assert True |
---|
65 | |
---|
66 | def test_normal_exit(self): |
---|
67 | assert True |
---|
68 | |
---|
69 | def test_product(self): |
---|
70 | assert True |
---|
71 | |
---|
72 | def test_silent_remove(self): |
---|
73 | assert True |
---|
74 | |
---|
75 | |
---|
76 | def test_get_list_as_string(self): |
---|
77 | assert True |
---|
78 | |
---|
79 | def test_make_dir(self): |
---|
80 | assert True |
---|
81 | |
---|
82 | def test_put_file_to_ecserver(self): |
---|
83 | assert True |
---|
84 | |
---|
85 | def submit_job_to_ecserver(self): |
---|
86 | assert True |
---|
87 | |
---|
88 | if __name__ == "__main__": |
---|
89 | unittest.main() |
---|