Skip to content

Commit

Permalink
Check that tmp files are removed
Browse files Browse the repository at this point in the history
  • Loading branch information
Nina.Hakansson committed Apr 19, 2024
1 parent 1bdf799 commit b3f434f
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions nwcsafpps_runner/tests/test_nwp_prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.

"""Test the nwp_prepare runner code."""
import glob
import logging
import os
import unittest
Expand Down Expand Up @@ -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."""
Expand All @@ -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."""
Expand All @@ -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."""
Expand Down

0 comments on commit b3f434f

Please sign in to comment.