@@ -238,3 +238,28 @@ def test_download_with_unknown_hash_algorithm(
238238 # and only then realize hash cannot be verified
239239 assert client .download_target (init_data , target_path ) == 1
240240 assert client .get_downloaded_target_bytes () == []
241+
242+
243+ def test_artifact_cache (client : ClientRunner , server : SimulatorServer ) -> None :
244+ """In this test client is asked to download the same artifact twice.
245+ The client is expected return the cached content on the second time.
246+
247+ Artifact caching is not required in the specification: clients
248+ that do not support it can mark this test as expected to fail
249+ """
250+
251+ init_data , repo = server .new_test (client .test_name )
252+ assert client .init_client (init_data ) == 0
253+
254+ # Create a test artifact, add it to the repository
255+ target_path = "target_file.txt"
256+ target_content = b"target file contents"
257+ repo .add_artifact (Targets .type , target_content , target_path )
258+ repo .publish ([Targets .type , Snapshot .type , Timestamp .type ])
259+
260+ # Client is asked to download artifact twice
261+ assert client .download_target (init_data , target_path ) == 0
262+ assert client .download_target (init_data , target_path ) == 0
263+
264+ # Expect only one download from repository
265+ assert len (repo .artifact_statistics ) == 1
0 commit comments