waybackpy/tests/test_wrapper.py

29 lines
691 B
Python
Raw Normal View History

2020-05-05 12:59:55 +02:00
import pytest
2020-12-13 20:48:04 +01:00
from waybackpy.wrapper import Url
2020-11-21 12:30:11 +01:00
2020-05-05 12:59:55 +02:00
user_agent = "Mozilla/5.0 (Windows NT 6.2; rv:20.0) Gecko/20121202 Firefox/20.0"
def test_url_check():
"""No API Use"""
broken_url = "http://wwwgooglecom/"
with pytest.raises(Exception):
2021-01-09 21:53:53 +01:00
Url(broken_url, user_agent)
2020-05-05 12:59:55 +02:00
2020-05-05 12:59:55 +02:00
def test_near():
2020-11-21 12:30:11 +01:00
with pytest.raises(Exception):
NeverArchivedUrl = (
"https://ee_3n.wrihkeipef4edia.org/rwti5r_ki/Nertr6w_rork_rse7c_urity"
)
2021-01-09 21:53:53 +01:00
target = Url(NeverArchivedUrl, user_agent)
2020-11-21 12:30:11 +01:00
target.near(year=2010)
2020-05-07 05:29:09 +02:00
def test_json():
url = "github.com/akamhy/waybackpy"
2021-01-09 21:53:53 +01:00
target = Url(url, user_agent)
assert "archived_snapshots" in str(target.JSON)