Format and lint codes and fix packaging (#125)
* add: configure files (setup.py->setup.py+setup.cfg+pyproject.toml) * add: __download_url__ * format with black and isort * fix: flake8 section in setup.cfg * add: E501 to flake ignore * fix: metadata.name does not accept attr * fix: merge __version__.py into __init__.py * fix: flake8 errors in tests/ * fix: datetime.datetime -> datetime * fix: banner * fix: ignore W605 for banner * fix: way to install deps in CI * add: versem to setuptools * fix: drop python<=3.6 (#126) from package and CI
This commit is contained in:
@ -1,21 +1,24 @@
|
||||
import pytest
|
||||
import random
|
||||
import string
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
import pytest
|
||||
|
||||
from waybackpy.availability_api import WaybackMachineAvailabilityAPI
|
||||
from waybackpy.exceptions import (
|
||||
InvalidJSONInAvailabilityAPIResponse,
|
||||
ArchiveNotInAvailabilityAPIResponse,
|
||||
InvalidJSONInAvailabilityAPIResponse,
|
||||
)
|
||||
|
||||
now = datetime.utcnow()
|
||||
url = "https://example.com/"
|
||||
user_agent = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36"
|
||||
|
||||
rndstr = lambda n: "".join(
|
||||
random.choice(string.ascii_uppercase + string.digits) for _ in range(n)
|
||||
)
|
||||
|
||||
def rndstr(n):
|
||||
return "".join(
|
||||
random.choice(string.ascii_uppercase + string.digits) for _ in range(n)
|
||||
)
|
||||
|
||||
|
||||
def test_oldest():
|
||||
@ -57,7 +60,7 @@ def test_invalid_json():
|
||||
"""
|
||||
with pytest.raises(InvalidJSONInAvailabilityAPIResponse):
|
||||
availability_api = WaybackMachineAvailabilityAPI(url="", user_agent=user_agent)
|
||||
archive_url = availability_api.archive_url
|
||||
_ = availability_api.archive_url
|
||||
|
||||
|
||||
def test_no_archive():
|
||||
@ -73,7 +76,7 @@ def test_no_archive():
|
||||
availability_api = WaybackMachineAvailabilityAPI(
|
||||
url="https://%s.cn" % rndstr(30), user_agent=user_agent
|
||||
)
|
||||
archive_url = availability_api.archive_url
|
||||
_ = availability_api.archive_url
|
||||
|
||||
|
||||
def test_no_api_call_str_repr():
|
||||
|
@ -1,4 +1,3 @@
|
||||
import pytest
|
||||
from datetime import datetime
|
||||
|
||||
from waybackpy.cdx_snapshot import CDXSnapshot
|
||||
|
@ -1,13 +1,14 @@
|
||||
import pytest
|
||||
from waybackpy.exceptions import WaybackError
|
||||
|
||||
from waybackpy.cdx_utils import (
|
||||
get_total_pages,
|
||||
check_collapses,
|
||||
check_filters,
|
||||
check_match_type,
|
||||
full_url,
|
||||
get_response,
|
||||
check_filters,
|
||||
check_collapses,
|
||||
check_match_type,
|
||||
get_total_pages,
|
||||
)
|
||||
from waybackpy.exceptions import WaybackError
|
||||
|
||||
|
||||
def test_get_total_pages():
|
||||
@ -86,10 +87,10 @@ def test_check_collapses():
|
||||
|
||||
|
||||
def test_check_match_type():
|
||||
assert None == check_match_type(None, "url")
|
||||
assert check_match_type(None, "url") is None
|
||||
match_type = "exact"
|
||||
url = "test_url"
|
||||
assert None == check_match_type(match_type, url)
|
||||
assert check_match_type(match_type, url) is None
|
||||
|
||||
url = "has * in it"
|
||||
with pytest.raises(WaybackError):
|
||||
|
@ -1,15 +1,18 @@
|
||||
import pytest
|
||||
import time
|
||||
import random
|
||||
import string
|
||||
import time
|
||||
from datetime import datetime
|
||||
|
||||
from waybackpy.save_api import WaybackMachineSaveAPI
|
||||
from waybackpy.exceptions import MaximumSaveRetriesExceeded
|
||||
import pytest
|
||||
|
||||
rndstr = lambda n: "".join(
|
||||
random.choice(string.ascii_uppercase + string.digits) for _ in range(n)
|
||||
)
|
||||
from waybackpy.exceptions import MaximumSaveRetriesExceeded
|
||||
from waybackpy.save_api import WaybackMachineSaveAPI
|
||||
|
||||
|
||||
def rndstr(n):
|
||||
return "".join(
|
||||
random.choice(string.ascii_uppercase + string.digits) for _ in range(n)
|
||||
)
|
||||
|
||||
|
||||
def test_save():
|
||||
@ -23,8 +26,9 @@ def test_save():
|
||||
cached_save = save_api.cached_save
|
||||
assert cached_save in [True, False]
|
||||
assert archive_url.find("github.com/akamhy/waybackpy") != -1
|
||||
assert timestamp is not None
|
||||
assert str(headers).find("github.com/akamhy/waybackpy") != -1
|
||||
assert type(save_api.timestamp()) == type(datetime(year=2020, month=10, day=2))
|
||||
assert isinstance(save_api.timestamp(), datetime)
|
||||
|
||||
|
||||
def test_max_redirect_exceeded():
|
||||
|
@ -1,9 +1,9 @@
|
||||
from waybackpy import __version__
|
||||
from waybackpy.utils import (
|
||||
latest_version_pypi,
|
||||
latest_version_github,
|
||||
DEFAULT_USER_AGENT,
|
||||
latest_version_github,
|
||||
latest_version_pypi,
|
||||
)
|
||||
from waybackpy.__version__ import __version__
|
||||
|
||||
|
||||
def test_default_user_agent():
|
||||
|
Reference in New Issue
Block a user