prodc 0.3.1__tar.gz → 0.3.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: prodc
3
- Version: 0.3.1
3
+ Version: 0.3.2
4
4
  Summary: Product management as code: personas, flows, and features traced to evidence.
5
5
  Project-URL: Homepage, https://gitlab.com/jorgeecardona/prodc
6
6
  Project-URL: Repository, https://gitlab.com/jorgeecardona/prodc
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "prodc"
3
- version = "0.3.1"
3
+ version = "0.3.2"
4
4
  description = "Product management as code: personas, flows, and features traced to evidence."
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.12"
@@ -201,13 +201,21 @@ class PytestAdapter:
201
201
  return out
202
202
 
203
203
  def resolve(self, payload: str) -> ProofResult:
204
- file_part, _, node = payload.partition("::")
205
- func = node.split("[")[0] # strip parametrisation
204
+ # Node id: file[::Class[::Nested]]::test_name, each segment may carry [params].
205
+ parts = [p.split("[")[0] for p in payload.split("::")]
206
+ file_part = parts[0]
207
+ node = parts[1:]
208
+ func = node[-1] if node else ""
209
+ classes = node[:-1] # class path for class-based tests (file::TestX::test_y)
206
210
  fp = self._root / file_part
207
211
  if not fp.exists():
208
212
  return ProofResult(ProofState.BROKEN, False, f"no file '{file_part}'")
209
- if func and f"def {func}" not in fp.read_text(encoding="utf-8"):
210
- return ProofResult(ProofState.BROKEN, False, f"no test '{func}' in {file_part}")
213
+ text = fp.read_text(encoding="utf-8")
214
+ missing = [f"class {c}" for c in classes if f"class {c}" not in text]
215
+ if func and f"def {func}" not in text:
216
+ missing.append(f"def {func}")
217
+ if missing:
218
+ return ProofResult(ProofState.BROKEN, False, f"no {', '.join(missing)} in {file_part}")
211
219
  results = self._load_results()
212
220
  if func in results:
213
221
  ok = results[func]
@@ -217,3 +225,21 @@ class PytestAdapter:
217
225
  "junit: passed" if ok else "junit: failing",
218
226
  )
219
227
  return ProofResult(ProofState.DELIVERED, True, "test exists")
228
+
229
+
230
+ class FilesAdapter:
231
+ """Resolves ``path`` to a verification script's existence.
232
+
233
+ For proofs that are executable models/scripts, not pytest tests. Existence is a
234
+ *declared* DELIVERED — a script existing is not a script passing; a run/result
235
+ marker (confirmed) is left for later, mirroring the gherkin/pytest results split.
236
+ """
237
+
238
+ def __init__(self, root: Path) -> None:
239
+ self._root = root
240
+
241
+ def resolve(self, payload: str) -> ProofResult:
242
+ fp = self._root / payload
243
+ if not fp.exists():
244
+ return ProofResult(ProofState.BROKEN, False, f"no file '{payload}'")
245
+ return ProofResult(ProofState.DELIVERED, True, "script exists")
@@ -7,7 +7,7 @@ from dataclasses import dataclass, field
7
7
  from pathlib import Path
8
8
  from typing import cast
9
9
 
10
- from .adapters import Adapter, GherkinAdapter, PytestAdapter
10
+ from .adapters import Adapter, FilesAdapter, GherkinAdapter, PytestAdapter
11
11
 
12
12
 
13
13
  class ConfigError(Exception):
@@ -70,6 +70,11 @@ class Config:
70
70
  root=root / (sub if isinstance(sub, str) else "."),
71
71
  results=results_s,
72
72
  )
73
+ elif kind == "files":
74
+ sub = tbl.get("root", ".")
75
+ adapters[name] = FilesAdapter(root=root / (sub if isinstance(sub, str) else "."))
73
76
  else:
74
- raise ConfigError(f"[proofs.{name}]: unknown kind {kind!r} (gherkin|pytest)")
77
+ raise ConfigError(
78
+ f"[proofs.{name}]: unknown kind {kind!r} (gherkin|pytest|files)"
79
+ )
75
80
  return cls(root=root, need_globs=need_globs, adapters=adapters)
@@ -0,0 +1,54 @@
1
+ """Adapters: pytest class-based node ids (#6) and the files adapter (#7)."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from pathlib import Path
6
+
7
+ from prodc.adapters import FilesAdapter, PytestAdapter
8
+ from prodc.model import ProofState
9
+
10
+
11
+ def _pytest_file(tmp_path: Path) -> PytestAdapter:
12
+ (tmp_path / "test_x.py").write_text(
13
+ "class TestX:\n"
14
+ " def test_y(self):\n"
15
+ " assert True\n"
16
+ "\n"
17
+ "def test_z():\n"
18
+ " assert True\n",
19
+ encoding="utf-8",
20
+ )
21
+ return PytestAdapter(root=tmp_path, results=None)
22
+
23
+
24
+ def test_pytest_resolves_class_based_node_id(tmp_path: Path) -> None:
25
+ adapter = _pytest_file(tmp_path)
26
+ r = adapter.resolve("test_x.py::TestX::test_y")
27
+ assert r.state is ProofState.DELIVERED and r.declared # existence only
28
+
29
+
30
+ def test_pytest_resolves_plain_function(tmp_path: Path) -> None:
31
+ assert _pytest_file(tmp_path).resolve("test_x.py::test_z").state is ProofState.DELIVERED
32
+
33
+
34
+ def test_pytest_missing_method_in_class_is_broken(tmp_path: Path) -> None:
35
+ assert _pytest_file(tmp_path).resolve("test_x.py::TestX::test_nope").state is ProofState.BROKEN
36
+
37
+
38
+ def test_pytest_missing_class_is_broken(tmp_path: Path) -> None:
39
+ assert _pytest_file(tmp_path).resolve("test_x.py::TestNope::test_y").state is ProofState.BROKEN
40
+
41
+
42
+ def test_pytest_strips_parametrisation(tmp_path: Path) -> None:
43
+ r = _pytest_file(tmp_path).resolve("test_x.py::TestX::test_y[case1]")
44
+ assert r.state is ProofState.DELIVERED
45
+
46
+
47
+ def test_files_adapter_existence_is_declared(tmp_path: Path) -> None:
48
+ (tmp_path / "verify.py").write_text("# a model\n", encoding="utf-8")
49
+ r = FilesAdapter(root=tmp_path).resolve("verify.py")
50
+ assert r.state is ProofState.DELIVERED and r.declared # existence != passing
51
+
52
+
53
+ def test_files_adapter_missing_is_broken(tmp_path: Path) -> None:
54
+ assert FilesAdapter(root=tmp_path).resolve("gone.py").state is ProofState.BROKEN
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes