Skip to content

Commit

Permalink
Add feedgen library for generation example RSS
Browse files Browse the repository at this point in the history
  • Loading branch information
dplocki committed Jan 11, 2024
1 parent 76cb01b commit 30293fd
Showing 1 changed file with 31 additions and 5 deletions.
36 changes: 31 additions & 5 deletions e2e/test_sample.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import datetime
import os
import subprocess
import sys
import tempfile
import pytest
import json
from feedgen.feed import FeedGenerator


@pytest.fixture()
Expand All @@ -30,8 +32,32 @@ def create_temporary_directory():
yield tmp_dirname


def build_server():
pass
class FeedBuilder():

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' )


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))

return self


def build(self):
rss_file_name = 'podcast.xml'
self.fg.rss_file(rss_file_name)

return rss_file_name


def build_config(config_path, config_object):
Expand All @@ -40,7 +66,6 @@ def build_config(config_path, config_object):


def run_podcast_downloader():
os.system("cat ~/.podcast_downloader_config.json")
subprocess.check_call([sys.executable, "-m", "podcast_downloader"])


Expand All @@ -49,15 +74,16 @@ def check_the_download_directory():


def test_answer(secure_config_file, create_temporary_directory):
build_server()
rss_file = FeedBuilder().add_entry().add_entry().build()

build_config(
secure_config_file,
{
"podcasts": [
{
"name": "test",
"path": create_temporary_directory,
"rss_link": "feed",
"rss_link": rss_file,
}
]
},
Expand Down

0 comments on commit 30293fd

Please sign in to comment.