Skip to content

Commit

Permalink
Add and implement the test test_should_return_last_according_the_feed…
Browse files Browse the repository at this point in the history
…_order_with_gap_between_files
  • Loading branch information
dplocki committed Feb 19, 2024
1 parent 879f815 commit 368b1ed
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
3 changes: 3 additions & 0 deletions podcast_downloader/downloaded.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,8 @@ def get_last_downloaded_file_before_gap(
for feed_file_name in feed_files:
if feed_file_name in all_downloaded_files:
last_file = feed_file_name
else:
if last_file != None:
return last_file

return last_file
26 changes: 23 additions & 3 deletions tests/get_last_downloaded_file_before_gap_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def test_should_return_last_for_nonempty_directory_files(self):

# Assert
self.assertEqual(
result, feed_files[-1], "Should return the last files from the feed"
result, feed_files[-1], "Should return the last file from the feed"
)

def test_should_return_last_according_the_feed_order(self):
Expand All @@ -50,7 +50,7 @@ def test_should_return_last_according_the_feed_order(self):

# Assert
self.assertEqual(
result, feed_files[-1], "Should return the last files from the feed"
result, feed_files[-1], "Should return the last file from the feed"
)

def test_should_return_last_according_the_feed_order_when_feed_is_longer(self):
Expand All @@ -66,7 +66,27 @@ def test_should_return_last_according_the_feed_order_when_feed_is_longer(self):

# Assert
self.assertEqual(
result, feed_files[-3], "Should return the last files from the feed"
result,
feed_files[-3],
"Should return the last file (according to feed) which is downloaded",
)

def test_should_return_last_according_the_feed_order_with_gap_between_files(self):
# Assign
feed_files = list(generate_podcast_files_episodes(8))

directory_files = feed_files[2:4] + [feed_files[-2]]
shuffle(directory_files)
directory_files.insert(0, feed_files[-4])

# Act
result = get_last_downloaded_file_before_gap(feed_files, directory_files)

# Assert
self.assertEqual(
result,
feed_files[-4],
"Should return the last file (according to feed) before gap which is downloaded",
)


Expand Down

0 comments on commit 368b1ed

Please sign in to comment.