[067a0c3] | 1 | #!/usr/bin/env python |
---|
| 2 | # -*- coding: utf-8 -*- |
---|
| 3 | |
---|
| 4 | import os |
---|
[2f4cc73] | 5 | import sys |
---|
| 6 | #import unittest |
---|
| 7 | import pytest |
---|
| 8 | |
---|
| 9 | sys.path.append('../') |
---|
| 10 | import _config |
---|
[067a0c3] | 11 | from tools import init128, to_param_id, my_error, read_ecenv |
---|
| 12 | |
---|
| 13 | |
---|
[2f4cc73] | 14 | class TestTools(): |
---|
[067a0c3] | 15 | ''' |
---|
| 16 | ''' |
---|
| 17 | |
---|
| 18 | def setUp(self): |
---|
| 19 | pass |
---|
| 20 | |
---|
[2f4cc73] | 21 | def test_get_cmdline_arguments(self): |
---|
| 22 | assert True |
---|
| 23 | |
---|
[067a0c3] | 24 | def test_init128(self): |
---|
| 25 | ''' |
---|
| 26 | ''' |
---|
[2f4cc73] | 27 | table128 = init128(_config.PATH_GRIBTABLE) |
---|
[067a0c3] | 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()) |
---|
[2f4cc73] | 31 | assert result == True |
---|
[067a0c3] | 32 | |
---|
| 33 | |
---|
| 34 | def test_to_param_id(self): |
---|
| 35 | ''' |
---|
| 36 | ''' |
---|
[2f4cc73] | 37 | table128 = init128(_config.PATH_GRIBTABLE) |
---|
[067a0c3] | 38 | pars = to_param_id("T/SP/LSP/SSHF", table128) |
---|
| 39 | for par in pars: |
---|
[2f4cc73] | 40 | assert par in [130, 134, 142, 146] |
---|
[067a0c3] | 41 | |
---|
| 42 | def test_error_notifcation(self): |
---|
| 43 | ''' |
---|
| 44 | ''' |
---|
[2f4cc73] | 45 | with pytest.raises(SystemExit) as pytest_wrapped_e: |
---|
[067a0c3] | 46 | my_error(['${USER}', 'anne.philipp@univie.ac.at'], 'Failed!') |
---|
[2f4cc73] | 47 | assert pytest_wrapped_e.type == SystemExit |
---|
| 48 | assert pytest_wrapped_e.value.code == 1 |
---|
[067a0c3] | 49 | |
---|
| 50 | def test_read_ecenv(self): |
---|
[2f4cc73] | 51 | ''' |
---|
| 52 | ''' |
---|
[067a0c3] | 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 | |
---|
[2f4cc73] | 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 | |
---|
[067a0c3] | 75 | |
---|
[2f4cc73] | 76 | def test_get_list_as_string(self): |
---|
| 77 | assert True |
---|
[067a0c3] | 78 | |
---|
[2f4cc73] | 79 | def test_make_dir(self): |
---|
| 80 | assert True |
---|
[067a0c3] | 81 | |
---|
[2f4cc73] | 82 | def test_put_file_to_ecserver(self): |
---|
| 83 | assert True |
---|
[067a0c3] | 84 | |
---|
[2f4cc73] | 85 | def submit_job_to_ecserver(self): |
---|
| 86 | assert True |
---|
[067a0c3] | 87 | |
---|
| 88 | if __name__ == "__main__": |
---|
[2f4cc73] | 89 | unittest.main() |
---|