diff --git a/tests/conftest.py b/tests/conftest.py index d058dc878d05de7160d06ce8d0380008d5711a14..1ab4047abefe4013e8ed78b527bc6df5b3053966 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -280,6 +280,11 @@ def model_file_dir(): return SAMPLES_DIR / "model_files" +@pytest.fixture +def model_file_dir_with_subfolder(): + return SAMPLES_DIR / "root_folder" + + @pytest.fixture def fake_dummy_worker(): api_client = MockApiClient() diff --git a/tests/samples/root_folder/model_file.pth b/tests/samples/root_folder/model_file.pth new file mode 100644 index 0000000000000000000000000000000000000000..cc78ba3026c620f5d0e8c5b65071ae8ae2dfe157 --- /dev/null +++ b/tests/samples/root_folder/model_file.pth @@ -0,0 +1 @@ +Wow this is actually the data of the best model ever created on Arkindex \ No newline at end of file diff --git a/tests/samples/root_folder/subfolder1/model_file.pth b/tests/samples/root_folder/subfolder1/model_file.pth new file mode 100644 index 0000000000000000000000000000000000000000..cc78ba3026c620f5d0e8c5b65071ae8ae2dfe157 --- /dev/null +++ b/tests/samples/root_folder/subfolder1/model_file.pth @@ -0,0 +1 @@ +Wow this is actually the data of the best model ever created on Arkindex \ No newline at end of file diff --git a/tests/samples/root_folder/subfolder2/model_file.pth b/tests/samples/root_folder/subfolder2/model_file.pth new file mode 100644 index 0000000000000000000000000000000000000000..cc78ba3026c620f5d0e8c5b65071ae8ae2dfe157 --- /dev/null +++ b/tests/samples/root_folder/subfolder2/model_file.pth @@ -0,0 +1 @@ +Wow this is actually the data of the best model ever created on Arkindex \ No newline at end of file diff --git a/tests/test_elements_worker/test_training.py b/tests/test_elements_worker/test_training.py index e8f419621bbf964a4313c93c130ffe14d049af7f..551fdf6d42121733d68a00fc3ec659153919583b 100644 --- a/tests/test_elements_worker/test_training.py +++ b/tests/test_elements_worker/test_training.py @@ -45,6 +45,24 @@ def test_create_archive(model_file_dir): assert not os.path.exists(zst_archive_path), "Auto removal failed" +def test_create_archive_with_subfolder(model_file_dir_with_subfolder): + """Create an archive when the model's file is in a folder containing a subfolder""" + + with create_archive(path=model_file_dir_with_subfolder) as ( + zst_archive_path, + hash, + size, + archive_hash, + ): + assert os.path.exists(zst_archive_path), "The archive was not created" + assert ( + hash == "3e453881404689e6e125144d2db3e605" + ), "Hash was not properly computed" + assert 300 < size < 1500 + + assert not os.path.exists(zst_archive_path), "Auto removal failed" + + @pytest.mark.parametrize( "tag, description", [