mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-12-01 12:26:19 -05:00
Removing leading www. from archive domains.g
This commit is contained in:
parent
d9fc3e3d0d
commit
d4f09e057e
2 changed files with 32 additions and 5 deletions
|
|
@ -1,10 +1,11 @@
|
|||
import json
|
||||
import pathlib
|
||||
from datetime import datetime
|
||||
|
||||
import mock
|
||||
|
||||
from modules.archive.lib import new_archive, get_or_create_domain_and_url, get_urls, get_url_count, delete_url, \
|
||||
_refresh_archives, get_domains
|
||||
_refresh_archives, get_domains, get_new_archive_files
|
||||
from modules.archive.models import Archive, URL, Domain
|
||||
from wrolpi.common import get_media_directory
|
||||
from wrolpi.db import get_db_session
|
||||
|
|
@ -34,6 +35,23 @@ class TestArchive(TestAPI):
|
|||
super().setUp()
|
||||
(pathlib.Path(self.tmp_dir.name) / 'archive').mkdir(exist_ok=True)
|
||||
|
||||
@mock.patch('modules.archive.lib.now', lambda: datetime(2001, 1, 1))
|
||||
def test_get_new_archive_files(self):
|
||||
s, r, t, j, c = map(str, get_new_archive_files('https://example.com/two'))
|
||||
assert str(s).endswith('archive/example.com/2001-01-01 00:00:00.000000.html')
|
||||
assert str(r).endswith('archive/example.com/2001-01-01 00:00:00.000000-readability.html')
|
||||
assert str(t).endswith('archive/example.com/2001-01-01 00:00:00.000000-readability.txt')
|
||||
assert str(j).endswith('archive/example.com/2001-01-01 00:00:00.000000-readability.json')
|
||||
assert str(c).endswith('archive/example.com/2001-01-01 00:00:00.000000.png')
|
||||
|
||||
s, r, t, j, c = get_new_archive_files('https://www.example.com/one')
|
||||
# Leading www. is removed.
|
||||
assert str(s).endswith('archive/example.com/2001-01-01 00:00:00.000000.html')
|
||||
assert str(r).endswith('archive/example.com/2001-01-01 00:00:00.000000-readability.html')
|
||||
assert str(t).endswith('archive/example.com/2001-01-01 00:00:00.000000-readability.txt')
|
||||
assert str(j).endswith('archive/example.com/2001-01-01 00:00:00.000000-readability.json')
|
||||
assert str(c).endswith('archive/example.com/2001-01-01 00:00:00.000000.png')
|
||||
|
||||
@wrap_test_db
|
||||
def test_new_archive(self):
|
||||
with mock.patch('modules.archive.lib.request_archive', make_fake_request_archive()):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue