From 879f8158749e09c3c66050b546bd17db191c6203 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dawid=20P=C5=82ocki?= Date: Mon, 19 Feb 2024 20:03:25 +0100 Subject: [PATCH] Add unit test get_last_downloaded_file_before_gap_test.py --- .../get_last_downloaded_file_before_gap_test.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/get_last_downloaded_file_before_gap_test.py b/tests/get_last_downloaded_file_before_gap_test.py index be84050..682024a 100644 --- a/tests/get_last_downloaded_file_before_gap_test.py +++ b/tests/get_last_downloaded_file_before_gap_test.py @@ -53,6 +53,22 @@ def test_should_return_last_according_the_feed_order(self): result, feed_files[-1], "Should return the last files from the feed" ) + def test_should_return_last_according_the_feed_order_when_feed_is_longer(self): + # Assign + feed_files = list(generate_podcast_files_episodes(8)) + + directory_files = feed_files[2:-3] + shuffle(directory_files) + directory_files = directory_files[:1] + [feed_files[-3]] + directory_files[1:] + + # Act + result = get_last_downloaded_file_before_gap(feed_files, directory_files) + + # Assert + self.assertEqual( + result, feed_files[-3], "Should return the last files from the feed" + ) + def generate_podcast_files_episodes(n: int) -> Generator[str, None, None]: for i in range(1, n + 1):