vivamais / tests /steps /test_documents.py
marinarosa's picture
Rewrite the feature files for the artifact model
3b0b063
Raw
History Blame Contribute Delete
1.59 kB
"""Step definitions for identity document tracking (UC6)."""
from __future__ import annotations
import os
from typing import Any
from pytest_bdd import given, scenario, then, when
from vivamais.application.documents import check_identity
from vivamais.domain.artifacts import IdentityDocument, IdentityKind
_FEATURES_DIR = os.path.normpath(
os.path.join(os.path.dirname(__file__), "..", "..", "features"),
)
_context: dict[str, Any] = {}
@scenario(
os.path.join(_FEATURES_DIR, "documents.feature"),
"A passport satisfies the identity requirement",
)
def test_passport_satisfies() -> None:
"""A passport satisfies the identity requirement."""
@scenario(
os.path.join(_FEATURES_DIR, "documents.feature"),
"A CPF alone is not enough",
)
def test_cpf_not_enough() -> None:
"""A CPF alone is not enough."""
@given("a passenger with a received passport")
def given_passport() -> None:
_context["documents"] = [IdentityDocument(kind=IdentityKind.PASSPORT, holder="Maria")]
@given("a passenger with only a CPF")
def given_cpf_only() -> None:
_context["documents"] = [IdentityDocument(kind=IdentityKind.CPF, holder="Maria")]
@when("document readiness is checked")
def when_checked() -> None:
_context["result"] = check_identity(["Maria"], _context["documents"])
@then("the passenger is marked as received")
def then_received() -> None:
assert _context["result"]["passengers"]["Maria"] == "received"
@then("the passenger is marked as missing")
def then_missing() -> None:
assert _context["result"]["passengers"]["Maria"] == "missing"