From 3141cd1d7be26fb2ff1445d04069e7ca79f0af12 Mon Sep 17 00:00:00 2001 From: Dominic Orchard Date: Wed, 20 Nov 2024 09:24:42 +0000 Subject: [PATCH 1/2] allow inverse or instantaneous models --- src/bmi_tester/_tests/stage_1/time_test.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/bmi_tester/_tests/stage_1/time_test.py b/src/bmi_tester/_tests/stage_1/time_test.py index a93690d..6274022 100644 --- a/src/bmi_tester/_tests/stage_1/time_test.py +++ b/src/bmi_tester/_tests/stage_1/time_test.py @@ -62,6 +62,11 @@ def test_get_end_time(initialized_bmi): """Test that there is a stop time.""" start = initialized_bmi.get_start_time() stop = initialized_bmi.get_end_time() + time_step = initialized_bmi.get_time_step() assert isinstance(stop, (int, float)) - assert stop >= start + assert ((time_step > 0 & start <= stop) + # or an inverse model + | (time_step < 0 & stop <= start) + # or an instantaneous model + | (time_step == 0 & start == stop)) From 42e33f2c9d0e6af74d9b2c8c6b6a47b87f9f1f94 Mon Sep 17 00:00:00 2001 From: Dominic Orchard Date: Wed, 20 Nov 2024 09:31:22 +0000 Subject: [PATCH 2/2] generalise the current_time check too --- src/bmi_tester/_tests/stage_1/time_test.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/bmi_tester/_tests/stage_1/time_test.py b/src/bmi_tester/_tests/stage_1/time_test.py index 6274022..0915111 100644 --- a/src/bmi_tester/_tests/stage_1/time_test.py +++ b/src/bmi_tester/_tests/stage_1/time_test.py @@ -50,11 +50,22 @@ def test_get_current_time(initialized_bmi): start = initialized_bmi.get_start_time() now = initialized_bmi.get_current_time() stop = initialized_bmi.get_end_time() + time_step = initialized_bmi.get_time_step() assert isinstance(now, (int, float)) - assert now <= stop - assert now >= start + # Test that the current time is 'between' the start and stop + # times; this depends on whether the time step is negative, positive, or 0 + assert (((time_step > 0) & (now <= stop)) + # Inverse model has current time greater than the stop + | ((time_step < 0) & (now >= stop)) + # Instantaneous model has current time equal stop + | ((time_step == 0) & (now == stop))) + assert (((time_step > 0) & (now >= start)) + # Inverse model has current time less than the start + | ((time_step < 0) & (now <= start)) + # Instantaneous model has current time equalt the start + | ((time_step == 0) & (now == start))) @pytest.mark.skip() @pytest.mark.dependency(depends=["test_get_start_time"])