Skip to content

Commit

Permalink
E2E: Add test test_configuration_during_filling_up_gaps_should_not_do…
Browse files Browse the repository at this point in the history
…wnload_existing_files
  • Loading branch information
dplocki committed Feb 26, 2024
1 parent ddd45b9 commit 753b588
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
3 changes: 3 additions & 0 deletions e2e/fixures.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ def get_feed_url(self) -> str:

return self.httpserver.url_for(self.url_prefix + self.FEED_RSS_FILE_NAME)

def get_requested_files_list(self):
return [log[0].path[1:] for log in self.httpserver.log]


class PodcastDirectory:
def __init__(self, download_destination_directory: Path) -> None:
Expand Down
47 changes: 47 additions & 0 deletions e2e/test_logic.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from itertools import chain
from typing import Callable, Dict
from e2e.fixures import (
FeedBuilder,
Expand Down Expand Up @@ -75,3 +76,49 @@ def test_ignore_files_not_being_part_of_the_feed(
[file_name.lower() for file_name in not_podcasts_files]
+ [last_podcast_file.lower()]
)


def test_configuration_during_filling_up_gaps_should_not_download_existing_files(
feed: FeedBuilder,
use_config: Callable[[Dict], None],
podcast_directory: PodcastDirectory,
):
# Arrange
files_downloaded_and_removed = call_n_times(generate_random_mp3_file)
downloaded_files_before_gap = call_n_times(generate_random_mp3_file)
files_in_the_gap = call_n_times(generate_random_mp3_file)
downloaded_files_after_gap = call_n_times(generate_random_mp3_file)
files_to_download = call_n_times(generate_random_mp3_file)

for file_name in chain(
files_downloaded_and_removed,
downloaded_files_before_gap,
files_in_the_gap,
downloaded_files_after_gap,
files_to_download,
):
feed.add_entry(file_name)

for file_name in chain(
downloaded_files_before_gap,
downloaded_files_after_gap,
):
podcast_directory.add_file(file_name)

use_config(
{
"podcasts": [
{
"path": podcast_directory.path(),
"rss_link": feed.get_feed_url(),
"fill_up_gaps": True,
}
],
}
)

# Act
run_podcast_downloader()

# Assert
assert set(feed.get_requested_files_list()) == set(files_to_download)

0 comments on commit 753b588

Please sign in to comment.