From b3f434ffeabcb074916b8e6f5bd5e31d43f95e93 Mon Sep 17 00:00:00 2001 From: "Nina.Hakansson" Date: Fri, 19 Apr 2024 14:31:31 +0200 Subject: [PATCH] Check that tmp files are removed --- nwcsafpps_runner/tests/test_nwp_prepare.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/nwcsafpps_runner/tests/test_nwp_prepare.py b/nwcsafpps_runner/tests/test_nwp_prepare.py index d579627..9267bde 100644 --- a/nwcsafpps_runner/tests/test_nwp_prepare.py +++ b/nwcsafpps_runner/tests/test_nwp_prepare.py @@ -22,6 +22,7 @@ # along with this program. If not, see . """Test the nwp_prepare runner code.""" +import glob import logging import os import unittest @@ -116,6 +117,8 @@ def test_update_nwp(self, fake_file_dir): # Run again when file is already created nwc_prep.update_nwp(date - timedelta(days=2), [9], cfg_file) assert os.path.exists(outfile) + out_files = glob.glob(os.path.join(str(my_temp_dir), "*_202205100000+009H00M*")) + assert len(out_files) == 1 def test_update_nwp_no_requirement_file(self, fake_file_dir): """Create file no requirement file.""" @@ -127,6 +130,8 @@ def test_update_nwp_no_requirement_file(self, fake_file_dir): date = datetime(year=2022, month=5, day=10, hour=0, tzinfo=timezone.utc) nwc_prep.update_nwp(date - timedelta(days=2), [9], cfg_file) assert os.path.exists(outfile) + out_files = glob.glob(os.path.join(str(my_temp_dir), "*_202205100000+009H00M*")) + assert len(out_files) == 1 def test_update_nwp_missing_fields(self, fake_file_dir): """Test that no file without mandatory data is created.""" @@ -136,6 +141,8 @@ def test_update_nwp_missing_fields(self, fake_file_dir): date = datetime(year=2022, month=5, day=10, hour=0, tzinfo=timezone.utc) nwc_prep.update_nwp(date - timedelta(days=2), [9], cfg_file) assert not (os.path.exists(outfile)) + out_files = glob.glob(os.path.join(str(my_temp_dir), "*_202205100000+009H00M*")) + assert len(out_files) == 0 def test_remove_filename(self, fake_file_dir): """Test the function for removing files."""