Пример #1
0
def test_options_check_tinyurl_output(bot, feedreader_feed_valid):
    format = 'f=fy+ty'
    options = rss.Options(bot, feedreader_feed_valid, format)
    item = feedreader_feed_valid.get_feed().entries[0]
    post = options.get_post('feed1', item)
    expected = 'Title 3 \x02→\x02 https://tinyurl.com/govvpmm'
    assert expected == post
Пример #2
0
def test_config_concatenate_feeds(bot, feedreader_feed_valid):
    bot.memory['rss']['options']['feed1'] = rss.Options(
        bot, feedreader_feed_valid, 'f=fy+fty')
    feeds = rss._config_concatenate_feeds(bot)
    expected = [
        '#channel1' + rss.CONFIG_SEPARATOR + 'feed1' + rss.CONFIG_SEPARATOR +
        'http://www.site1.com/feed' + rss.CONFIG_SEPARATOR + 'f=fy+fty'
    ]
    assert expected == feeds
Пример #3
0
def _fixture_bot_add_data(bot, id, url):
    bot.memory['rss']['feeds']['feed' + id] = {
        'channel': '#channel' + id,
        'name': 'feed' + id,
        'url': url
    }
    bot.memory['rss']['hashes']['feed' + id] = rss.RingBuffer(100)
    feedreader = rss.MockFeedReader(FEED_VALID)
    bot.memory['rss']['options']['feed' + id] = rss.Options(bot, feedreader)
    sql_create_table = 'CREATE TABLE ' + rss._digest_tablename(
        'feed' + id) + ' (id INTEGER PRIMARY KEY, hash VARCHAR(32) UNIQUE)'
    bot.db.execute(sql_create_table)
    bot.config.core.channels = ['#channel' + id]
    return bot
Пример #4
0
def test_options_check_template_invalid_duplicate_curly_braces(bot):
    template = '{}{}'
    result = rss.Options(bot, rss.FeedReader('')).is_template_valid(template)
    assert False == result
Пример #5
0
def test_options_check_template_valid(bot):
    template = '{}'
    result = rss.Options(bot, rss.FeedReader('')).is_template_valid(template)
    assert True == result
Пример #6
0
def test_options_check_format_duplicate_field_output(bot,
                                                     feedreader_feed_valid):
    format = 'f=l+tll'
    options = rss.Options(bot, feedreader_feed_valid, format)
    assert format != options.get_format()
Пример #7
0
def test_options_check_format_tinyurl(bot, feedreader_feed_valid):
    format = 'f=fy+ty'
    options = rss.Options(bot, feedreader_feed_valid, format)
    assert format == options.get_format()
Пример #8
0
def test_options_check_format_output_only_feedname(bot, feedreader_feed_valid):
    format = 'f=t+f'
    options = rss.Options(bot, feedreader_feed_valid, format)
    assert format != options.get_format()
Пример #9
0
def test_options_check_format_duplicate_separator(bot, feedreader_feed_valid):
    format = 'f=t+t+t'
    options = rss.Options(bot, feedreader_feed_valid, format)
    assert format != options.get_format()
Пример #10
0
def test_options_check_format_hashed_empty(bot, feedreader_feed_valid):
    format = 'f=+t'
    options = rss.Options(bot, feedreader_feed_valid, format)
    assert format != options.get_format()
Пример #11
0
def test_options_check_format_default(bot, feedreader_feed_valid):
    options = rss.Options(bot, feedreader_feed_valid)
    assert options.get_format_default() == options.get_format()
Пример #12
0
def test_options_get_fields_feed_item_neither_title_nor_description(
        bot, feedreader_feed_item_neither_title_nor_description):
    options = rss.Options(bot,
                          feedreader_feed_item_neither_title_nor_description)
    fields = options.get_fields()
    assert 'd' not in fields and 't' not in fields
Пример #13
0
def test_options_get_fields_feed_valid(bot, feedreader_feed_valid):
    options = rss.Options(bot, feedreader_feed_valid)
    fields = options.get_fields()
    assert 'fadglpsty' == fields
Пример #14
0
def test_options_get_format_custom(bot, feedreader_feed_valid):
    options = rss.Options(bot, feedreader_feed_valid, 'f=ta+ta')
    assert 'f=ta+ta' == options.get_format()