diff --git a/pyproject.toml b/pyproject.toml index 033992c..15d1075 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -49,6 +49,7 @@ addopts = [ ] pythonpath = [".", "src", "tests"] testpaths = ["tests"] +norecursedirs = ["tests/fixtures"] markers = [ "flaky: tests that can randomly fail through no change to the code", "slow: marks tests as slow (deselect with '-m \"not slow\"')", diff --git a/tests/fixtures/test_project/README.md b/tests/fixtures/test_project/README.md index b6554e6..c330baa 100644 --- a/tests/fixtures/test_project/README.md +++ b/tests/fixtures/test_project/README.md @@ -5,12 +5,12 @@ Minimal test project for manual validation of `reqstool-python-poetry-plugin`. ## Prerequisites A `.venv` must exist in the repository root with both the plugin and Poetry installed. -If it is missing, recreate it from the repository root: +If it is missing, recreate it from the repository root (`reqstool-python-poetry-plugin/`): ```bash python3.13 -m venv .venv .venv/bin/pip install -e . -.venv/bin/pip install poetry +.venv/bin/pip install poetry reqstool ``` Point Poetry at Python 3.13 (once per machine): @@ -24,7 +24,7 @@ cd tests/fixtures/test_project Run all commands from `tests/fixtures/test_project/`. -### 1 — Install +### 1 — Install (adds `include` entries to pyproject.toml) ```bash ../../../.venv/bin/poetry install @@ -36,7 +36,15 @@ Expected: plugin prints its version, then adds three entries to `pyproject.toml` include = ["reqstool_config.yml", "docs/reqstool/**/*", "build/reqstool/**/*"] ``` -### 2 — Build +### 2 — Run tests + +```bash +../../../.venv/bin/pytest tests/ --junit-xml=build/test-results/junit.xml -v +``` + +Expected: `test_hello` passes. + +### 3 — Build ```bash ../../../.venv/bin/poetry build @@ -45,18 +53,19 @@ include = ["reqstool_config.yml", "docs/reqstool/**/*", "build/reqstool/**/*"] Expected output (in order): 1. `[reqstool] plugin version ` 2. `[reqstool] added to reqstool_config.yml: docs/reqstool/requirements.yml` -3. `[reqstool] added to reqstool_config.yml: build/reqstool/annotations.yml` -4. `[reqstool] Created reqstool_config.yml in project root` -5. Poetry builds sdist + wheel -6. `[reqstool] Removed reqstool_config.yml from project root` +3. `[reqstool] added to reqstool_config.yml: docs/reqstool/software_verification_cases.yml` +4. `[reqstool] added to reqstool_config.yml: build/reqstool/annotations.yml` +5. `[reqstool] Created reqstool_config.yml in project root` +6. Poetry builds sdist + wheel +7. `[reqstool] Removed reqstool_config.yml from project root` -### 3 — Verify +### 4 — Check artefacts ```bash # annotations.yml must exist test -f build/reqstool/annotations.yml && echo "OK: annotations.yml" -# reqstool_config.yml must be gone from project root after build +# reqstool_config.yml must be gone after build test ! -f reqstool_config.yml && echo "OK: reqstool_config.yml cleaned up" # sdist must contain all reqstool files @@ -67,5 +76,17 @@ Expected entries in the sdist: - `mypackage-0.1.0/reqstool_config.yml` - `mypackage-0.1.0/build/reqstool/annotations.yml` - `mypackage-0.1.0/docs/reqstool/requirements.yml` +- `mypackage-0.1.0/docs/reqstool/software_verification_cases.yml` + +### 5 — Run reqstool status + +Extract the sdist and merge in the local test results, then run `reqstool status`: + +```bash +mkdir -p /tmp/mypackage-reqstool +tar -xzf dist/mypackage-0.1.0.tar.gz -C /tmp/mypackage-reqstool +cp -r build/test-results /tmp/mypackage-reqstool/mypackage-0.1.0/build/ +../../../.venv/bin/reqstool status local -p /tmp/mypackage-reqstool/mypackage-0.1.0 +``` -`annotations.yml` must contain `REQ_001` mapped to `src.mypackage.main.hello`. +Expected: all green — `REQ_001` implemented, `T1 P1`, no missing tests or SVCs. diff --git a/tests/fixtures/test_project/docs/reqstool/requirements.yml b/tests/fixtures/test_project/docs/reqstool/requirements.yml index 5040328..91bb93d 100644 --- a/tests/fixtures/test_project/docs/reqstool/requirements.yml +++ b/tests/fixtures/test_project/docs/reqstool/requirements.yml @@ -1,5 +1,8 @@ -document: - id: mypackage +# yaml-language-server: $schema=https://raw.githubusercontent.com/reqstool/reqstool-client/main/src/reqstool/resources/schemas/v1/requirements.schema.json + +metadata: + urn: mypackage + variant: microservice title: Mypackage Requirements url: https://github.com/reqstool/reqstool-python-poetry-plugin @@ -8,6 +11,5 @@ requirements: title: Hello function significance: shall description: The hello function shall return "hello". - categories: - - category: functional + categories: ["functional-suitability"] revision: "0.1.0" diff --git a/tests/fixtures/test_project/docs/reqstool/software_verification_cases.yml b/tests/fixtures/test_project/docs/reqstool/software_verification_cases.yml new file mode 100644 index 0000000..da083ba --- /dev/null +++ b/tests/fixtures/test_project/docs/reqstool/software_verification_cases.yml @@ -0,0 +1,8 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/reqstool/reqstool-client/main/src/reqstool/resources/schemas/v1/software_verification_cases.schema.json + +cases: + - id: SVC_001 + requirement_ids: ["REQ_001"] + title: "Hello function returns hello" + verification: automated-test + revision: "0.1.0" diff --git a/tests/fixtures/test_project/pyproject.toml b/tests/fixtures/test_project/pyproject.toml index 151931c..82f0bf9 100644 --- a/tests/fixtures/test_project/pyproject.toml +++ b/tests/fixtures/test_project/pyproject.toml @@ -17,6 +17,16 @@ include = ["reqstool_config.yml", "docs/reqstool/**/*", "build/reqstool/**/*"] [tool.poetry.dependencies] python = "^3.13" +[tool.poetry.group.dev.dependencies] +pytest = "*" +pytest-cov = "*" + +[tool.pytest.ini_options] +addopts = ["--import-mode=importlib"] +pythonpath = ["src"] +testpaths = ["tests"] +junit_family = "xunit2" + [tool.reqstool] sources = ["src", "tests"] test_results = ["build/**/junit.xml"] diff --git a/tests/fixtures/test_project/tests/test_main.py b/tests/fixtures/test_project/tests/test_main.py new file mode 100644 index 0000000..72e7562 --- /dev/null +++ b/tests/fixtures/test_project/tests/test_main.py @@ -0,0 +1,8 @@ +from reqstool_python_decorators.decorators.decorators import SVCs + +from mypackage.main import hello + + +@SVCs("SVC_001") +def test_hello(): + assert hello() == "hello"