Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing tests #94

Merged
merged 1 commit into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion tests/test_paperless_0_0_0.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@
)
from pypaperless.models import DocumentMeta, Page
from pypaperless.models import documents as doc_helpers
from pypaperless.models.common import DocumentMetadataType, PermissionTableType, RetrieveFileMode
from pypaperless.models.common import (
DocumentMetadataType,
DocumentSearchHitType,
PermissionTableType,
RetrieveFileMode,
)
from pypaperless.models.documents import DocumentSuggestions, DownloadedDocument
from pypaperless.models.mixins import helpers as helper_mixins
from pypaperless.models.mixins import models as model_mixins
Expand Down Expand Up @@ -114,6 +119,13 @@ async def test_iter(self, p: Paperless, mapping: ResourceTestMapping):
async for item in getattr(p, mapping.resource):
assert isinstance(item, mapping.model_cls)

async def test_all(self, p: Paperless, mapping: ResourceTestMapping):
"""Test all."""
items = await getattr(p, mapping.resource).all()
assert isinstance(items, list)
for item in items:
assert isinstance(item, int)

async def test_reduce(self, p: Paperless, mapping: ResourceTestMapping):
"""Test iter with reduce."""
async with getattr(p, mapping.resource).reduce(any_filter_param="1") as q:
Expand Down Expand Up @@ -165,6 +177,7 @@ async def test_delete(self, p: Paperless, mapping: ResourceTestMapping):
async def test_permissions(self, p: Paperless, mapping: ResourceTestMapping):
"""Test permissions."""
getattr(p, mapping.resource).request_permissions = True
assert getattr(p, mapping.resource).request_permissions
item = await getattr(p, mapping.resource)(1)
assert item.has_permissions
assert isinstance(item.permissions, PermissionTableType)
Expand Down Expand Up @@ -224,6 +237,13 @@ async def test_iter(self, p: Paperless, mapping: ResourceTestMapping):
async for item in getattr(p, mapping.resource):
assert isinstance(item, mapping.model_cls)

async def test_all(self, p: Paperless, mapping: ResourceTestMapping):
"""Test all."""
items = await getattr(p, mapping.resource).all()
assert isinstance(items, list)
for item in items:
assert isinstance(item, int)

async def test_call(self, p: Paperless, mapping: ResourceTestMapping):
"""Test call."""
item = await getattr(p, mapping.resource)(1)
Expand Down Expand Up @@ -328,6 +348,13 @@ async def test_iter(self, p: Paperless, mapping: ResourceTestMapping):
async for item in getattr(p, mapping.resource):
assert isinstance(item, mapping.model_cls)

async def test_all(self, p: Paperless, mapping: ResourceTestMapping):
"""Test all."""
items = await getattr(p, mapping.resource).all()
assert isinstance(items, list)
for item in items:
assert isinstance(item, int)

async def test_call(self, p: Paperless, mapping: ResourceTestMapping):
"""Test call."""
item = await getattr(p, mapping.resource)(1)
Expand Down Expand Up @@ -428,7 +455,9 @@ async def test_searching(self, p: Paperless, mapping: ResourceTestMapping):
async for item in getattr(p, mapping.resource).search("leet"):
assert isinstance(item, mapping.model_cls)
assert item.has_search_hit
assert isinstance(item.search_hit, DocumentSearchHitType)
# more_like
async for item in getattr(p, mapping.resource).more_like(1337):
assert isinstance(item, mapping.model_cls)
assert item.has_search_hit
assert isinstance(item.search_hit, DocumentSearchHitType)
7 changes: 7 additions & 0 deletions tests/test_paperless_1_8_0.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,13 @@ async def test_iter(self, p: Paperless, mapping: ResourceTestMapping):
async for item in getattr(p, mapping.resource):
assert isinstance(item, mapping.model_cls)

async def test_all(self, p: Paperless, mapping: ResourceTestMapping):
"""Test all."""
items = await getattr(p, mapping.resource).all()
assert isinstance(items, list)
for item in items:
assert isinstance(item, int)

async def test_call(self, p: Paperless, mapping: ResourceTestMapping):
"""Test call."""
item = await getattr(p, mapping.resource)(1)
Expand Down
7 changes: 7 additions & 0 deletions tests/test_paperless_2_0_0.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,13 @@ async def test_iter(self, p: Paperless, mapping: ResourceTestMapping):
async for item in getattr(p, mapping.resource):
assert isinstance(item, mapping.model_cls)

async def test_all(self, p: Paperless, mapping: ResourceTestMapping):
"""Test all."""
items = await getattr(p, mapping.resource).all()
assert isinstance(items, list)
for item in items:
assert isinstance(item, int)

async def test_call(self, p: Paperless, mapping: ResourceTestMapping):
"""Test call."""
item = await getattr(p, mapping.resource)(1)
Expand Down
7 changes: 7 additions & 0 deletions tests/test_paperless_2_3_0.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,13 @@ async def test_iter(self, p: Paperless, mapping: ResourceTestMapping):
async for item in getattr(p, mapping.resource):
assert isinstance(item, mapping.model_cls)

async def test_all(self, p: Paperless, mapping: ResourceTestMapping):
"""Test all."""
items = await getattr(p, mapping.resource).all()
assert isinstance(items, list)
for item in items:
assert isinstance(item, int)

async def test_call(self, p: Paperless, mapping: ResourceTestMapping):
"""Test call."""
item = await getattr(p, mapping.resource)(1)
Expand Down
Loading