From c7395ebaa0b508d375f052f2d1de8565bb4256cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dawid=20P=C5=82ocki?= Date: Sun, 18 Feb 2024 12:33:25 +0100 Subject: [PATCH] Introduce helper function generate_podcast_files_episodes --- ...et_last_downloaded_file_before_gap_test.py | 27 +++++++------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/tests/get_last_downloaded_file_before_gap_test.py b/tests/get_last_downloaded_file_before_gap_test.py index e10170b..be84050 100644 --- a/tests/get_last_downloaded_file_before_gap_test.py +++ b/tests/get_last_downloaded_file_before_gap_test.py @@ -1,4 +1,5 @@ from random import shuffle +from typing import Generator import unittest from podcast_downloader.downloaded import get_last_downloaded_file_before_gap @@ -14,12 +15,7 @@ def test_should_return_none_for_empty_collections(self): def test_should_return_none_for_empty_directory_files(self): # Assign - feed_files = [ - "podcast_episode_1.mp3", - "podcast_episode_2.mp3", - "podcast_episode_3.mp3", - "podcast_episode_4.mp3", - ] + feed_files = list(generate_podcast_files_episodes(4)) # Act result = get_last_downloaded_file_before_gap(feed_files, []) @@ -29,12 +25,7 @@ def test_should_return_none_for_empty_directory_files(self): def test_should_return_last_for_nonempty_directory_files(self): # Assign - feed_files = [ - "podcast_episode_1.mp3", - "podcast_episode_2.mp3", - "podcast_episode_3.mp3", - "podcast_episode_4.mp3", - ] + feed_files = list(generate_podcast_files_episodes(4)) directory_files = feed_files.copy() @@ -48,12 +39,7 @@ def test_should_return_last_for_nonempty_directory_files(self): def test_should_return_last_according_the_feed_order(self): # Assign - feed_files = [ - "podcast_episode_1.mp3", - "podcast_episode_2.mp3", - "podcast_episode_3.mp3", - "podcast_episode_4.mp3", - ] + feed_files = list(generate_podcast_files_episodes(4)) directory_files = feed_files[0:-1] shuffle(directory_files) @@ -66,3 +52,8 @@ def test_should_return_last_according_the_feed_order(self): self.assertEqual( result, feed_files[-1], "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): + yield f"podcast_episode_{i}.mp3"