def test_rss_formats_format_unchanged(bot): format_old = bot.memory['rss']['options']['feed1'].get_format() rss._rss_formats(bot, ['format', 'feed1', 'f=abcd+efgh']) format_new = bot.memory['rss']['options']['feed1'].get_format() assert format_old == format_new expected = rss.MESSAGES['consider_rss_fields'].format( bot.config.core.prefix, 'feed1') + '\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 + 'https://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_formats_format_output(bot_rss_update): rss._rss_formats(bot_rss_update, ['format', 'feed1', 'f=fadglpst+fadglpst']) rss._rss_update(bot_rss_update, ['update']) expected = 'f=fadglpst+fadglpst' + ''' \x02[feed1]\x02 <Author 1> Description of article 1 1 at https://www.site1.com/ \x02→\x02 https://www.site1.com/article1 (2016-08-21 01:10) Description of article 1 Title 1 \x02[feed1]\x02 <Author 2> Description of article 2 2 at https://www.site1.com/ \x02→\x02 https://www.site1.com/article2 (2016-08-22 02:20) Description of article 2 Title 2 \x02[feed1]\x02 <Author 3> Description of article 3 3 at https://www.site1.com/ \x02→\x02 https://www.site1.com/article3 (2016-08-23 03:30) Description of article 3 Title 3 ''' assert expected == bot_rss_update.output
def test_rss_formats_changes_are_saved(bot): rss._rss_formats(bot, ['format', 'feed1', 'f=asl+als']) expected = ['#channel1;feed1;https://www.site1.com/feed;f=asl+als'] assert expected == bot.config.rss.feeds
def test_rss_formats_format_set(bot): rss._rss_formats(bot, ['format', 'feed1', 'f=asl+als']) format_new = bot.memory['rss']['options']['feed1'].get_format() assert 'f=asl+als' == format_new
def test_rss_formats_format_changed(bot): format_old = bot.memory['rss']['options']['feed1'].get_format() rss._rss_formats(bot, ['format', 'feed1', 'f=asl+als']) format_new = bot.memory['rss']['options']['feed1'].get_format() assert format_old != format_new
def test_rss_formats_feed_get(bot): rss._rss_formats(bot, ['format', 'feed1', 'f=yt+ytl']) bot.output = '' rss._rss_formats(bot, ['format', 'feed1']) expected = 'f=yt+ytl\n' assert expected == bot.output
def test_rss_formats_feed_nonexistent(bot): rss._rss_formats(bot, ['format', 'abcd']) expected = rss.MESSAGES['feed_does_not_exist'].format('abcd') + '\n' assert expected == bot.output