Ejemplo n.º 1
0
def test_rss_config_formats_output(bot):
    rss._rss_config(bot, ["config", "formats", "f=t+t"])
    rss._rss_add(bot, ["add", "#channel", "feedname", FEED_VALID])
    bot.output = ""
    rss._rss_get(bot, ["get", "feedname"])
    expected = "Title 1\nTitle 2\nTitle 3\n"
    assert expected == bot.output
Ejemplo n.º 2
0
def test_rss_config_formats_output(bot):
    rss._rss_config(bot, ['config', 'formats', 'f=t+t'])
    rss._rss_add(bot, ['add', '#channel', 'feedname', FEED_VALID])
    bot.output = ''
    rss._rss_get(bot, ['get', 'feedname'])
    expected = 'Title 1\nTitle 2\nTitle 3\n'
    assert expected == bot.output
Ejemplo n.º 3
0
def test_rss_templates_override(bot):
    format_add = "f=l+agpt"
    templates_add = "t=t" + rss.TEMPLATE_SEPARATOR + "addtitle:{}"
    templates_add += rss.CONFIG_SEPARATOR
    templates_add += "t=g" + rss.TEMPLATE_SEPARATOR + "addguid:{}"
    options = templates_add + rss.CONFIG_SEPARATOR + format_add
    templates_feed = "t=t" + rss.TEMPLATE_SEPARATOR + "feedtitle:{}"
    templates_feed += rss.CONFIG_SEPARATOR
    templates_feed += "t=a" + rss.TEMPLATE_SEPARATOR + "feedauthor:{}"
    templates_default = "t=t" + rss.TEMPLATE_SEPARATOR + "defaulttitle:{}"
    templates_default += rss.CONFIG_SEPARATOR
    templates_default += "t=p" + rss.TEMPLATE_SEPARATOR + "defaultpublished:{}"
    templates_default += rss.CONFIG_SEPARATOR
    templates_default += "t=g" + rss.TEMPLATE_SEPARATOR + "defaultguid:{}"
    rss._rss_add(bot, ["add", "#channel", "feed", FEED_VALID, options])
    rss._rss_templates(bot, ["templates", "feed", templates_feed])
    rss._rss_config(bot, ["config", "templates", templates_default])
    bot.output = ""
    rss._rss_get(bot, ["get", "feed"])
    expected = "feedauthor:Author 1 addguid:1 at http://www.site1.com/ defaultpublished:2016-08-21 01:10 feedtitle:Title 1\nfeedauthor:Author 2 addguid:2 at http://www.site1.com/ defaultpublished:2016-08-22 02:20 feedtitle:Title 2\nfeedauthor:Author 3 addguid:3 at http://www.site1.com/ defaultpublished:2016-08-23 03:30 feedtitle:Title 3\n"
    assert expected == bot.output
Ejemplo n.º 4
0
def test_rss_templates_override(bot):
    format_add = 'f=l+agpt'
    templates_add = 't=t' + rss.TEMPLATE_SEPARATOR + 'addtitle:{}'
    templates_add += rss.CONFIG_SEPARATOR
    templates_add += 't=g' + rss.TEMPLATE_SEPARATOR + 'addguid:{}'
    options = templates_add + rss.CONFIG_SEPARATOR + format_add
    templates_feed = 't=t' + rss.TEMPLATE_SEPARATOR + 'feedtitle:{}'
    templates_feed += rss.CONFIG_SEPARATOR
    templates_feed += 't=a' + rss.TEMPLATE_SEPARATOR + 'feedauthor:{}'
    templates_default = 't=t' + rss.TEMPLATE_SEPARATOR + 'defaulttitle:{}'
    templates_default += rss.CONFIG_SEPARATOR
    templates_default += 't=p' + rss.TEMPLATE_SEPARATOR + 'defaultpublished:{}'
    templates_default += rss.CONFIG_SEPARATOR
    templates_default += 't=g' + rss.TEMPLATE_SEPARATOR + 'defaultguid:{}'
    rss._rss_add(bot, ['add', '#channel', 'feed', FEED_VALID, options])
    rss._rss_templates(bot, ['templates', 'feed', templates_feed])
    rss._rss_config(bot, ['config', 'templates', templates_default])
    bot.output = ''
    rss._rss_get(bot, ['get', 'feed'])
    expected = 'feedauthor:Author 1 addguid:1 at http://www.site1.com/ defaultpublished:2016-08-21 01:10 feedtitle:Title 1\nfeedauthor:Author 2 addguid:2 at http://www.site1.com/ defaultpublished:2016-08-22 02:20 feedtitle:Title 2\nfeedauthor:Author 3 addguid:3 at http://www.site1.com/ defaultpublished:2016-08-23 03:30 feedtitle:Title 3\n'
    assert expected == bot.output
Ejemplo n.º 5
0
def test_rss_get_feed_spy(bot):
    rss._feed_add(bot, "#channel", "SPY", FEED_SPY)
    rss._rss_get(bot, ["get", "SPY"])
    expected = "\x02[SPY]\x02 Deutsche Bank Predicts 10% Pullback in S&P 500 \x02→\x02 http://markets.financialcontent.com/stocks/news/read?GUID=32821698&Symbol=SPY\n"
    assert expected == bot.output
Ejemplo n.º 6
0
def test_rss_get_post_feed_items(bot):
    rss._feed_add(bot, "#channel", "feedname", FEED_VALID)
    rss._rss_get(bot, ["get", "feedname"])
    expected = "\x02[feedname]\x02 Title 1 \x02→\x02 http://www.site1.com/article1\n\x02[feedname]\x02 Title 2 \x02→\x02 http://www.site1.com/article2\n\x02[feedname]\x02 Title 3 \x02→\x02 http://www.site1.com/article3\n"
    assert expected == bot.output
Ejemplo n.º 7
0
def test_rss_get_feed_nonexistent(bot):
    rss._rss_get(bot, ["get", "abcd"])
    expected = rss.MESSAGES["feed_does_not_exist"].format("abcd") + "\n"
    assert expected == bot.output
Ejemplo n.º 8
0
def test_rss_get_feed_spy(bot):
    rss._feed_add(bot, '#channel', 'SPY', FEED_SPY)
    rss._rss_get(bot, ['get', 'SPY'])
    expected = '\x02[SPY]\x02 Deutsche Bank Predicts 10% Pullback in S&P 500 \x02→\x02 http://markets.financialcontent.com/stocks/news/read?GUID=32821698&Symbol=SPY\n'
    assert expected == bot.output
Ejemplo n.º 9
0
def test_rss_get_post_feed_items(bot):
    rss._feed_add(bot, '#channel', 'feedname', FEED_VALID)
    rss._rss_get(bot, ['get', 'feedname'])
    expected = '\x02[feedname]\x02 Title 1 \x02→\x02 http://www.site1.com/article1\n\x02[feedname]\x02 Title 2 \x02→\x02 http://www.site1.com/article2\n\x02[feedname]\x02 Title 3 \x02→\x02 http://www.site1.com/article3\n'
    assert expected == bot.output
Ejemplo n.º 10
0
def test_rss_get_feed_nonexistent(bot):
    rss._rss_get(bot, ['get', 'abcd'])
    expected = rss.MESSAGES['feed_does_not_exist'].format('abcd') + '\n'
    assert expected == bot.output