Пример #1
0
def _read_response(base_dir, filename):
    content = (Path(base_dir) / filename).read_bytes()
    builder = FeedResponseBuilder()
    builder.url('https://blog.example.com/feed')
    builder.content(content)
    response = builder.build()
    return response
Пример #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
Пример #3
0
def _create_builder(content=None):
    builder = FeedResponseBuilder()
    builder.url('https://blog.example.com/feed')
    if content is not None:
        builder.content(content)
    return builder
Пример #4
0
def _create_builder():
    builder = FeedResponseBuilder()
    builder.url('https://blog.example.com/feed.xml')
    return builder
Пример #5
0
def _build_simple_response(status):
    builder = FeedResponseBuilder()
    builder.url('https://www.example.com/feed.xml')
    builder.status(status)
    builder.headers({
        'etag': '5e8c43f8-4d269b',
        'content-type': 'application/xml',
    })
    builder.content('''
        <?xml version="1.0" encoding="utf-8"?>
        <feed xmlns="http://www.w3.org/2005/Atom">
        <title>V2EX - 技术</title>
    '''.encode('utf-8'))
    response = builder.build()
    return response
Пример #6
0
def _build_no_content_response(status):
    builder = FeedResponseBuilder()
    builder.url('https://www.example.com/feed.xml')
    builder.status(status)
    response = builder.build()
    return response