From 0baa8ce74f2170d5d5bc2aa2e19101c06f4cd8dc Mon Sep 17 00:00:00 2001 From: Akash <64683866+akamhy@users.noreply.github.com> Date: Fri, 24 Jul 2020 14:41:58 +0530 Subject: [PATCH] test archive urll parser and dunders --- tests/test_wrapper.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/test_wrapper.py b/tests/test_wrapper.py index a626d2c..b4f3ba5 100644 --- a/tests/test_wrapper.py +++ b/tests/test_wrapper.py @@ -23,6 +23,21 @@ def test_clean_url(): test_result = target._clean_url() assert answer == test_result +def test_dunders(): + url = "https://en.wikipedia.org/wiki/Network_security" + user_agent = "UA" + target = waybackpy.Url(test_url, user_agent) + assert "waybackpy.Url(url=%s, user_agent=%s)" % (url, user_agent) == repr(target) + assert len(target) == len(url) + assert str(target) == url + +def test_archive_url_parser(): + request_url = "https://amazon.com" + hdr = {"User-Agent": user_agent} # nosec + req = Request(request_url, headers=hdr) # nosec + header = _get_response(req).headers + with pytest.raises(Exception): + waybackpy._archive_url_parser(header) def test_url_check(): broken_url = "http://wwwgooglecom/"