increase coverage
This commit is contained in:
parent
bd079978bf
commit
0c6107e675
@ -1,6 +1,8 @@
|
|||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import pytest
|
import pytest
|
||||||
|
import random
|
||||||
|
import string
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
sys.path.append("..")
|
sys.path.append("..")
|
||||||
@ -8,9 +10,6 @@ import waybackpy.cli as cli # noqa: E402
|
|||||||
from waybackpy.wrapper import Url # noqa: E402
|
from waybackpy.wrapper import Url # noqa: E402
|
||||||
from waybackpy.__version__ import __version__
|
from waybackpy.__version__ import __version__
|
||||||
|
|
||||||
# Namespace(day=None, get=None, hour=None, minute=None, month=None, near=False,
|
|
||||||
# newest=False, oldest=False, save=False, total=False, url=None, user_agent=None, version=False, year=None)
|
|
||||||
|
|
||||||
|
|
||||||
def test_save():
|
def test_save():
|
||||||
args = argparse.Namespace(
|
args = argparse.Namespace(
|
||||||
@ -32,6 +31,25 @@ def test_save():
|
|||||||
reply = cli.args_handler(args)
|
reply = cli.args_handler(args)
|
||||||
assert "pypi.org/user/akamhy" in str(reply)
|
assert "pypi.org/user/akamhy" in str(reply)
|
||||||
|
|
||||||
|
args = argparse.Namespace(
|
||||||
|
user_agent=None,
|
||||||
|
url="https://hfjfjfjfyu6r6rfjvj.fjhgjhfjgvjm",
|
||||||
|
total=False,
|
||||||
|
version=False,
|
||||||
|
oldest=False,
|
||||||
|
save=True,
|
||||||
|
json=False,
|
||||||
|
archive_url=False,
|
||||||
|
newest=False,
|
||||||
|
near=False,
|
||||||
|
alive=False,
|
||||||
|
subdomain=False,
|
||||||
|
known_urls=False,
|
||||||
|
get=None,
|
||||||
|
)
|
||||||
|
reply = cli.args_handler(args)
|
||||||
|
assert "could happen because either your waybackpy" in str(reply)
|
||||||
|
|
||||||
|
|
||||||
def test_json():
|
def test_json():
|
||||||
args = argparse.Namespace(
|
args = argparse.Namespace(
|
||||||
@ -95,6 +113,29 @@ def test_oldest():
|
|||||||
reply = cli.args_handler(args)
|
reply = cli.args_handler(args)
|
||||||
assert "pypi.org/user/akamhy" in str(reply)
|
assert "pypi.org/user/akamhy" in str(reply)
|
||||||
|
|
||||||
|
uid = "".join(
|
||||||
|
random.choice(string.ascii_lowercase + string.digits) for _ in range(6)
|
||||||
|
)
|
||||||
|
url = "https://pypi.org/yfvjvycyc667r67ed67r" + uid
|
||||||
|
args = argparse.Namespace(
|
||||||
|
user_agent=None,
|
||||||
|
url=url,
|
||||||
|
total=False,
|
||||||
|
version=False,
|
||||||
|
oldest=True,
|
||||||
|
save=False,
|
||||||
|
json=False,
|
||||||
|
archive_url=False,
|
||||||
|
newest=False,
|
||||||
|
near=False,
|
||||||
|
alive=False,
|
||||||
|
subdomain=False,
|
||||||
|
known_urls=False,
|
||||||
|
get=None,
|
||||||
|
)
|
||||||
|
reply = cli.args_handler(args)
|
||||||
|
assert "Can not find archive for" in str(reply)
|
||||||
|
|
||||||
|
|
||||||
def test_newest():
|
def test_newest():
|
||||||
args = argparse.Namespace(
|
args = argparse.Namespace(
|
||||||
@ -117,6 +158,29 @@ def test_newest():
|
|||||||
reply = cli.args_handler(args)
|
reply = cli.args_handler(args)
|
||||||
assert "pypi.org/user/akamhy" in str(reply)
|
assert "pypi.org/user/akamhy" in str(reply)
|
||||||
|
|
||||||
|
uid = "".join(
|
||||||
|
random.choice(string.ascii_lowercase + string.digits) for _ in range(6)
|
||||||
|
)
|
||||||
|
url = "https://pypi.org/yfvjvycyc667r67ed67r" + uid
|
||||||
|
args = argparse.Namespace(
|
||||||
|
user_agent=None,
|
||||||
|
url=url,
|
||||||
|
total=False,
|
||||||
|
version=False,
|
||||||
|
oldest=False,
|
||||||
|
save=False,
|
||||||
|
json=False,
|
||||||
|
archive_url=False,
|
||||||
|
newest=True,
|
||||||
|
near=False,
|
||||||
|
alive=False,
|
||||||
|
subdomain=False,
|
||||||
|
known_urls=False,
|
||||||
|
get=None,
|
||||||
|
)
|
||||||
|
reply = cli.args_handler(args)
|
||||||
|
assert "Can not find archive for" in str(reply)
|
||||||
|
|
||||||
|
|
||||||
def test_total_archives():
|
def test_total_archives():
|
||||||
args = argparse.Namespace(
|
args = argparse.Namespace(
|
||||||
@ -161,6 +225,26 @@ def test_known_urls():
|
|||||||
reply = cli.args_handler(args)
|
reply = cli.args_handler(args)
|
||||||
assert "github" in str(reply)
|
assert "github" in str(reply)
|
||||||
|
|
||||||
|
args = argparse.Namespace(
|
||||||
|
user_agent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/600.8.9 \
|
||||||
|
(KHTML, like Gecko) Version/8.0.8 Safari/600.8.9",
|
||||||
|
url="https://akfyfufyjcujfufu6576r76r6amhy.gitd6r67r6u6hub.yfjyfjio",
|
||||||
|
total=False,
|
||||||
|
version=False,
|
||||||
|
oldest=False,
|
||||||
|
save=False,
|
||||||
|
json=False,
|
||||||
|
archive_url=False,
|
||||||
|
newest=False,
|
||||||
|
near=False,
|
||||||
|
alive=True,
|
||||||
|
subdomain=True,
|
||||||
|
known_urls=True,
|
||||||
|
get=None,
|
||||||
|
)
|
||||||
|
reply = cli.args_handler(args)
|
||||||
|
assert "No known URLs found" in str(reply)
|
||||||
|
|
||||||
|
|
||||||
def test_near():
|
def test_near():
|
||||||
args = argparse.Namespace(
|
args = argparse.Namespace(
|
||||||
@ -188,6 +272,34 @@ def test_near():
|
|||||||
reply = cli.args_handler(args)
|
reply = cli.args_handler(args)
|
||||||
assert "202007" in str(reply)
|
assert "202007" in str(reply)
|
||||||
|
|
||||||
|
uid = "".join(
|
||||||
|
random.choice(string.ascii_lowercase + string.digits) for _ in range(6)
|
||||||
|
)
|
||||||
|
url = "https://pypi.org/yfvjvycyc667r67ed67r" + uid
|
||||||
|
args = argparse.Namespace(
|
||||||
|
user_agent=None,
|
||||||
|
url=url,
|
||||||
|
total=False,
|
||||||
|
version=False,
|
||||||
|
oldest=False,
|
||||||
|
save=False,
|
||||||
|
json=False,
|
||||||
|
archive_url=False,
|
||||||
|
newest=False,
|
||||||
|
near=True,
|
||||||
|
alive=False,
|
||||||
|
subdomain=False,
|
||||||
|
known_urls=False,
|
||||||
|
get=None,
|
||||||
|
year=2020,
|
||||||
|
month=7,
|
||||||
|
day=15,
|
||||||
|
hour=1,
|
||||||
|
minute=1,
|
||||||
|
)
|
||||||
|
reply = cli.args_handler(args)
|
||||||
|
assert "Can not find archive for" in str(reply)
|
||||||
|
|
||||||
|
|
||||||
def test_get():
|
def test_get():
|
||||||
args = argparse.Namespace(
|
args = argparse.Namespace(
|
||||||
|
@ -305,8 +305,7 @@ def parse_args(argv):
|
|||||||
|
|
||||||
|
|
||||||
def main(argv=None):
|
def main(argv=None):
|
||||||
if argv is None:
|
argv = sys.argv if argv is None else argv
|
||||||
argv = sys.argv
|
|
||||||
print(args_handler(parse_args(argv)))
|
print(args_handler(parse_args(argv)))
|
||||||
|
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ def _archive_url_parser(header, url):
|
|||||||
"If '%s' can be accessed via your web browser then either "
|
"If '%s' can be accessed via your web browser then either "
|
||||||
"this version of waybackpy (%s) is out of date or WayBack Machine is malfunctioning. Visit "
|
"this version of waybackpy (%s) is out of date or WayBack Machine is malfunctioning. Visit "
|
||||||
"'https://github.com/akamhy/waybackpy' for the latest version "
|
"'https://github.com/akamhy/waybackpy' for the latest version "
|
||||||
"of waybackpy.\nHeader:\n%s" % (__version__, str(header))
|
"of waybackpy.\nHeader:\n%s" % (url, __version__, str(header))
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user