mirror of
https://github.com/ajurna/cbwebreader.git
synced 2026-11-02 10:36:55 +00:00
- Removed `flake8` and `flake8-annotations` from dependencies, replaced by `ruff` for linting. - Introduced cleaner type hinting and modern Python annotations (PEP 604 style) across multiple modules. - Moved archive processing to a dedicated helper (`comic.archives`) for improved maintainability. - Updated and simplified logic for archive file retrieval, directory cleaning, and user access validation. - Improved error handling and added support for user classification restrictions in API responses.
32 lines
926 B
Python
32 lines
926 B
Python
"""Tests for the scan_comics management command."""
|
|
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
from django.core.management import call_command
|
|
|
|
from comic import models
|
|
from comic.tests.factories import make_cbz
|
|
|
|
|
|
@pytest.mark.django_db
|
|
def test_scan_indexes_nested_directories(comic_volume: Path, reader_user) -> None:
|
|
nested = comic_volume / 'Series' / 'Volume 1'
|
|
nested.mkdir(parents=True)
|
|
make_cbz(nested / 'issue.cbz', pages=2)
|
|
|
|
call_command('scan_comics')
|
|
|
|
directory = models.Directory.objects.get(name='Volume 1', parent__name='Series')
|
|
book = models.ComicBook.objects.get(file_name='issue.cbz', directory=directory)
|
|
assert book.page_count == 2
|
|
|
|
|
|
@pytest.mark.django_db
|
|
def test_scan_without_a_user_stops_before_reading_the_volume(comic_volume: Path) -> None:
|
|
make_cbz(comic_volume / 'issue.cbz', pages=1)
|
|
|
|
call_command('scan_comics')
|
|
|
|
assert models.ComicBook.objects.count() == 0
|