- Timestamp:
- Aug 31, 2018, 2:08:46 PM (6 years ago)
- Branches:
- master, ctbto, dev
- Children:
- 2ad8ea5
- Parents:
- dda0e9d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
python/pythontest/TestTools.py
r067a0c3 r2f4cc73 2 2 # -*- coding: utf-8 -*- 3 3 4 import unittest4 import os 5 5 import sys 6 import os 7 sys.path.append('../python') 6 #import unittest 7 import pytest 8 9 sys.path.append('../') 10 import _config 8 11 from tools import init128, to_param_id, my_error, read_ecenv 9 12 10 13 11 class TestTools( unittest.TestCase):14 class TestTools(): 12 15 ''' 13 16 ''' … … 16 19 pass 17 20 21 def test_get_cmdline_arguments(self): 22 assert True 23 18 24 def test_init128(self): 19 25 ''' 20 26 ''' 21 table128 = init128( '../grib_templates/ecmwf_grib1_table_128')27 table128 = init128(_config.PATH_GRIBTABLE) 22 28 expected = {'078': 'TCLW', '130': 'T', '034': 'SST'} 23 29 # check a sample of parameters which must have been read in 24 30 result = all((k in table128 and table128[k]==v) for k,v in expected.iteritems()) 25 self.assertEqual(result, True)31 assert result == True 26 32 27 33 … … 29 35 ''' 30 36 ''' 31 table128 = init128( '../grib_templates/ecmwf_grib1_table_128')37 table128 = init128(_config.PATH_GRIBTABLE) 32 38 pars = to_param_id("T/SP/LSP/SSHF", table128) 33 39 for par in pars: 34 self.assertIn(par, [130, 134, 142, 146])40 assert par in [130, 134, 142, 146] 35 41 36 42 def test_error_notifcation(self): 37 43 ''' 38 44 ''' 39 with self.assertRaises(SystemExit) as re:45 with pytest.raises(SystemExit) as pytest_wrapped_e: 40 46 my_error(['${USER}', 'anne.philipp@univie.ac.at'], 'Failed!') 41 self.assertEqual(re.exception.code, 1) 47 assert pytest_wrapped_e.type == SystemExit 48 assert pytest_wrapped_e.value.code == 1 42 49 43 50 def test_read_ecenv(self): 44 51 ''' 52 ''' 45 53 envs_ref = {'ECUID': 'km4a', 46 54 'ECGID': 'at', … … 50 58 envs = read_ecenv(os.getcwd() + '/TestData/ECMWF_ENV') 51 59 52 self.assertDictEqual(envs_ref, envs)60 assert envs_ref == envs 53 61 54 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 55 74 56 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 57 87 58 88 if __name__ == "__main__":
Note: See TracChangeset
for help on using the changeset viewer.