blob: debd69a535f342e731a04071f62cc6bddca70a12 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
from datetime import datetime, timezone
import pytest
from conftest import DB
from hircine.api.types import Page
from hircine.db.models import Archive
@pytest.mark.anyio
async def test_page(gen_page):
pages = list(gen_page)
images = [p.image for p in pages]
# persist images and pages in database by binding them to a throwaway
# archive
archive = await DB.add(
Archive(
hash="339e3a32e5648fdeb2597f05cb2e1ef6",
path="some/archive.zip",
size=78631597,
mtime=datetime(1999, 12, 27, tzinfo=timezone.utc),
cover=images[0],
pages=pages,
page_count=len(pages),
)
)
assert len(archive.pages) == len(pages)
page_iter = iter(pages)
image_iter = iter(images)
for page in [Page(p) for p in archive.pages]:
matching_page = next(page_iter)
matching_image = next(image_iter)
assert page.id == matching_page.id
assert page.comic_id is None
assert page.image.id == matching_image.id
assert page.path == matching_page.path
|