-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
47 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,33 +32,61 @@ def create_temporary_directory(): | |
yield tmp_dirname | ||
|
||
|
||
class FeedBuilder(): | ||
@pytest.fixture() | ||
def create_origin_feed_directory(create_temporary_directory): | ||
feed_source_path = os.path.join(create_temporary_directory, "feed_source") | ||
os.makedirs(feed_source_path) | ||
yield feed_source_path | ||
|
||
|
||
@pytest.fixture() | ||
def create_download_destination_directory(create_temporary_directory): | ||
feed_destination_path = os.path.join(create_temporary_directory, "destination") | ||
os.makedirs(feed_destination_path) | ||
yield feed_destination_path | ||
|
||
def __init__(self) -> None: | ||
self.fg = FeedGenerator() | ||
self.fg.title('Some Testfeed') | ||
self.fg.author( {'name':'John Doe','email':'[email protected]'} ) | ||
self.fg.subtitle('This is a cool feed!') | ||
self.fg.link( href='http://example.com', rel='alternate' ) | ||
|
||
class FeedBuilder: | ||
def __init__(self, feed_source) -> None: | ||
self.feed_source = feed_source | ||
self.fg = FeedGenerator() | ||
self.fg.title("Some Testfeed") | ||
self.fg.author({"name": "John Doe", "email": "[email protected]"}) | ||
self.fg.subtitle("This is a cool feed!") | ||
self.fg.link(href="http://example.com", rel="alternate") | ||
|
||
def add_entry(self): | ||
fe = self.fg.add_entry() | ||
fe.id('http://lernfunk.de/media/654321/1/file.mp3') | ||
fe.title('The First Episode') | ||
fe.description('Enjoy our first episode.') | ||
fe.enclosure('http://lernfunk.de/media/654321/1/file.mp3', 0, 'audio/mpeg') | ||
fe.published(datetime.datetime(2014, 7, 10, 2, 43, 55, 230107, tzinfo=datetime.timezone.utc)) | ||
fe.id("http://lernfunk.de/media/654321/1/file.mp3") | ||
fe.title("The First Episode") | ||
fe.description("Enjoy our first episode.") | ||
fe.enclosure(f"file:///{self.feed_source}/file.mp3", 0, "audio/mpeg") | ||
fe.published( | ||
datetime.datetime( | ||
2014, 7, 10, 2, 43, 55, 230107, tzinfo=datetime.timezone.utc | ||
) | ||
) | ||
|
||
self.__add_file_in_source("file.mp3") | ||
|
||
return self | ||
|
||
|
||
def build(self): | ||
rss_file_name = 'podcast.xml' | ||
rss_file_name = "podcast.xml" | ||
self.fg.rss_file(rss_file_name) | ||
|
||
return rss_file_name | ||
|
||
def __add_file_in_source(self, file_name): | ||
path_to_file = os.path.join(self.feed_source, file_name) | ||
with open(path_to_file, "w") as file: | ||
file.write("test") | ||
|
||
|
||
@pytest.fixture() | ||
def feed_builder(create_origin_feed_directory): | ||
yield FeedBuilder(create_origin_feed_directory) | ||
|
||
|
||
def build_config(config_path, config_object): | ||
with open(config_path, "w") as file: | ||
|
@@ -73,16 +101,17 @@ def check_the_download_directory(): | |
pass | ||
|
||
|
||
def test_answer(secure_config_file, create_temporary_directory): | ||
rss_file = FeedBuilder().add_entry().add_entry().build() | ||
|
||
def test_answer( | ||
secure_config_file, feed_builder, create_download_destination_directory | ||
): | ||
rss_file = feed_builder.add_entry().add_entry().build() | ||
build_config( | ||
secure_config_file, | ||
{ | ||
"podcasts": [ | ||
{ | ||
"name": "test", | ||
"path": create_temporary_directory, | ||
"path": create_download_destination_directory, | ||
"rss_link": rss_file, | ||
} | ||
] | ||
|