Skip to content
Merged
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
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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\"')",
Expand Down
43 changes: 32 additions & 11 deletions tests/fixtures/test_project/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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
Expand All @@ -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
Expand All @@ -45,18 +53,19 @@ include = ["reqstool_config.yml", "docs/reqstool/**/*", "build/reqstool/**/*"]
Expected output (in order):
1. `[reqstool] plugin version <x.y.z>`
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`

### 3Verify
### 4Check 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
Expand All @@ -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.
10 changes: 6 additions & 4 deletions tests/fixtures/test_project/docs/reqstool/requirements.yml
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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"
Original file line number Diff line number Diff line change
@@ -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"
10 changes: 10 additions & 0 deletions tests/fixtures/test_project/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
8 changes: 8 additions & 0 deletions tests/fixtures/test_project/tests/test_main.py
Original file line number Diff line number Diff line change
@@ -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"
Loading