mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-10-26 19:01:39 -04:00
Tags can be created and deleted in UI. Adding tag_file using id to avoid session error. Using UTC in test. Matching tag_names style in test. Tag icon is displayed on file rows. Archives, Videos and Files can be filtered by their tags. Tags can be added and removed from UI. Tags are displayed in VideoPlayer. The tags of a file are returned in it's JSON. Video favorites are converted to Favorite tag on channel config import. Updating tests to match frontend usage. PDF creator and modification time are displayed. Reworking file search to use Video.__json__ for complex video relations. Archives can be viewed. Removing ebook.title. Reworking alembic migration to be an upgrade rather than a replace. Skipping test on circleci. Clearing out video caption index only if extract_subtitles if off. Channel tests pass. Some video tests pass. Missing videos can be found. A video can be downloaded. Orphaned files can be found. Videos can be tagged. Videos can be searched. Videos can be modeled. Converting some tests to use FileGroup.primary_path. Adding archive and domains to alembic migration. Testing cascading Archive titles. Archives now uses FileGroup. archive.lib tests pass. Archive is partially converted to FileGroup. Calculating FileGroup.primary file on refresh, rather than on select. wrolpi tests pass. Using FilesType to convert between str/pathlib.Path for FileGroup.files. Using list of files in FileGroup.files instead of dictionary. Storing files in dedicated FileGroup.files to avoid overwriting them. Adding comment explaining CASE. Not overwriting FileGroup.data on refresh if no change has been detected. Removing File model in favor of FileGroup.data. Adding typing to Files methods. Files are indexed using the primary mimetype of the FileGroup. files test_lib tests pass. Removing file_group_file in favor of simple one-to-many relationship. PDF files are indexed during refresh. Adding Tag and TagFile to tag files with specific tags. Only iterating when full_stem_ids has contents. Testing that FileGroups are related to their Files. Files and file_groups are created and linked. Bump webpack from 5.75.0 to 5.76.1 in /app (#160) Bumps [webpack](https://github.com/webpack/webpack) from 5.75.0 to 5.76.1. - [Release notes](https://github.com/webpack/webpack/releases) - [Commits](https://github.com/webpack/webpack/compare/v5.75.0...v5.76.1) --- updated-dependencies: - dependency-name: webpack dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
82 lines
2.7 KiB
Python
82 lines
2.7 KiB
Python
import datetime
|
|
import json
|
|
import pathlib
|
|
from uuid import uuid4
|
|
|
|
import pytest
|
|
import pytz
|
|
|
|
from modules.archive.lib import archive_strftime
|
|
from modules.archive.models import Archive, Domain
|
|
|
|
|
|
@pytest.fixture
|
|
def archive_directory(test_directory) -> pathlib.Path:
|
|
path = test_directory / 'archive'
|
|
path.mkdir()
|
|
return path
|
|
|
|
|
|
@pytest.fixture
|
|
def archive_factory(test_session, archive_directory, make_files_structure):
|
|
def time_generator():
|
|
timestamp = datetime.datetime(2000, 1, 1, 0, 0, 0).astimezone(pytz.UTC)
|
|
while True:
|
|
timestamp += datetime.timedelta(seconds=1)
|
|
yield timestamp
|
|
|
|
now = time_generator()
|
|
|
|
def _(domain: str = None, url: str = None, title: str = 'NA', contents: str = None,
|
|
singlefile_contents: str = None) -> Archive:
|
|
if domain:
|
|
assert '/' not in domain
|
|
|
|
title = title or str(uuid4())
|
|
domain_dir = domain or title
|
|
domain_dir = archive_directory / domain_dir
|
|
domain_dir.mkdir(exist_ok=True)
|
|
|
|
archive_datetime = next(now)
|
|
timestamp = archive_strftime(archive_datetime)
|
|
|
|
json_contents = {}
|
|
if title != 'NA':
|
|
json_contents['title'] = title
|
|
if url:
|
|
json_contents['url'] = url
|
|
json_contents = json.dumps(json_contents)
|
|
singlefile_path, screenshot_path, readability_path, readability_txt_path, readability_json_path = \
|
|
make_files_structure({
|
|
str(domain_dir / f'{timestamp}_{title}.html'): singlefile_contents or '<html></html>',
|
|
str(domain_dir / f'{timestamp}_{title}.png'): None,
|
|
str(domain_dir / f'{timestamp}_{title}.readability.html'): '<html></html>',
|
|
str(domain_dir / f'{timestamp}_{title}.readability.txt'): contents,
|
|
str(domain_dir / f'{timestamp}_{title}.readability.json'): json_contents,
|
|
})
|
|
|
|
if domain:
|
|
domain = test_session.query(Domain).filter_by(domain=domain).one_or_none()
|
|
|
|
if not domain and domain_dir.name != 'NA':
|
|
domain = Domain(
|
|
domain=domain_dir.name,
|
|
directory=domain_dir,
|
|
)
|
|
test_session.add(domain)
|
|
test_session.flush([domain])
|
|
|
|
# Only add files that were created.
|
|
files = (readability_path, readability_json_path, readability_txt_path, screenshot_path, singlefile_path)
|
|
files = list(filter(None, files))
|
|
|
|
archive = Archive.from_paths(test_session, *files)
|
|
archive.url = url
|
|
archive.title = title
|
|
archive.archive_datetime = next(now)
|
|
archive.domain = domain
|
|
archive.validate()
|
|
|
|
return archive
|
|
|
|
return _
|