Skip to content
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
2 changes: 1 addition & 1 deletion codecov.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ignore:
- "docs"
- "tests"
- "examples"
- "examples"
6 changes: 6 additions & 0 deletions pyjelly/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ def flat(self) -> bool:
)

def __repr__(self) -> str:
"""
Return the representation of StreamTypes.

>>> repr(StreamTypes(9999, 8888))
'StreamTypes(9999, 8888)'
"""
with suppress(ValueError):
physical_type_name = jelly.PhysicalStreamType.Name(self.physical_type)
logical_type_name = jelly.LogicalStreamType.Name(self.logical_type)
Expand Down
37 changes: 35 additions & 2 deletions tests/unit_tests/test_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,18 @@
from unittest.mock import Mock

import pytest
from _pytest.monkeypatch import MonkeyPatch

import pyjelly.options as op
from pyjelly import jelly
from pyjelly.errors import JellyAssertionError
from pyjelly.options import StreamParameters, StreamTypes
from pyjelly.errors import JellyAssertionError, JellyConformanceError
from pyjelly.options import (
MIN_NAME_LOOKUP_SIZE,
MIN_VERSION,
LookupPreset,
StreamParameters,
StreamTypes,
)
from pyjelly.parse.decode import options_from_frame


Expand Down Expand Up @@ -151,3 +159,28 @@ def test_stream_parameters(generalized_statements: int, rdf_star: int) -> None:
)
assert params.generalized_statements == mock_options.generalized_statements
assert params.rdf_star == mock_options.rdf_star


def test_lookup_preset_validation() -> None:
with pytest.raises(JellyConformanceError):
LookupPreset(max_names=MIN_NAME_LOOKUP_SIZE - 1)
p = LookupPreset.small()
assert (p.max_names, p.max_prefixes, p.max_datatypes) == (128, 32, 32)


def test_stream_parameters_version() -> None:
s1 = StreamParameters(namespace_declarations=False)
assert s1.version == MIN_VERSION
s2 = StreamParameters(namespace_declarations=True)
assert s2.version == 2


def test_stream_options_invalid_version(monkeypatch: MonkeyPatch) -> None:
monkeypatch.setattr(op, "MIN_VERSION", 10)
monkeypatch.setattr(op, "MAX_VERSION", 5)

with pytest.raises(JellyConformanceError) as excinfo:
StreamParameters(namespace_declarations=True)

msg = str(excinfo.value)
assert "Version must be between 10 and 5" in msg
Loading