2020-05-05 12:59:55 +02:00
|
|
|
import sys
|
|
|
|
import pytest
|
2020-07-18 13:09:35 +02:00
|
|
|
import random
|
2020-12-13 10:35:57 +01:00
|
|
|
import requests
|
2021-01-03 20:14:55 +01:00
|
|
|
from datetime import datetime
|
2020-12-13 20:48:04 +01:00
|
|
|
|
2021-01-23 16:38:21 +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"
|
|
|
|
|
2020-07-22 06:39:14 +02:00
|
|
|
|
2021-01-02 14:22:46 +01:00
|
|
|
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-07-22 06:39:14 +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"
|
2020-07-22 06:39:14 +02:00
|
|
|
)
|
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-07-22 06:39:14 +02:00
|
|
|
|
2020-05-07 05:29:09 +02:00
|
|
|
|
2020-10-16 15:55:45 +02:00
|
|
|
def test_json():
|
|
|
|
url = "github.com/akamhy/waybackpy"
|
2021-01-09 21:53:53 +01:00
|
|
|
target = Url(url, user_agent)
|
2020-10-16 15:55:45 +02:00
|
|
|
assert "archived_snapshots" in str(target.JSON)
|