From d506685f68cbdd9a32abf5a43bf42bab80399f91 Mon Sep 17 00:00:00 2001 From: Akash Mahanty Date: Sun, 23 Jan 2022 18:35:54 +0530 Subject: [PATCH] added some tests for save_api interface --- tests/test_save_api.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 tests/test_save_api.py diff --git a/tests/test_save_api.py b/tests/test_save_api.py new file mode 100644 index 0000000..e80f277 --- /dev/null +++ b/tests/test_save_api.py @@ -0,0 +1,20 @@ +import pytest +import time +from datetime import datetime + +from waybackpy.save_api import WaybackMachineSaveAPI + + +def test_save(): + url = "https://github.com/akamhy/waybackpy" + user_agent = "Mozilla/5.0 (MacBook Air; M1 Mac OS X 11_4) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1.1 Safari/604.1" + save_api = WaybackMachineSaveAPI(url, user_agent) + save_api.save() + archive_url = save_api.archive_url + timestamp = save_api.timestamp() + headers = save_api.headers # CaseInsensitiveDict + cached_save = save_api.cached_save + assert cached_save in [True, False] + assert archive_url.find("github.com/akamhy/waybackpy") != -1 + assert str(headers).find("github.com/akamhy/waybackpy") != -1 + assert type(save_api.timestamp()) == type(datetime(year=2020, month=10, day=2))