Skip to content

Commit

Permalink
Add the test_download_since_last_run_with_no_marker_file_setup
Browse files Browse the repository at this point in the history
  • Loading branch information
dplocki committed May 18, 2024
1 parent c162528 commit e7751ad
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
10 changes: 9 additions & 1 deletion e2e/fixures.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,16 +224,24 @@ def is_highlighted_in_outcome(self, word: str) -> bool:
def is_containing(self, word: str) -> bool:
return word in self.output.stdout

def get_output(self):
return self.output.stdout.splitlines()


class MarkerFileManager:
def __init__(self, directory) -> None:
self.path_of_marker_file = directory / ".marker"
self.path_of_marker_file.write_text(generate_random_string())

def get_path(self) -> str:
return str(self.path_of_marker_file)

def is_exists(self) -> bool:
return self.path_of_marker_file.is_file()

def set_date(self, new_modification_time: datetime.datetime) -> None:
if self.is_exists():
self.path_of_marker_file.write_text(generate_random_string())

dt = new_modification_time.timestamp()
os.utime(self.path_of_marker_file, (dt, dt))

Expand Down
31 changes: 31 additions & 0 deletions e2e/test_simple_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,3 +323,34 @@ def test_download_since_last_run(

# Assert
podcast_directory.is_containing_only(expected_episode)


def test_download_since_last_run_with_no_marker_file_setup(
feed: FeedBuilder,
use_config: Callable[[Dict], None],
podcast_downloader: PodcastDownloaderRunner,
podcast_directory: PodcastDirectory,
marker_file_manager: MarkerFileManager,
):
# Arrange
feed.add_random_entries()

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

# Act
podcast_downloader.run()

# Assert
assert marker_file_manager.is_exists()
assert podcast_downloader.is_containing("Marker file")

0 comments on commit e7751ad

Please sign in to comment.