From 40cd270a8e2723d075a5bf97e4ae7a853cf9136b Mon Sep 17 00:00:00 2001 From: Akash <64683866+akamhy@users.noreply.github.com> Date: Mon, 20 Jul 2020 09:52:16 +0530 Subject: [PATCH] Update test_1.py --- tests/test_1.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tests/test_1.py b/tests/test_1.py index 74785c5..c63af3c 100644 --- a/tests/test_1.py +++ b/tests/test_1.py @@ -5,6 +5,11 @@ import waybackpy import pytest import random import time +if sys.version_info >= (3, 0): # If the python ver >= 3 + from urllib.request import Request, urlopen + from urllib.error import URLError +else: # For python2.x + from urllib2 import Request, urlopen, URLError user_agent = "Mozilla/5.0 (Windows NT 6.2; rv:20.0) Gecko/20121202 Firefox/20.0" @@ -105,7 +110,13 @@ def test_get(): def test_wayback_timestamp(): ts = waybackpy.Url("https://www.google.com","UA").wayback_timestamp(year=2020,month=1,day=2,hour=3,minute=4) - assert "202001020304" in ts + assert "202001020304" in str(ts) + +def test_get_response(): + hdr = { 'User-Agent' : 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0'} + req = Request("https://www.google.com", headers=hdr) # nosec + response = waybackpy.Url("https://www.google.com","UA").get_response(req) + assert str(type(response)) == "" def test_total_archives(): time.sleep(10)