Adding tests and some minor tweaks to structure.

This commit is contained in:
Michael Lazar
2018-10-01 00:45:09 -04:00
parent 67fb93b2ef
commit e4cced27eb
5 changed files with 158 additions and 49 deletions

View File

@@ -617,3 +617,17 @@ def test_content_rate_limit(reddit, oauth, refresh_token):
# Even though the headers were returned, the rate limiting should
# still not be triggering a delay for the next request
assert reddit.handler.next_request_timestamp is None
def test_content_extract_links():
# Should handle relative & absolute links, should ignore empty links.
html = """
<a href='/'>Home Page</a>
<a href='https://www.github.com'>Github</a>
<a>Blank</a>
"""
assert Content.extract_links(html) == [
{'href': 'https://www.reddit.com/', 'text': 'Home Page'},
{'href': 'https://www.github.com', 'text': 'Github'}
]