Skip to content

Commit 28d39cc

Browse files
committed
Move file + trim PR to 2
1 parent 299241f commit 28d39cc

3 files changed

Lines changed: 50 additions & 158 deletions

File tree

tests/unit_tests/test_lookup/test_lookup_object.py

Lines changed: 0 additions & 96 deletions
This file was deleted.

tests/unit_tests/test_options.py

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,18 @@
33
from unittest.mock import Mock
44

55
import pytest
6+
from _pytest.monkeypatch import MonkeyPatch
67

8+
import pyjelly.options as op
79
from pyjelly import jelly
8-
from pyjelly.errors import JellyAssertionError
9-
from pyjelly.options import StreamParameters, StreamTypes
10+
from pyjelly.errors import JellyAssertionError, JellyConformanceError
11+
from pyjelly.options import (
12+
MIN_NAME_LOOKUP_SIZE,
13+
MIN_VERSION,
14+
LookupPreset,
15+
StreamParameters,
16+
StreamTypes,
17+
)
1018
from pyjelly.parse.decode import options_from_frame
1119

1220

@@ -54,6 +62,7 @@
5462
jelly.PHYSICAL_STREAM_TYPE_UNSPECIFIED,
5563
jelly.LOGICAL_STREAM_TYPE_TIMESTAMPED_NAMED_GRAPHS,
5664
),
65+
(jelly.PHYSICAL_STREAM_TYPE_UNSPECIFIED, jelly.LOGICAL_STREAM_TYPE_UNSPECIFIED),
5766
],
5867
)
5968
def test_stream_types_ok(
@@ -151,3 +160,42 @@ def test_stream_parameters(generalized_statements: int, rdf_star: int) -> None:
151160
)
152161
assert params.generalized_statements == mock_options.generalized_statements
153162
assert params.rdf_star == mock_options.rdf_star
163+
164+
165+
def test_lookup_preset_validation() -> None:
166+
with pytest.raises(JellyConformanceError):
167+
LookupPreset(max_names=MIN_NAME_LOOKUP_SIZE - 1)
168+
p = LookupPreset.small()
169+
assert (p.max_names, p.max_prefixes, p.max_datatypes) == (128, 32, 32)
170+
171+
172+
def test_stream_types_flat_and_repr() -> None:
173+
st = StreamTypes(
174+
physical_type=jelly.PHYSICAL_STREAM_TYPE_TRIPLES,
175+
logical_type=jelly.LOGICAL_STREAM_TYPE_FLAT_TRIPLES,
176+
)
177+
assert st.flat
178+
expected = (
179+
f"StreamTypes("
180+
f"{jelly.PhysicalStreamType.Name(st.physical_type)}, "
181+
f"{jelly.LogicalStreamType.Name(st.logical_type)})"
182+
)
183+
assert str(st) == expected
184+
185+
186+
def test_stream_parameters_version() -> None:
187+
s1 = StreamParameters(namespace_declarations=False)
188+
assert s1.version == MIN_VERSION
189+
s2 = StreamParameters(namespace_declarations=True)
190+
assert s2.version == 2
191+
192+
193+
def test_stream_options_invalid_version(monkeypatch: MonkeyPatch) -> None:
194+
monkeypatch.setattr(op, "MIN_VERSION", 10)
195+
monkeypatch.setattr(op, "MAX_VERSION", 5)
196+
197+
with pytest.raises(JellyConformanceError) as excinfo:
198+
StreamParameters(namespace_declarations=True)
199+
200+
msg = str(excinfo.value)
201+
assert "Version must be between 10 and 5" in msg

tests/unit_tests/test_options/test_options.py

Lines changed: 0 additions & 60 deletions
This file was deleted.

0 commit comments

Comments
 (0)