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
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
def _create_builder(content=None): builder = FeedResponseBuilder() builder.url('https://blog.example.com/feed') if content is not None: builder.content(content) return builder
def _create_builder(): builder = FeedResponseBuilder() builder.url('https://blog.example.com/feed.xml') return builder
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
def _build_no_content_response(status): builder = FeedResponseBuilder() builder.url('https://www.example.com/feed.xml') builder.status(status) response = builder.build() return response