Skip to content

Commit

Permalink
deleting files at the end of mct tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Cinzia Mazzetti committed Jul 24, 2024
1 parent 15b7531 commit 77f0ff9
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 23 deletions.
18 changes: 11 additions & 7 deletions tests/test_mct_dyn_inflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,16 @@ def run(self, date_start, date_end, dtsec, type):

comparator.compare_files(reference, output_tss)

def teardown_method(self):
def teardown_method(self, type):
print('Cleaning directories')
ref_path = os.path.join(self.case_dir, 'reference_mct_dyn', 'inflow_'+ str(type))
shutil.rmtree(ref_path, ignore_errors=True)

ref_path = os.path.join(self.case_dir, 'reference_mct_dyn')
if os.path.exists(ref_path) and os.path.isdir(ref_path):
shutil.rmtree(ref_path, ignore_errors=True)

out_path = os.path.join(self.case_dir, self.run_type)
shutil.rmtree(out_path, ignore_errors=True)
if os.path.exists(out_path) and os.path.isdir(out_path):
shutil.rmtree(out_path, ignore_errors=True)


class TestInflowShort(TestInflow):
Expand All @@ -107,12 +111,12 @@ class TestInflowShort(TestInflow):

def test_inflow_6h(self):
self.run("01/03/2016 06:00", "30/03/2016 06:00", 21600,'6h')
def cleaning(self):
self.teardown_method()

def test_inflow_daily(self):
self.run("02/01/2016 06:00", "30/01/2016 06:00", 86400,'daily')
def cleaning(self):

# cleaning folders
def cleaning(self,):
self.teardown_method()

# @pytest.mark.slow
Expand Down
42 changes: 26 additions & 16 deletions tests/test_mct_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,19 @@ def run_split(self, date_start, date_end, dtsec, dtsec_chan, type):
output_tss = os.path.join(self.out_path_run, 'OutletDischargeErrorSplitRoutingM3S.tss')
comparator.compare_files(reference, output_tss)

# def teardown_method(self):
# print('Cleaning directories')
# out_path = os.path.join(self.case_dir, self.out_path_run)
# shutil.rmtree(out_path, ignore_errors=True)
def teardown_method(self):
print('Cleaning directories')
out_path = os.path.join(self.case_dir, 'out')
if os.path.exists(out_path) and os.path.isdir(out_path):
shutil.rmtree(out_path, ignore_errors=True)

# for item in os.listdir(out_path):
# item_path = os.path.join(out_path, item)
# if os.path.isfile(item_path) or os.path.islink(item_path):
# os.unlink(item_path) # Remove the file or link
# elif os.path.isdir(item_path):
# shutil.rmtree(item_path) # Remove the directory and its contents



class TestMCTResults(TestTSSResults):
Expand All @@ -206,11 +215,11 @@ def test_MCT_6h(self):
def test_MCT_6h_1h(self):
self.run_mct("02/01/2016 06:00", "02/07/2016 06:00", 21600, 3600,'6h_1h')
def test_MCT_daily(self):
self.run_mct("02/01/2016 06:00", "02/07/2016 06:00", 86400, 86400,'daily')
self.run_mct("02/01/2016 06:00", "02/07/2016 06:00", 86400, 86400,'daily')
def test_MCT_daily_6h(self):
self.run_mct("02/01/2016 06:00", "02/07/2016 06:00", 86400, 21600,'daily_6h')
self.run_mct("02/01/2016 06:00", "02/07/2016 06:00", 86400, 21600,'daily_6h')
def test_MCT_daily_1h(self):
self.run_mct("02/01/2016 06:00", "02/07/2016 06:00", 86400, 3600, 'daily_1h')
self.run_mct("02/01/2016 06:00", "02/07/2016 06:00", 86400, 3600, 'daily_1h')

###########################################
# test results of MCT+SPLIT routing
Expand All @@ -219,11 +228,11 @@ def test_MCTS_6h(self):
def test_MCTS_6h_1h(self):
self.run_mcts("02/01/2016 06:00", "02/07/2016 06:00", 21600, 3600,'6h_1h')
def test_MCTS_daily(self):
self.run_mcts("02/01/2016 06:00", "02/07/2016 06:00", 86400, 86400,'daily')
self.run_mcts("02/01/2016 06:00", "02/07/2016 06:00", 86400, 86400,'daily')
def test_MCTS_daily_6h(self):
self.run_mcts("02/01/2016 06:00", "02/07/2016 06:00", 86400, 21600,'daily_6h')
self.run_mcts("02/01/2016 06:00", "02/07/2016 06:00", 86400, 21600,'daily_6h')
def test_MCTS_daily_1h(self):
self.run_mcts("02/01/2016 06:00", "02/07/2016 06:00", 86400, 3600, 'daily_1h')
self.run_mcts("02/01/2016 06:00", "02/07/2016 06:00", 86400, 3600, 'daily_1h')

# #########################################
# test results of Kinemating routing
Expand All @@ -232,11 +241,11 @@ def test_KIN_6h(self):
def test_KIN_6h_1h(self):
self.run_kin("02/01/2016 06:00", "02/07/2016 06:00", 21600, 3600,'6h_1h')
def test_KIN_daily(self):
self.run_kin("02/01/2016 06:00", "02/07/2016 06:00", 86400, 86400,'daily')
self.run_kin("02/01/2016 06:00", "02/07/2016 06:00", 86400, 86400,'daily')
def test_KIN_daily_6h(self):
self.run_kin("02/01/2016 06:00", "02/07/2016 06:00", 86400, 21600,'daily_6h')
self.run_kin("02/01/2016 06:00", "02/07/2016 06:00", 86400, 21600,'daily_6h')
def test_KIN_daily_1h(self):
self.run_kin("02/01/2016 06:00", "02/07/2016 06:00", 86400, 3600, 'daily_1h')
self.run_kin("02/01/2016 06:00", "02/07/2016 06:00", 86400, 3600, 'daily_1h')

# #########################################
# test results of Split routing
Expand All @@ -251,9 +260,10 @@ def test_SPLIT_daily_6h(self):
def test_SPLIT_daily_1h(self):
self.run_split("02/01/2016 06:00", "02/07/2016 06:00", 86400, 3600, 'daily_1h')


# def cleaning(self):
# self.teardown_method()
# #########################################
# cleaning out/ folder
def cleaning(self,):
self.teardown_method()


# @pytest.mark.slow
Expand Down

0 comments on commit 77f0ff9

Please sign in to comment.