from app.models import AtlasAlias, AtlasClaim, AtlasClaimObject, AtlasEntity, AtlasProvenance
from app.triple_export import entity_to_turtle


def test_entity_to_turtle_contains_expected_triples():
    entity = AtlasEntity(
        atlas_id="atlas:012gx2abcd123456",
        canonical_label="Joe Biden",
        entity_type="Person",
        aliases=[AtlasAlias(label="Joe Biden")],
        claims=[
            AtlasClaim(
                claim_id="clm_raw_ident_mid_/m/012gx2",
                subject="atlas:012gx2abcd123456",
                predicate="atlas:hasIdentifier",
                object=AtlasClaimObject(kind="identifier", id_type="mid", value="/m/012gx2"),
                layer="raw",
                provenance=AtlasProvenance(source="google-trends", retrieval_method="trends-resolution", confidence=0.9, retrieved_at="2026-04-03T17:33:21.651528+00:00"),
            ),
            AtlasClaim(
                claim_id="clm_drv_canonical_type",
                subject="atlas:012gx2abcd123456",
                predicate="atlas:hasCanonicalType",
                object=AtlasClaimObject(kind="type", value="atlas:Person"),
                layer="derived",
            ),
        ],
        needs_curation=False,
    )
    ttl = entity_to_turtle(entity)

    assert '@prefix atlas: <http://world.eu.org/atlas_ontology#> .' in ttl
    assert 'atlas:canonicalLabel "Joe Biden"' in ttl
    assert 'atlas:hasCanonicalType atlas:Person' in ttl
    assert 'atlas:hasIdentifier' in ttl
    assert 'atlas:needsCuration false' in ttl
    assert 'a atlas:Claim' in ttl
    assert 'atlas:claimPredicate "atlas:hasIdentifier"' in ttl
    assert 'atlas:claimStatus "active"' in ttl
