"""Tests for the new ontology models (ConceptDefinition, ConceptScheme)."""

from __future__ import annotations

from pycharter.wiki.ontology.models import (
    ConceptDefinition,
    ConceptScheme,
    FieldOntology,
)


class TestConceptDefinition:
    def test_minimal(self):
        c = ConceptDefinition(id="Foo", label="Foo Label")
        d = c.to_dict()
        assert d["id"] == "Foo"
        assert d["label"] == "Foo Label"
        assert "broader" not in d
        assert "deprecated" not in d

    def test_full(self):
        c = ConceptDefinition(
            id="Bar",
            label="Bar Label",
            definition="A bar",
            broader="Foo",
            tags=["t1"],
            alt_labels=["B"],
            notation="BAR",
            examples=["ex1"],
            exact_match="https://example.com/bar",
            deprecated=True,
            replaced_by="Baz",
        )
        d = c.to_dict()
        assert d["broader"] == "Foo"
        assert d["deprecated"] is True
        assert d["replaced_by"] == "Baz"
        assert d["alt_labels"] == ["B"]


class TestConceptScheme:
    def test_to_dict(self):
        s = ConceptScheme(
            id="Test",
            title="Test Scheme",
            version="1.0.0",
            concepts=[ConceptDefinition(id="A", label="A")],
        )
        d = s.to_dict()
        assert d["scheme"]["id"] == "Test"
        assert len(d["concepts"]) == 1


class TestFieldOntologyNewFields:
    def test_description_and_deprecated(self):
        fo = FieldOntology(
            concept="Foo",
            description="some desc",
            deprecated=True,
        )
        d = fo.to_dict()
        assert d["description"] == "some desc"
        assert d["deprecated"] is True

    def test_defaults(self):
        fo = FieldOntology(concept="Foo")
        d = fo.to_dict()
        assert "description" not in d
        assert "deprecated" not in d
