From c5538222ef62a38f78eec3151a1ddeff179944f7 Mon Sep 17 00:00:00 2001 From: Roland Date: Wed, 2 Nov 2022 14:37:57 -0600 Subject: [PATCH] Handling when a Singlefile is found that was not created by WROLPi. --- modules/archive/conftest.py | 26 +++++++++++ modules/archive/lib.py | 20 +++++++- modules/archive/models.py | 80 ++++++++++++++++++-------------- modules/archive/test/test_lib.py | 17 +++++++ 4 files changed, 107 insertions(+), 36 deletions(-) diff --git a/modules/archive/conftest.py b/modules/archive/conftest.py index ddc3e987..6c2e8f37 100644 --- a/modules/archive/conftest.py +++ b/modules/archive/conftest.py @@ -1,3 +1,4 @@ +import copy import datetime import json import pathlib @@ -84,3 +85,28 @@ def archive_factory(test_session, archive_directory, make_files_structure): return archive return _ + + +SINGLEFILE_CONTENTS = ''' + + + + +the title + + +some body contents + + + +''' + + +@pytest.fixture +def singlefile_contents() -> str: + """Return a short HTML string that contains an example Singlefile file.""" + return copy.deepcopy(SINGLEFILE_CONTENTS) diff --git a/modules/archive/lib.py b/modules/archive/lib.py index 2e7a6077..453828ea 100644 --- a/modules/archive/lib.py +++ b/modules/archive/lib.py @@ -488,13 +488,29 @@ def is_archive_file(path: pathlib.Path) -> bool: return path.is_file() and path.suffix.lower() in ARCHIVE_SUFFIXES and bool(ARCHIVE_MATCHER.match(path.name)) +SINGLEFILE_HEADER = '''