diff --git a/wetb/prepost/tests/data/demo_dlc/ref/control/minimal_demo_file.txt b/wetb/prepost/tests/data/demo_dlc/ref/control/minimal_demo_file.txt new file mode 100644 index 0000000000000000000000000000000000000000..8db2621539988442dd84f09006b47d9b6ed08690 --- /dev/null +++ b/wetb/prepost/tests/data/demo_dlc/ref/control/minimal_demo_file.txt @@ -0,0 +1 @@ +just one demo line diff --git a/wetb/prepost/tests/data/demo_dlc/ref/prepost/A0001.pkl b/wetb/prepost/tests/data/demo_dlc/ref/prepost/A0001.pkl deleted file mode 100755 index 2bec5738cd61979d1887c8e6a66f398c8f4f161e..0000000000000000000000000000000000000000 Binary files a/wetb/prepost/tests/data/demo_dlc/ref/prepost/A0001.pkl and /dev/null differ diff --git a/wetb/prepost/tests/data/demo_dlc/ref/prepost/remote.pkl b/wetb/prepost/tests/data/demo_dlc/ref/prepost/remote.pkl new file mode 100644 index 0000000000000000000000000000000000000000..424870abe4d235d40b0bc86884127247ace71cde Binary files /dev/null and b/wetb/prepost/tests/data/demo_dlc/ref/prepost/remote.pkl differ diff --git a/wetb/prepost/tests/data/demo_dlc/ref/prepost/A0001_tags.txt b/wetb/prepost/tests/data/demo_dlc/ref/prepost/remote_tags.txt old mode 100755 new mode 100644 similarity index 97% rename from wetb/prepost/tests/data/demo_dlc/ref/prepost/A0001_tags.txt rename to wetb/prepost/tests/data/demo_dlc/ref/prepost/remote_tags.txt index 6de32e2baa7f2271d6649facb844f22a2d58f337..21c9f3dd8e9452763faab41e0e8920e87c22a63d --- a/wetb/prepost/tests/data/demo_dlc/ref/prepost/A0001_tags.txt +++ b/wetb/prepost/tests/data/demo_dlc/ref/prepost/remote_tags.txt @@ -63,7 +63,7 @@ [wdir] : 0 [windramp] : False [wsp factor] : 1.0 - [zip_root_files] : ['pbs_in_file_cache.txt', 'A0001_ErrorLog.csv'] + [zip_root_files] : [] ------------------------------------------------------------------------------- opt_tags set @@ -119,7 +119,7 @@ [wdir] : 0 [windramp] : False [wsp factor] : 0.888888888889 - [zip_root_files] : ['pbs_in_file_cache.txt', 'A0001_ErrorLog.csv'] + [zip_root_files] : [] ------------------------------------------------------------------------------- opt_tags set @@ -175,4 +175,4 @@ [wdir] : 0 [windramp] : False [wsp factor] : 0.8 - [zip_root_files] : ['pbs_in_file_cache.txt', 'A0001_ErrorLog.csv'] + [zip_root_files] : [] diff --git a/wetb/prepost/tests/data/demo_dlc/source/control/minimal_demo_file.txt b/wetb/prepost/tests/data/demo_dlc/source/control/minimal_demo_file.txt new file mode 100644 index 0000000000000000000000000000000000000000..8db2621539988442dd84f09006b47d9b6ed08690 --- /dev/null +++ b/wetb/prepost/tests/data/demo_dlc/source/control/minimal_demo_file.txt @@ -0,0 +1 @@ +just one demo line diff --git a/wetb/prepost/tests/test_Simulations.py b/wetb/prepost/tests/test_Simulations.py index f4c9cfa48cc7320772a29a6926b2f80b6b3b84b5..9d6ba1d06e9e1632252d41fbc9d66b3b498c739a 100644 --- a/wetb/prepost/tests/test_Simulations.py +++ b/wetb/prepost/tests/test_Simulations.py @@ -13,6 +13,7 @@ standard_library.install_aliases() import unittest import os import filecmp +import pickle from wetb.prepost import dlctemplate as tmpl @@ -26,29 +27,39 @@ class TestGenerateInputs(unittest.TestCase): # manually configure paths, HAWC2 model root path is then constructed as # p_root_remote/PROJECT/sim_id, and p_root_local/PROJECT/sim_id # adopt accordingly when you have configured your directories differently - p_root_remote = os.path.join(self.basepath, 'data/') - p_root_local = os.path.join(self.basepath, 'data/') + p_root = os.path.join(self.basepath, 'data/') # project name, sim_id, master file name tmpl.PROJECT = 'demo_dlc' tmpl.MASTERFILE = 'demo_dlc_master_A0001.htc' # MODEL SOURCES, exchanche file sources - tmpl.P_RUN = os.path.join(p_root_remote, tmpl.PROJECT, 'remote/') - tmpl.P_SOURCE = os.path.join(p_root_local, tmpl.PROJECT, 'source/') + tmpl.P_RUN = os.path.join(p_root, tmpl.PROJECT, 'remote/') + tmpl.P_SOURCE = os.path.join(p_root, tmpl.PROJECT, 'source/') # location of the master file - tmpl.P_MASTERFILE = os.path.join(p_root_local, tmpl.PROJECT, + tmpl.P_MASTERFILE = os.path.join(p_root, tmpl.PROJECT, 'source', 'htc', '_master/') # location of the pre and post processing data - tmpl.POST_DIR = os.path.join(p_root_remote, tmpl.PROJECT, 'remote', + tmpl.POST_DIR = os.path.join(p_root, tmpl.PROJECT, 'remote', 'prepost/') tmpl.force_dir = tmpl.P_RUN tmpl.launch_dlcs_excel('remote', silent=True) - remote = os.path.join(p_root_remote, tmpl.PROJECT, 'remote') - ref = os.path.join(p_root_remote, tmpl.PROJECT, 'ref') - cmp = filecmp.dircmp(remote, ref) - self.assertTrue(len(cmp.diff_files)==0) - self.assertTrue(len(cmp.right_only)==0) - self.assertTrue(len(cmp.left_only)==0) + # we can not check-in empty dirs in git + for subdir in ['control', 'data', 'htc', 'pbs_in']: + remote = os.path.join(p_root, tmpl.PROJECT, 'remote', subdir) + ref = os.path.join(p_root, tmpl.PROJECT, 'ref', subdir) + cmp = filecmp.dircmp(remote, ref) + self.assertTrue(len(cmp.diff_files)==0) + self.assertTrue(len(cmp.right_only)==0) + self.assertTrue(len(cmp.left_only)==0) + + # for the pickled file we can just read it + remote = os.path.join(p_root, tmpl.PROJECT, 'remote', 'prepost') + ref = os.path.join(p_root, tmpl.PROJECT, 'ref', 'prepost') + with open(os.path.join(remote, 'remote.pkl'), 'rb') as FILE: + pkl_remote = pickle.load(FILE) + with open(os.path.join(ref, 'remote.pkl'), 'rb') as FILE: + pkl_ref = pickle.load(FILE) + self.assertEqual(pkl_remote, pkl_ref) if __name__ == "__main__":