some cli tests

This commit is contained in:
Akash 2020-07-23 20:44:14 +05:30 committed by GitHub
parent e231228721
commit 44bb2cf5e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

35
tests/test_cli.py Normal file
View File

@ -0,0 +1,35 @@
# -*- coding: utf-8 -*-
import sys
import os
import pytest
import argparse
sys.path.append("..")
import waybackpy.cli as cli # noqa: E402
from waybackpy.wrapper import Url # noqa: E402
def test_save():
obj = Url("https://pypi.org/user/akamhy/", "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")
cli._save(obj)
def test_get():
args = argparse.Namespace(get='oldest')
obj = Url("https://pypi.org/user/akamhy/", "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")
cli._get(obj, args)
args = argparse.Namespace(get='newest')
cli._get(obj, args)
args = argparse.Namespace(get='url')
cli._get(obj, args)
def test_oldest():
obj = Url("https://pypi.org/user/akamhy/", "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")
cli._oldest(obj)
def test_newest():
obj = Url("https://pypi.org/user/akamhy/", "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")
cli._newest(obj)
def test_near():
args = argparse.Namespace(year=2020, month=6, day=1, hour=1, minute=1)
obj = Url("https://pypi.org/user/akamhy/", "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")
cli._near(obj, args)