Ejemplo n.º 1
0
def test_rss_global_help_synopsis_help(bot):
    rss._rss(bot, ['help'])
    expected = rss.COMMANDS['help']['synopsis'].format(
        bot.config.core.prefix) + '\n'
    expected += rss.MESSAGES['command_is_one_of'].format('|'.join(
        sorted(rss.COMMANDS.keys()))) + '\n'
    assert expected == bot.output
Ejemplo n.º 2
0
def test_rss_global_formats_feed(bot):
    rss._rss(bot, ['formats', 'feed1', 'f=apl+atl'])
    bot.output = ''
    args = ['config', 'feeds']
    rss._rss_config(bot, args)
    expected = '#channel1' + rss.CONFIG_SEPARATOR + 'feed1' + rss.CONFIG_SEPARATOR + 'http://www.site1.com/feed' + rss.CONFIG_SEPARATOR + 'f=apl+atl\n'
    assert expected == bot.output
Ejemplo n.º 3
0
def test_rss_global_too_many_parameters(bot):
    rss._rss(bot, [
        'add', '#channel', 'feedname', FEED_VALID, 'f=fl+ftl', 'fifth_argument'
    ])
    expected = rss.COMMANDS['add']['synopsis'].format(
        bot.config.core.prefix) + '\n'
    assert expected == bot.output
Ejemplo n.º 4
0
def test_rss_global_join(bot):
    rss._rss(bot, ['join'])
    channels = []
    for feed in bot.memory['rss']['feeds']:
        feedchannel = bot.memory['rss']['feeds'][feed]['channel']
        if feedchannel not in channels:
            channels.append(feedchannel)
    assert channels == bot.config.core.channels
Ejemplo n.º 5
0
def test_rss_global_join(bot):
    rss._rss(bot, ["join"])
    channels = []
    for feed in bot.memory["rss"]["feeds"]:
        feedchannel = bot.memory["rss"]["feeds"][feed]["channel"]
        if feedchannel not in channels:
            channels.append(feedchannel)
    assert channels == bot.config.core.channels
Ejemplo n.º 6
0
def test_rss_global_list_feed_options(bot):
    rss._rss(bot, ["add", "#channel", "feed", FEED_VALID])
    rss._rss(bot, ["formats", "feed", "f=l+tl"])
    rss._rss(bot, ["templates", "feed", "t=t|%06[{}]%20"])
    bot.output = ""
    rss._rss(bot, ["list", "feed"])
    expected = "#channel feed " + FEED_VALID + " f=l+tl;t=t|%06[{}]%20\n"
    assert expected == bot.output
Ejemplo n.º 7
0
def test_rss_global_formats_feed(bot):
    rss._rss(bot, ["formats", "feed1", "f=apl+atl"])
    bot.output = ""
    args = ["config", "feeds"]
    rss._rss_config(bot, args)
    expected = (
        "#channel1"
        + rss.CONFIG_SEPARATOR
        + "feed1"
        + rss.CONFIG_SEPARATOR
        + "http://www.site1.com/feed"
        + rss.CONFIG_SEPARATOR
        + "f=apl+atl\n"
    )
    assert expected == bot.output
Ejemplo n.º 8
0
def test_rss_global_list_feed_options(bot):
    rss._rss(bot, ['add', '#channel', 'feed', FEED_VALID])
    rss._rss(bot, ['formats', 'feed', 'f=l+tl'])
    rss._rss(bot, ['templates', 'feed', 't=t|%06[{}]%20'])
    bot.output = ''
    rss._rss(bot, ['list', 'feed'])
    expected = '#channel feed ' + FEED_VALID + ' f=l+tl;t=t|%06[{}]%20\n'
    assert expected == bot.output
Ejemplo n.º 9
0
def test_rss_global_feed_delete(bot):
    rss._rss(bot, ["add", "#channel", "feedname", FEED_VALID])
    rss._rss(bot, ["del", "feedname"])
    assert rss._feed_exists(bot, "feedname") == False
Ejemplo n.º 10
0
def test_rss_global_feed_add(bot):
    rss._rss(bot, ["add", "#channel", "feedname", FEED_VALID])
    assert rss._feed_exists(bot, "feedname") == True
Ejemplo n.º 11
0
def test_rss_global_config_templates(bot):
    rss._rss(bot, ["config", "templates"])
    expected = "t=a|<{}>;t=d|{};t=f|%16[{}]%16;t=g|{};t=l|%16→%16 {};"
    expected += "t=p|({});t=s|{};t=t|{};t=y|%16→%16 {}\n"
    expected += rss._config_templates_example(bot) + "\n"
    assert expected == bot.output
Ejemplo n.º 12
0
def test_rss_global_formats_set(bot):
    rss._rss(bot, ['formats', 'feed1', 'f=asl+als'])
    format_new = bot.memory['rss']['options']['feed1'].get_format()
    assert 'f=asl+als' == format_new
Ejemplo n.º 13
0
def test_rss_global_list_feed(bot):
    rss._rss(bot, ["list", "feed1"])
    expected = "#channel1 feed1 http://www.site1.com/feed\n"
    assert expected == bot.output
Ejemplo n.º 14
0
def test_rss_global_help_synopsis_help(bot):
    rss._rss(bot, ["help"])
    expected = rss.COMMANDS["help"]["synopsis"].format(bot.config.core.prefix) + "\n"
    expected += rss.MESSAGES["command_is_one_of"].format("|".join(sorted(rss.COMMANDS.keys()))) + "\n"
    assert expected == bot.output
Ejemplo n.º 15
0
def test_rss_global_templates_get(bot):
    rss._rss(bot, ['templates', 'feed1'])
    assert '' == bot.output
Ejemplo n.º 16
0
def test_rss_global_config_templates(bot):
    rss._rss(bot, ['config', 'templates'])
    expected = 't=a|<{}>;t=d|{};t=f|%16[{}]%16;t=g|{};t=l|%16→%16 {};'
    expected += 't=p|({});t=s|{};t=t|{};t=y|%16→%16 {}\n'
    expected += rss._config_templates_example(bot) + '\n'
    assert expected == bot.output
Ejemplo n.º 17
0
def test_rss_global_list_feed(bot):
    rss._rss(bot, ['list', 'feed1'])
    expected = '#channel1 feed1 http://www.site1.com/feed\n'
    assert expected == bot.output
Ejemplo n.º 18
0
def test_rss_global_feed_add(bot):
    rss._rss(bot, ['add', '#channel', 'feedname', FEED_VALID])
    assert rss._feed_exists(bot, 'feedname') == True
Ejemplo n.º 19
0
def test_rss_global_get_post_feed_items(bot):
    rss._rss(bot, ['add', '#channel', 'feedname', FEED_VALID])
    bot.output = ''
    rss._rss(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.º 20
0
def test_rss_global_feed_delete(bot):
    rss._rss(bot, ['add', '#channel', 'feedname', FEED_VALID])
    rss._rss(bot, ['del', 'feedname'])
    assert rss._feed_exists(bot, 'feedname') == False
Ejemplo n.º 21
0
def test_rss_global_fields_get(bot):
    rss._rss(bot, ["fields", "feed1"])
    expected = rss.MESSAGES["fields_of_feed"].format("feed1", "fadglpsty") + "\n"
    assert expected == bot.output
Ejemplo n.º 22
0
def test_rss_global_templates_get(bot):
    rss._rss(bot, ["templates", "feed1"])
    assert "" == bot.output
Ejemplo n.º 23
0
def test_rss_global_formats_set(bot):
    rss._rss(bot, ["formats", "feed1", "f=asl+als"])
    format_new = bot.memory["rss"]["options"]["feed1"].get_format()
    assert "f=asl+als" == format_new
Ejemplo n.º 24
0
def test_rss_global_too_few_parameters(bot):
    rss._rss(bot, ['add', '#channel', 'feedname'])
    expected = rss.COMMANDS['add']['synopsis'].format(
        bot.config.core.prefix) + '\n'
    assert expected == bot.output
Ejemplo n.º 25
0
def test_rss_global_get_post_feed_items(bot):
    rss._rss(bot, ["add", "#channel", "feedname", FEED_VALID])
    bot.output = ""
    rss._rss(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.º 26
0
def test_rss_global_too_few_parameters(bot):
    rss._rss(bot, ["add", "#channel", "feedname"])
    expected = rss.COMMANDS["add"]["synopsis"].format(bot.config.core.prefix) + "\n"
    assert expected == bot.output
Ejemplo n.º 27
0
def test_rss_global_color(bot):
    rss._rss(bot, ['colors'])
    expected = '\x0301,00 00: white \x0f\x0300,01 01: black \x0f\x0300,02 02: blue \x0f\x0300,03 03: green \x0f\x0301,04 04: red \x0f\x0300,05 05: brown \x0f\x0300,06 06: purple \x0f\x0301,07 07: orange \x0f\x0301,08 08: yellow \x0f\x0301,09 09: lime \x0f\x0300,10 10: cyan \x0f\x0301,11 11: aqua \x0f\x0301,12 12: azure \x0f\x0301,13 13: pink \x0f\x0300,14 14: grey \x0f\x0301,15 15: silver \x0f\x0300,01 16: \x02bold\x02 \x0f\x0301,00 17: \x1ditalic\x1d \x0f\x0300,01 18: \x1funderline\x1f \x0f\n'
    assert expected == bot.output
Ejemplo n.º 28
0
def test_rss_global_color(bot):
    rss._rss(bot, ["colors"])
    expected = "\x0301,00 00: white \x0f\x0300,01 01: black \x0f\x0300,02 02: blue \x0f\x0300,03 03: green \x0f\x0301,04 04: red \x0f\x0300,05 05: brown \x0f\x0300,06 06: purple \x0f\x0301,07 07: orange \x0f\x0301,08 08: yellow \x0f\x0301,09 09: lime \x0f\x0300,10 10: cyan \x0f\x0301,11 11: aqua \x0f\x0301,12 12: azure \x0f\x0301,13 13: pink \x0f\x0300,14 14: grey \x0f\x0301,15 15: silver \x0f\x0300,01 16: \x02bold\x02 \x0f\x0301,00 17: \x1ditalic\x1d \x0f\x0300,01 18: \x1funderline\x1f \x0f\n"
    assert expected == bot.output
Ejemplo n.º 29
0
def test_rss_global_update_update(bot_rss_update):
    rss._rss(bot_rss_update, ['update'])
    expected = '\x02[feed1]\x02 Title 1 \x02→\x02 http://www.site1.com/article1\n\x02[feed1]\x02 Title 2 \x02→\x02 http://www.site1.com/article2\n\x02[feed1]\x02 Title 3 \x02→\x02 http://www.site1.com/article3\n'
    assert expected == bot_rss_update.output
Ejemplo n.º 30
0
def test_rss_global_fields_get(bot):
    rss._rss(bot, ['fields', 'feed1'])
    expected = rss.MESSAGES['fields_of_feed'].format('feed1',
                                                     'fadglpsty') + '\n'
    assert expected == bot.output
Ejemplo n.º 31
0
def test_rss_global_update_update(bot_rss_update):
    rss._rss(bot_rss_update, ["update"])
    expected = "\x02[feed1]\x02 Title 1 \x02→\x02 http://www.site1.com/article1\n\x02[feed1]\x02 Title 2 \x02→\x02 http://www.site1.com/article2\n\x02[feed1]\x02 Title 3 \x02→\x02 http://www.site1.com/article3\n"
    assert expected == bot_rss_update.output
Ejemplo n.º 32
0
def test_rss_global_too_many_parameters(bot):
    rss._rss(bot, ["add", "#channel", "feedname", FEED_VALID, "f=fl+ftl", "fifth_argument"])
    expected = rss.COMMANDS["add"]["synopsis"].format(bot.config.core.prefix) + "\n"
    assert expected == bot.output