# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.
"""Pytest conftest for generate-cve-json.

The Python tool loads all project-specific values from a TOML config
the adopting project ships at:

  <adopter-tracker>/.apache-magpie-overrides/tools/cve-tool-vulnogram/cve-json-config.toml

The tool reads that config relative to ``cwd`` (or via the
``CVE_JSON_CONFIG`` environment variable / the ``--config`` CLI flag).

For the framework's own pytest suite (run from this repository, no
adopter present), we point ``CVE_JSON_CONFIG`` at the test fixture at
``tests/fixtures/cve-json-config.toml``. The fixture mirrors one
adopter's configuration so the existing tests keep their assertions;
**it is not the framework's default configuration** — adopters write
their own per the schema in the package README.
"""

from __future__ import annotations

import os
from pathlib import Path

_FIXTURE_CONFIG = Path(__file__).resolve().parent / "fixtures" / "cve-json-config.toml"
assert _FIXTURE_CONFIG.exists(), f"missing test fixture: {_FIXTURE_CONFIG}"
os.environ.setdefault("CVE_JSON_CONFIG", str(_FIXTURE_CONFIG))
