From 7ca79976e5bb685d9a69a652179664fc39eaeeba Mon Sep 17 00:00:00 2001 From: KulaginVladimir Date: Mon, 7 Oct 2024 03:17:53 +0300 Subject: [PATCH] test is_last --- test/unit/test_exports/test_txt_export.py | 26 +++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/test/unit/test_exports/test_txt_export.py b/test/unit/test_exports/test_txt_export.py index 5210bf3f3..177b6c853 100644 --- a/test/unit/test_exports/test_txt_export.py +++ b/test/unit/test_exports/test_txt_export.py @@ -163,3 +163,29 @@ def test_false(self, my_export): assert not my_export.is_it_time_to_export(0) assert not my_export.is_it_time_to_export(5) assert not my_export.is_it_time_to_export(1.5) + + +class TestIsLast: + @pytest.fixture + def my_export(self, tmpdir): + d = tmpdir.mkdir("test_folder") + my_export = TXTExport( + "solute", + filename="{}/solute_label.txt".format(str(Path(d))), + ) + + return my_export + + def test_final_time_none(self, my_export): + assert my_export.is_last(1, None) == True + + @pytest.mark.parametrize("current_time,output", [(1, False), (3, False), (5, True)]) + def test_times_not_none(self, current_time, output, my_export): + final_time = 5 + assert my_export.is_last(current_time, final_time) == output + + @pytest.mark.parametrize("current_time,output", [(1, False), (2, False), (3, True)]) + def test_times_not_none(self, current_time, output, my_export): + my_export.times = [1, 2, 3] + final_time = 5 + assert my_export.is_last(current_time, final_time) == output