Skip to content

Commit

Permalink
E2E: Draft of the test_download_since_last_run
Browse files Browse the repository at this point in the history
  • Loading branch information
dplocki committed May 14, 2024
1 parent 97781ac commit 772c92a
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions e2e/test_simple_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,3 +276,44 @@ def test_download_last_n_episodes_behavior(

# Assert
podcast_directory.is_containing_only(expected_downloaded_files)


def test_download_since_last_run(
feed: FeedBuilder,
use_config: Callable[[Dict], None],
podcast_downloader: Callable[[List[str]], PodcastDownloaderRunner],
podcast_directory: PodcastDirectory,
):
# Arrange
expected_number_of_episode = generate_random_int(2, 5)
metadata = []
previous = datetime.datetime.now(datetime.timezone.utc) - datetime.timedelta(days=1)
for _ in range(generate_random_int(7, 13)):
metadata.append((generate_random_mp3_file(), previous))
previous -= datetime.timedelta(days=1)

metadata.reverse()

expected_episode = [name for name, _ in metadata[:expected_number_of_episode]]

last_run_date = metadata[expected_number_of_episode][1]
last_run_date -= datetime.timedelta(hours=1)

use_config(
{
"last_run_mark_file_path": "totem.json",
"podcasts": [
{
"if_directory_empty": "download_since_last_run",
"path": podcast_directory.path(),
"rss_link": feed.get_feed_url(),
}
],
}
)

# Act
podcast_downloader.run()

# Assert
podcast_directory.is_containing_only(expected_episode)

0 comments on commit 772c92a

Please sign in to comment.