From 894dd65da9b2e7f5fd666a4df6be4bdb29e70c61 Mon Sep 17 00:00:00 2001 From: Tom Ward Date: Fri, 4 Oct 2024 14:34:24 +0100 Subject: [PATCH] Add smaller test case --- tests/test_run.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tests/test_run.py b/tests/test_run.py index c9a4d033..78df65c5 100644 --- a/tests/test_run.py +++ b/tests/test_run.py @@ -1000,6 +1000,38 @@ def test_get_obsolete_files_things_to_delete(db): assert obsolete == ["old_high.txt", "old_medium.txt"] +def test_get_obsolete_files_things_to_delete_timing(db): + old_outputs = { + "old_high.txt": "highly_sensitive", + "old_medium.txt": "moderately_sensitive", + "current.txt": "highly_sensitive", + } + new_outputs = { + "new_high.txt": "highly_sensitive", + "new_medium.txt": "moderately_sensitive", + "current.txt": "highly_sensitive", + } + + # insert previous outputs + job_factory( + state=State.SUCCEEDED, + status_code=StatusCode.SUCCEEDED, + outputs=old_outputs, + created_at=time.time() - 10, + ) + + job = job_factory( + state=State.RUNNING, + status_code=StatusCode.FINALIZED, + outputs=new_outputs, + ) + + job_definition = run.job_to_job_definition(job) + + obsolete = run.get_obsolete_files(job_definition, new_outputs) + assert obsolete == ["old_high.txt", "old_medium.txt"] + + def test_get_obsolete_files_case_change(db): old_outputs = { "high.txt": "highly_sensitive",