e61447effd
* 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
41 lines
1.3 KiB
Python
41 lines
1.3 KiB
Python
from datetime import datetime
|
|
|
|
from waybackpy.cdx_snapshot import CDXSnapshot
|
|
|
|
|
|
def test_CDXSnapshot():
|
|
sample_input = "org,archive)/ 20080126045828 http://github.com text/html 200 Q4YULN754FHV2U6Q5JUT6Q2P57WEWNNY 1415"
|
|
prop_values = sample_input.split(" ")
|
|
properties = {}
|
|
(
|
|
properties["urlkey"],
|
|
properties["timestamp"],
|
|
properties["original"],
|
|
properties["mimetype"],
|
|
properties["statuscode"],
|
|
properties["digest"],
|
|
properties["length"],
|
|
) = prop_values
|
|
|
|
snapshot = CDXSnapshot(properties)
|
|
|
|
assert properties["urlkey"] == snapshot.urlkey
|
|
assert properties["timestamp"] == snapshot.timestamp
|
|
assert properties["original"] == snapshot.original
|
|
assert properties["mimetype"] == snapshot.mimetype
|
|
assert properties["statuscode"] == snapshot.statuscode
|
|
assert properties["digest"] == snapshot.digest
|
|
assert properties["length"] == snapshot.length
|
|
assert (
|
|
datetime.strptime(properties["timestamp"], "%Y%m%d%H%M%S")
|
|
== snapshot.datetime_timestamp
|
|
)
|
|
archive_url = (
|
|
"https://web.archive.org/web/"
|
|
+ properties["timestamp"]
|
|
+ "/"
|
|
+ properties["original"]
|
|
)
|
|
assert archive_url == snapshot.archive_url
|
|
assert sample_input == str(snapshot)
|