Skip to content

Commit

Permalink
Introduce files to download
Browse files Browse the repository at this point in the history
  • Loading branch information
dplocki committed Jan 12, 2024
1 parent 30293fd commit 3cd0209
Showing 1 changed file with 47 additions and 18 deletions.
65 changes: 47 additions & 18 deletions e2e/test_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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,
}
]
Expand Down

0 comments on commit 3cd0209

Please sign in to comment.