diff --git a/tests/test_helpers.py b/tests/test_helpers.py index 6e3fc8ea4..f5a37b5a0 100644 --- a/tests/test_helpers.py +++ b/tests/test_helpers.py @@ -14,12 +14,15 @@ sys.path.append(os.path.realpath(os.pardir)) import webcompat +from webcompat.helpers import format_link_header from webcompat.helpers import normalize_api_params +from webcompat.helpers import parse_link_header from webcompat.helpers import rewrite_and_sanitize_link from webcompat.helpers import rewrite_links from webcompat.helpers import sanitize_link + ACCESS_TOKEN_LINK = '; rel="next", ; rel="last", ; rel="first", ; rel="prev"' GITHUB_ISSUES_LINK_HEADER = '; rel="next", ; rel="last", ; rel="first", ; rel="prev"' GITHUB_SEARCH_LINK_HEADER = '; rel="next", ; rel="last"' @@ -94,5 +97,17 @@ def test_normalize_api_params_ignores_unknown_params(self): normalize_api_params({'foo': u'bar', 'direction': u'desc'})) + def test_parse_http_link_headers(self): + '''Test HTTP Links parsing for GitHub only.''' + parsed_headers = [{'link': 'https://api.github.com/repositories/17914657/issues?page=2', 'rel': 'next'}, {'link': 'https://api.github.com/repositories/17914657/issues?page=11', 'rel': 'last'}] + link_header = '; rel="next", ; rel="last"' + self.assertEqual(parse_link_header(link_header), parsed_headers) + + def test_format_http_link_headers(self): + '''Test HTTP Links formating.''' + parsed_headers = [{'link': 'https://api.github.com/repositories/17914657/issues?page=2', 'rel': 'next'}, {'link': 'https://api.github.com/repositories/17914657/issues?page=11', 'rel': 'last'}] + link_header = '; rel="next", ; rel="last"' + self.assertEqual(format_link_header(parsed_headers), link_header) + if __name__ == '__main__': unittest.main() diff --git a/tests/test_urls.py b/tests/test_urls.py index 81c061cb1..123abdf52 100644 --- a/tests/test_urls.py +++ b/tests/test_urls.py @@ -15,10 +15,6 @@ import webcompat from webcompat.issues import filter_new -from webcompat.helpers import format_link_header -from webcompat.helpers import parse_link_header -from webcompat.helpers import rewrite_links -from webcompat.helpers import sanitize_link # Any request that depends on parsing HTTP Headers (basically anything # on the index route, will need to include the following: environ_base=headers @@ -109,29 +105,6 @@ def test_issues_new(self): result = '[{"labels": [{"name": "bug"}, {"name": "help wanted"}], "id": 0, "title": "fake bug 0"}, {"labels": [], "id": 1, "title": "fake bug 1"}]' self.assertEqual(filter_new(issues), result) - def test_parse_http_link_headers(self): - '''Test HTTP Links parsing for GitHub only.''' - parsed_headers = [{'link': 'https://api.github.com/repositories/17914657/issues?page=2', 'rel': 'next'}, {'link': 'https://api.github.com/repositories/17914657/issues?page=11', 'rel': 'last'}] - link_header = '; rel="next", ; rel="last"' - self.assertEqual(parse_link_header(link_header), parsed_headers) - - def test_format_http_link_headers(self): - '''Test HTTP Links formating.''' - parsed_headers = [{'link': 'https://api.github.com/repositories/17914657/issues?page=2', 'rel': 'next'}, {'link': 'https://api.github.com/repositories/17914657/issues?page=11', 'rel': 'last'}] - link_header = '; rel="next", ; rel="last"' - self.assertEqual(format_link_header(parsed_headers), link_header) - - def test_rewrite_links(self): - '''Test the rewriting is correct.''' - link_header_1 = '; rel="next", ; rel="last"' - rewritten_header_1 = '; rel="next", ; rel="last"' - self.assertEqual(rewrite_links(link_header_1), rewritten_header_1) - - def test_sanitize_link(self): - '''Test the sanitization.''' - link_header = '; rel="next", ; rel="last"' - rewritten_header = '; rel="next", ; rel="last"' - self.assertEqual(sanitize_link(link_header), rewritten_header) if __name__ == '__main__': unittest.main()