Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions services/job-analysis-api/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"""Make sibling Orgmetra workspace packages importable for this service's tests.

The service depends on sibling workspace packages (for example
``orgmetra_hris_kernel``). Hosted quality workflows install those dependencies
into isolated environments, but plain ``pytest`` sessions started inside this
service directory (such as the central coverage sandbox) do not perform a
workspace install. This conftest adds every workspace ``src`` tree to the
import path so test collection succeeds without changing production behavior.
"""

from __future__ import annotations

from pathlib import Path
import sys

_WORKSPACE_ROOT = Path(__file__).resolve().parents[2]

for _source_dir in sorted(
str(path)
for pattern in ("packages/*/src", "services/*/src")
for path in _WORKSPACE_ROOT.glob(pattern)
if path.is_dir()
):
if _source_dir not in sys.path:
sys.path.insert(0, _source_dir)
Comment thread
seonghobae marked this conversation as resolved.
2 changes: 1 addition & 1 deletion services/job-analysis-api/tests/test_http_content_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ async def send(message: dict[str, object]) -> None:

def test_openapi_publishes_the_unsupported_media_type_response(self) -> None:
"""Keep generated clients aligned with the runtime 415 contract."""
schema = Path("schemas/openapi.yaml").read_text(encoding="utf-8")
schema = (Path(__file__).resolve().parents[3] / "schemas" / "openapi.yaml").read_text(encoding="utf-8")
collection = schema.split(
" /tenants/{tenant_record_id}/job-analysis-snapshots:", 1
)[1].split(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ async def send(message: dict[str, object]) -> None:

def test_openapi_allows_the_deprecated_error_alias_without_weakening_required_fields(self) -> None:
"""Preserve current clients while requiring the governed four-field envelope."""
schema = Path("schemas/openapi.yaml").read_text(encoding="utf-8")
schema = (Path(__file__).resolve().parents[3] / "schemas" / "openapi.yaml").read_text(encoding="utf-8")
error_schema = schema.split(" ErrorResponse:\n", 1)[1].split(
" responses:\n", 1
)[0]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

def test_openapi_matches_the_path_tenant_and_authenticated_actor_authority() -> None:
"""Do not publish a global route or duplicate tenant/actor header authority."""
schema = Path("schemas/openapi.yaml").read_text(encoding="utf-8")
schema = (Path(__file__).resolve().parents[3] / "schemas" / "openapi.yaml").read_text(encoding="utf-8")
collection_path = " /tenants/{tenant_record_id}/job-analysis-snapshots:"
item_path = " /tenants/{tenant_record_id}/job-analysis-snapshots/{analysis_record_id}:"
assert collection_path in schema
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

def test_snapshot_arrays_publish_runtime_cardinality_and_item_types() -> None:
"""Keep client schemas aligned with bounded runtime parsing and evidence shapes."""
schema = Path("schemas/openapi.yaml").read_text(encoding="utf-8")
schema = (Path(__file__).resolve().parents[3] / "schemas" / "openapi.yaml").read_text(encoding="utf-8")
command = schema.split(" PersistJobAnalysisSnapshotCommand:", 1)[1].split(
" JobAnalysisSnapshotDocument:", 1
)[0]
Expand All @@ -31,7 +31,7 @@ def test_snapshot_arrays_publish_runtime_cardinality_and_item_types() -> None:

def test_snapshot_get_publishes_dedicated_not_found_response() -> None:
"""Do not document a missing snapshot as generic invalid-command validation."""
schema = Path("schemas/openapi.yaml").read_text(encoding="utf-8")
schema = (Path(__file__).resolve().parents[3] / "schemas" / "openapi.yaml").read_text(encoding="utf-8")
item_path = " /tenants/{tenant_record_id}/job-analysis-snapshots/{analysis_record_id}:"
item_block = schema.split(item_path, 1)[1].split("components:", 1)[0]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@

def test_missing_position_failure_requires_the_expected_foreign_key_reason() -> None:
"""Do not accept an unrelated SQL failure as position-scope evidence."""
contract = Path("tests/test_job_analysis_snapshot_postgres.sh").read_text(
encoding="utf-8"
)
contract = (
Path(__file__).resolve().parents[3]
/ "tests"
/ "test_job_analysis_snapshot_postgres.sh"
).read_text(encoding="utf-8")
assert '"${missing_position_output}" != *"foreign key"*' in contract
assert '"${missing_position_output}" != *"job_analysis_snapshot_position_tenant_fk"*' in contract
assert "missing position failed for an unexpected reason" in contract
5 changes: 4 additions & 1 deletion services/job-analysis-api/tests/test_workflow_contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
from pathlib import Path


REPOSITORY_ROOT = Path(__file__).resolve().parents[3]


def _workflow(path: str) -> str:
"""Read one reviewed repository-local workflow as UTF-8 text."""
return Path(path).read_text(encoding="utf-8")
return (REPOSITORY_ROOT / path).read_text(encoding="utf-8")


def test_foundation_ci_runs_job_analysis_on_default_branch_pull_requests() -> None:
Expand Down
25 changes: 25 additions & 0 deletions services/people-api/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"""Make sibling Orgmetra workspace packages importable for this service's tests.

The service depends on sibling workspace packages (for example
``orgmetra_hris_kernel``). Hosted quality workflows install those dependencies
into isolated environments, but plain ``pytest`` sessions started inside this
service directory (such as the central coverage sandbox) do not perform a
workspace install. This conftest adds every workspace ``src`` tree to the
import path so test collection succeeds without changing production behavior.
"""

from __future__ import annotations

from pathlib import Path
import sys

_WORKSPACE_ROOT = Path(__file__).resolve().parents[2]

for _source_dir in sorted(
str(path)
for pattern in ("packages/*/src", "services/*/src")
for path in _WORKSPACE_ROOT.glob(pattern)
if path.is_dir()
):
if _source_dir not in sys.path:
sys.path.insert(0, _source_dir)
5 changes: 4 additions & 1 deletion services/people-api/tests/test_workflow_contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
from pathlib import Path


REPOSITORY_ROOT = Path(__file__).resolve().parents[3]


def _workflow(path: str) -> str:
"""Read one reviewed repository-local workflow as UTF-8 text."""
return Path(path).read_text(encoding="utf-8")
return (REPOSITORY_ROOT / path).read_text(encoding="utf-8")


def test_foundation_ci_runs_people_api_on_default_branch_pull_requests() -> None:
Expand Down
Loading