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
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
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
def test_rss_config_templates_list(bot): bot.memory['rss']['templates']['t'] = '†{}†' args = ['config', 'templates'] rss._rss_config(bot, args) 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
def test_rss_config_templates_list(bot): bot.memory["rss"]["templates"]["t"] = "†{}†" args = ["config", "templates"] rss._rss_config(bot, args) 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
def test_rss_config_feeds_list(bot): rss._rss_add(bot, ['add', '#channel2', 'feed2', FEED_VALID, 'f=p+tlpas']) rss._rss_formats(bot, ['format', 'feed1', 'f=asl+als']) 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=asl+als,#channel2' + rss.CONFIG_SEPARATOR + 'feed2' + rss.CONFIG_SEPARATOR + FEED_VALID + rss.CONFIG_SEPARATOR + 'f=p+tlpas\n' assert expected == bot.output
def test_rss_config_templates_output_escape_character(bot): template = rss.ESCAPE_CHARACTER + rss.ESCAPE_CHARACTER + '{}' bot.memory['rss']['templates']['s'] = template args = ['config', 'templates'] rss._rss_config(bot, args) 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
def test_rss_config_templates_pink_on_silver(bot): template = rss.ESCAPE_CHARACTER + '13$15{}' + rss.ESCAPE_CHARACTER + '20' bot.memory['rss']['templates']['d'] = template args = ['config', 'templates'] rss._rss_config(bot, args) expected = 't=a|<{}>;t=d|%13$15{}%20;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
def test_rss_config_templates_invalid_backgroundcolor(bot): template = rss.ESCAPE_CHARACTER + '04$20{}' + rss.ESCAPE_CHARACTER + '20' bot.memory['rss']['templates']['d'] = template args = ['config', 'templates'] rss._rss_config(bot, args) 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
def test_rss_config_templates_output_dollar_after_control_sequence(bot): template = rss.ESCAPE_CHARACTER + '17' + rss.ESCAPE_CHARACTER + '${}%16' bot.memory['rss']['templates']['s'] = template args = ['config', 'templates'] rss._rss_config(bot, args) expected = 't=a|<{}>;t=d|{};t=f|%16[{}]%16;t=g|{};t=l|%16→%16 {};' expected += 't=p|({});t=s|%17%${}%16;t=t|{};t=y|%16→%16 {}\n' expected += rss._config_templates_example(bot) + '\n' assert expected == bot.output
def test_rss_config_templates_output_dollar_after_control_sequence(bot): template = rss.ESCAPE_CHARACTER + "17" + rss.ESCAPE_CHARACTER + "${}%16" bot.memory["rss"]["templates"]["s"] = template args = ["config", "templates"] rss._rss_config(bot, args) expected = "t=a|<{}>;t=d|{};t=f|%16[{}]%16;t=g|{};t=l|%16→%16 {};" expected += "t=p|({});t=s|%17%${}%16;t=t|{};t=y|%16→%16 {}\n" expected += rss._config_templates_example(bot) + "\n" assert expected == bot.output
def test_rss_config_templates_output_escape_character(bot): template = rss.ESCAPE_CHARACTER + rss.ESCAPE_CHARACTER + "{}" bot.memory["rss"]["templates"]["s"] = template args = ["config", "templates"] rss._rss_config(bot, args) 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
def test_rss_config_templates_invalid_backgroundcolor(bot): template = rss.ESCAPE_CHARACTER + "04$20{}" + rss.ESCAPE_CHARACTER + "20" bot.memory["rss"]["templates"]["d"] = template args = ["config", "templates"] rss._rss_config(bot, args) 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
def test_rss_config_templates_pink_on_silver(bot): template = rss.ESCAPE_CHARACTER + "13$15{}" + rss.ESCAPE_CHARACTER + "20" bot.memory["rss"]["templates"]["d"] = template args = ["config", "templates"] rss._rss_config(bot, args) expected = "t=a|<{}>;t=d|%13$15{}%20;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
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
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
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
def test_rss_config_feeds_list(bot): rss._rss_add(bot, ["add", "#channel2", "feed2", FEED_VALID, "f=p+tlpas"]) rss._rss_formats(bot, ["format", "feed1", "f=asl+als"]) 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=asl+als,#channel2" + rss.CONFIG_SEPARATOR + "feed2" + rss.CONFIG_SEPARATOR + FEED_VALID + rss.CONFIG_SEPARATOR + "f=p+tlpas\n" ) assert expected == bot.output
def test_rss_config_formats_default(bot): rss._rss_config(bot, ['config', 'formats']) expected = 'f=' + rss.FORMAT_DEFAULT + '\n' assert expected == bot.output
def test_rss_formats_input_invalid(bot): rss._rss_config(bot, ["config", "formats", "fl+fty"]) bot.output = "" rss._rss_config(bot, ["config", "formats"]) expected = "f=fl+ftl\n" assert expected == bot.output
def test_rss_config_formats_list(bot): bot.memory['rss']['formats'] = ['lts+flts', 'at+at'] args = ['config', 'formats'] rss._rss_config(bot, args) expected = 'f=lts+flts;f=at+at;f=fl+ftl' + '\n' assert expected == bot.output
def test_rss_config_formats_list(bot): bot.memory["rss"]["formats"] = ["lts+flts", "at+at"] args = ["config", "formats"] rss._rss_config(bot, args) expected = "f=lts+flts;f=at+at;f=fl+ftl" + "\n" assert expected == bot.output
def test_rss_config_formats_default(bot): rss._rss_config(bot, ["config", "formats"]) expected = "f=" + rss.FORMAT_DEFAULT + "\n" assert expected == bot.output
def test_rss_config_invalid_key(bot): rss._rss_config(bot, ["config", "invalidkey"]) expected = "" assert expected == bot.output
def test_rss_formats_input_invalid(bot): rss._rss_config(bot, ['config', 'formats', 'fl+fty']) bot.output = '' rss._rss_config(bot, ['config', 'formats']) expected = 'f=fl+ftl\n' assert expected == bot.output
def test_rss_config_invalid_key(bot): rss._rss_config(bot, ['config', 'invalidkey']) expected = '' assert expected == bot.output