inc coverage
This commit is contained in:
parent
5dec4927cd
commit
bd079978bf
@ -2,6 +2,7 @@ import sys
|
|||||||
import pytest
|
import pytest
|
||||||
import random
|
import random
|
||||||
import requests
|
import requests
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
sys.path.append("..")
|
sys.path.append("..")
|
||||||
|
|
||||||
@ -20,6 +21,12 @@ def test_cleaned_url():
|
|||||||
assert answer == test_result
|
assert answer == test_result
|
||||||
|
|
||||||
|
|
||||||
|
def test_ts():
|
||||||
|
a = waybackpy.Url("https://google.com", user_agent)
|
||||||
|
ts = a._timestamp
|
||||||
|
assert str(datetime.utcnow().year) in str(ts)
|
||||||
|
|
||||||
|
|
||||||
def test_dunders():
|
def test_dunders():
|
||||||
"""No API use"""
|
"""No API use"""
|
||||||
url = "https://en.wikipedia.org/wiki/Network_security"
|
url = "https://en.wikipedia.org/wiki/Network_security"
|
||||||
@ -47,6 +54,26 @@ def test_archive_url_parser():
|
|||||||
)
|
)
|
||||||
assert "web.archive.org/web/20210102094009" in archive
|
assert "web.archive.org/web/20210102094009" in archive
|
||||||
|
|
||||||
|
header = """
|
||||||
|
vhgvkjv
|
||||||
|
Content-Location: /web/20201126185327/https://www.scribbr.com/citing-sources/et-al
|
||||||
|
ghvjkbjmmcmhj
|
||||||
|
"""
|
||||||
|
archive = waybackpy._archive_url_parser(
|
||||||
|
header, "https://www.scribbr.com/citing-sources/et-al/"
|
||||||
|
)
|
||||||
|
assert "20201126185327" in archive
|
||||||
|
|
||||||
|
header = """
|
||||||
|
hfjkfjfcjhmghmvjm
|
||||||
|
X-Cache-Key: https://web.archive.org/web/20171128185327/https://www.scribbr.com/citing-sources/et-al/US
|
||||||
|
yfu,u,gikgkikik
|
||||||
|
"""
|
||||||
|
archive = waybackpy._archive_url_parser(
|
||||||
|
header, "https://www.scribbr.com/citing-sources/et-al/"
|
||||||
|
)
|
||||||
|
assert "20171128185327" in archive
|
||||||
|
|
||||||
# The below header should result in Exception
|
# The below header should result in Exception
|
||||||
no_archive_header = """
|
no_archive_header = """
|
||||||
{'Server': 'nginx/1.15.8', 'Date': 'Sat, 02 Jan 2021 09:42:45 GMT', 'Content-Type': 'text/html; charset=utf-8', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'Cache-Control': 'no-cache', 'X-App-Server': 'wwwb-app52', 'X-ts': '523', 'X-RL': '0', 'X-Page-Cache': 'MISS', 'X-Archive-Screenname': '0'}
|
{'Server': 'nginx/1.15.8', 'Date': 'Sat, 02 Jan 2021 09:42:45 GMT', 'Content-Type': 'text/html; charset=utf-8', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'Cache-Control': 'no-cache', 'X-App-Server': 'wwwb-app52', 'X-ts': '523', 'X-RL': '0', 'X-Page-Cache': 'MISS', 'X-Archive-Screenname': '0'}
|
||||||
@ -137,7 +164,9 @@ def test_near():
|
|||||||
def test_oldest():
|
def test_oldest():
|
||||||
url = "github.com/akamhy/waybackpy"
|
url = "github.com/akamhy/waybackpy"
|
||||||
target = waybackpy.Url(url, user_agent)
|
target = waybackpy.Url(url, user_agent)
|
||||||
assert "20200504141153" in str(target.oldest())
|
o = target.oldest()
|
||||||
|
assert "20200504141153" in str(o)
|
||||||
|
assert "2020-05-04" in str(o._timestamp)
|
||||||
|
|
||||||
|
|
||||||
def test_json():
|
def test_json():
|
||||||
|
Loading…
Reference in New Issue
Block a user