Esempio n. 1
0
def test_raw_parse_bad_encoding():
    content = os.urandom(16 * 1024)
    response = _create_builder(content=content).build()
    parser = RawFeedParser()
    with pytest.raises(FeedParserError) as ex:
        parser.parse(response)
    assert ex
Esempio n. 2
0
def test_raw_parse_bad_encoding():
    content = os.urandom(16 * 1024)
    builder = FeedResponseBuilder()
    builder.url('https://blog.example.com/feed')
    builder.content(content)
    response = builder.build()
    parser = RawFeedParser()
    with pytest.raises(FeedParserError) as ex:
        parser.parse(response)
    assert ex
Esempio n. 3
0
def test_raw_parse_warn(filename):
    response = _read_response(_data_dir / 'warn', filename)
    parser = RawFeedParser()
    result = parser.parse(response)
    assert result
    assert result.warnings and isinstance(result.warnings, list)
    assert result.storys
    assert result.feed['version']
    assert result.feed['title']
Esempio n. 4
0
def test_parser_and_checksum(filepath):
    response = _read_response(_data_dir, filepath)
    raw_parser = RawFeedParser()
    raw_result = raw_parser.parse(response)
    assert raw_result.feed
    assert raw_result.storys
    parser = FeedParser()
    result = parser.parse(raw_result)
    assert result.feed
    assert result.storys
    assert result.checksum.size() == len(result.storys)
Esempio n. 5
0
def test_raw_parser_incomplete_content():
    response = _read_response(_data_dir / 'warn', 'https-tmioe-com-feed.xml')
    parser = RawFeedParser()
    result = parser.parse(response)
    assert len(result.storys) == 5
    assert result.feed['version'] == 'rss20'
    assert result.feed['title'] == 'ZAPRO · 杂铺'
    expect_title = "TikTok 抖音国际版 v18.6.2 解锁全部国家任意切换"
    expect_url = "https://tmioe.com/1463.html"
    got_storys = [x for x in result.storys if x['url'] == expect_url]
    assert got_storys
    assert got_storys[0]['title'] == expect_title
Esempio n. 6
0
def test_raw_parse_failed(filename):
    response = _read_response(_data_dir / 'failed', filename)
    parser = RawFeedParser()
    with pytest.raises(FeedParserError) as ex:
        parser.parse(response)
    assert ex