From a417e3837eea6f2deb276cb0fe2cebe71677a6a8 Mon Sep 17 00:00:00 2001 From: fang19911030 Date: Wed, 20 Nov 2024 11:07:33 -0500 Subject: [PATCH] new unit test --- .../test_create_file_name_for_push.py | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/flepimop/gempyor_pkg/tests/file_paths/test_create_file_name_for_push.py b/flepimop/gempyor_pkg/tests/file_paths/test_create_file_name_for_push.py index e69de29bb..68d915ef7 100644 --- a/flepimop/gempyor_pkg/tests/file_paths/test_create_file_name_for_push.py +++ b/flepimop/gempyor_pkg/tests/file_paths/test_create_file_name_for_push.py @@ -0,0 +1,42 @@ +from unittest.mock import patch +from gempyor.file_paths import create_file_name_for_push + +class TestCreateFileNameForPush: + # Mock implementation of create_file_name for testing + def mocked_create_file_name(self, run_id, prefix, inference_filename_prefix, inference_filepath_suffix, index, ftype, extension): + return f"{prefix}_{run_id}_{inference_filename_prefix}_{inference_filepath_suffix}_{index}_{ftype}.{extension}" + + # Test method for create_file_name_for_push + @patch("__main__.create_file_name") + def test_create_file_name_for_push(self, mock_create_file_name): + mock_create_file_name.side_effect = self.mocked_create_file_name + + flepi_run_index = "run123" + prefix = "testprefix" + flepi_slot_index = "42" + flepi_block_index = "3" + + expected_file_names = [ + f"testprefix_run123_000000042._chimeric/intermediate_3_seir.parquet", + f"testprefix_run123_000000042._chimeric/intermediate_3_hosp.parquet", + f"testprefix_run123_000000042._chimeric/intermediate_3_llik.parquet", + f"testprefix_run123_000000042._chimeric/intermediate_3_spar.parquet", + f"testprefix_run123_000000042._chimeric/intermediate_3_snpi.parquet", + f"testprefix_run123_000000042._chimeric/intermediate_3_hnpi.parquet", + f"testprefix_run123_000000042._chimeric/intermediate_3_hpar.parquet", + f"testprefix_run123_000000042._chimeric/intermediate_3_init.parquet", + f"testprefix_run123_000000042._chimeric/intermediate_3_seed.csv", + ] + + result = create_file_name_for_push( + flepi_run_index=flepi_run_index, + prefix=prefix, + flepi_slot_index=flepi_slot_index, + flepi_block_index=flepi_block_index, + ) + + # Assert the result matches the expected file names + assert result == expected_file_names + + # Assert that create_file_name was called the expected number of times + assert mock_create_file_name.call_count == 9 \ No newline at end of file