示例#1
0
def test_find_channel_file():
    expected = {
        "title": "All About Everything",
        "description": "A show about everything",
        "url": "http://www.example.com/podcasts/everything/index.html",
    }
    assert expected == load_channel_file(Path(HERE) / "test_data" / "0")
示例#2
0
def main(directory, debug):
    basicConfig(level=INFO if debug else ERROR, stream=stderr)
    getLogger(__name__).info("started")
    channel_dict = load_channel_file(Path(directory))
    stdout.buffer.write(
        generate_feed(channel_dict,
                      find_files(channel_dict["url"], Path(directory))))
示例#3
0
def test_feed_with_some_files():
    channel_dict = load_channel_file(Path(HERE) / "test_data" / "0")
    files = find_files("http://example.com", Path(HERE) / "test_data" / "0")
    feed = generate_feed(channel_dict, files)
    tree = etree.fromstring(feed)
    items = tree.findall("channel")[0].findall("item")
    expected_titles = ["Some silence", "More silence", "Even more silence"]
    assert expected_titles == [i.findall("title")[0].text for i in items]
示例#4
0
def test_feed_with_some_files():
    channel_dict = load_channel_file(Path(HERE) / "test_data" / "0")
    files = find_files("http://example.com", Path(HERE) / "test_data" / "0")
    feed = generate_feed(channel_dict, files)
    tree = etree.fromstring(feed)
    items = tree.findall("channel")[0].findall("item")
    expected_titles = ['Some silence', 'More silence', 'Even more silence']
    assert expected_titles == [i.findall("title")[0].text for i in items]
示例#5
0
def test_feed_with_no_files():
    channel_dict = load_channel_file(Path(HERE) / "test_data" / "0")
    feed = generate_feed(channel_dict, [])
    tree = etree.fromstring(feed)
    channel = tree.findall("channel")[0]
    assert channel.findall("title")[0].text == channel_dict["title"]
    assert channel.findall(
        "description")[0].text == channel_dict["description"]
    assert channel.findall("link")[0].text == channel_dict["url"]
示例#6
0
def main(directory, debug):
    basicConfig(level=INFO if debug else ERROR, stream=stderr)
    getLogger(__name__).info("started")
    channel_dict = load_channel_file(Path(directory))
    stdout.buffer.write(
        generate_feed(
            channel_dict,
            find_files(channel_dict["url"], Path(directory)))
    )
示例#7
0
def test_feed_with_no_files():
    channel_dict = load_channel_file(Path(HERE) / "test_data" / "0")
    feed = generate_feed(channel_dict, [])
    tree = etree.fromstring(feed)
    channel = tree.findall("channel")[0]
    assert channel.findall("title")[0].text == channel_dict["title"]
    assert (
        channel.findall("description")[0].text == channel_dict["description"]
    )
    assert channel.findall("link")[0].text == channel_dict["url"]
示例#8
0
def main(directory: str, debug: bool, output_file: str) -> None:
    basicConfig(level=INFO if debug else ERROR, stream=stderr)
    getLogger(__name__).info("started")
    channel_dict = load_channel_file(Path(directory))
    if not channel_dict["base_url"].endswith("/"):
        getLogger(__name__).error("base_url should end with a /")
        exit(1)
    feed = generate_feed(
        channel_dict, output_file, find_files(channel_dict["base_url"], Path(directory))
    )
    with open(output_file, "wb") as output_f:
        output_f.write(feed)