Add tests for field id clashes
This commit is contained in:
@ -14,6 +14,7 @@
|
||||
|
||||
import textwrap
|
||||
|
||||
import pytest
|
||||
import rdflib
|
||||
|
||||
from glowtables.table import Language, LiteralField, Table
|
||||
@ -90,3 +91,35 @@ def test_default_value() -> None:
|
||||
}
|
||||
"""
|
||||
)
|
||||
|
||||
|
||||
def test_field_id_subject() -> None:
|
||||
name_field = LiteralField(
|
||||
"subject",
|
||||
{Language("en"): "Name"},
|
||||
rdflib.URIRef("http://example.org/display-name"),
|
||||
)
|
||||
with pytest.raises(ValueError, match="both subject and a field id"):
|
||||
Table(
|
||||
fields=[name_field],
|
||||
constraints="",
|
||||
)
|
||||
|
||||
|
||||
def test_field_id_clash() -> None:
|
||||
name_field = LiteralField(
|
||||
"name",
|
||||
{Language("en"): "Name"},
|
||||
rdflib.URIRef("http://example.org/name"),
|
||||
)
|
||||
display_name_field = LiteralField(
|
||||
"name",
|
||||
{Language("en"): "Display Name"},
|
||||
rdflib.URIRef("http://example.org/display-name"),
|
||||
)
|
||||
with pytest.raises(ValueError, match="has duplicate field ids: name"):
|
||||
Table(
|
||||
fields=[name_field, display_name_field],
|
||||
constraints="",
|
||||
)
|
||||
|
||||
|
Reference in New Issue
Block a user