Skip to content

Commit

Permalink
Introduce helper function generate_podcast_files_episodes
Browse files Browse the repository at this point in the history
  • Loading branch information
dplocki committed Feb 18, 2024
1 parent b3bfc21 commit c7395eb
Showing 1 changed file with 9 additions and 18 deletions.
27 changes: 9 additions & 18 deletions tests/get_last_downloaded_file_before_gap_test.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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, [])
Expand All @@ -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()

Expand All @@ -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)
Expand All @@ -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"

0 comments on commit c7395eb

Please sign in to comment.