specrig 0.1.0__tar.gz → 0.2.0__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.
Files changed (140) hide show
  1. {specrig-0.1.0 → specrig-0.2.0}/PKG-INFO +29 -17
  2. {specrig-0.1.0 → specrig-0.2.0}/README.md +19 -8
  3. {specrig-0.1.0 → specrig-0.2.0}/docs/design.md +19 -10
  4. {specrig-0.1.0 → specrig-0.2.0}/pyproject.toml +9 -9
  5. {specrig-0.1.0 → specrig-0.2.0}/samples/reminders/specrig.md +1 -1
  6. {specrig-0.1.0 → specrig-0.2.0}/samples/shop/specrig.md +1 -1
  7. {specrig-0.1.0 → specrig-0.2.0}/src/specrig/fastapi/__init__.py +6 -2
  8. {specrig-0.1.0 → specrig-0.2.0}/src/specrig/postgres.py +62 -9
  9. {specrig-0.1.0 → specrig-0.2.0}/tests/test_harness.py +61 -0
  10. specrig-0.2.0/tests/test_postgres.py +197 -0
  11. {specrig-0.1.0 → specrig-0.2.0}/.github/workflows/release.yml +0 -0
  12. {specrig-0.1.0 → specrig-0.2.0}/.gitignore +0 -0
  13. {specrig-0.1.0 → specrig-0.2.0}/LICENSE +0 -0
  14. {specrig-0.1.0 → specrig-0.2.0}/Makefile +0 -0
  15. {specrig-0.1.0 → specrig-0.2.0}/samples/docs/billing.yaml +0 -0
  16. {specrig-0.1.0 → specrig-0.2.0}/samples/reminders/AGENTS.md +0 -0
  17. {specrig-0.1.0 → specrig-0.2.0}/samples/reminders/CLAUDE.md +0 -0
  18. {specrig-0.1.0 → specrig-0.2.0}/samples/reminders/config/__init__.py +0 -0
  19. {specrig-0.1.0 → specrig-0.2.0}/samples/reminders/config/settings.py +0 -0
  20. {specrig-0.1.0 → specrig-0.2.0}/samples/reminders/config/urls.py +0 -0
  21. {specrig-0.1.0 → specrig-0.2.0}/samples/reminders/config/wsgi.py +0 -0
  22. {specrig-0.1.0 → specrig-0.2.0}/samples/reminders/manage.py +0 -0
  23. {specrig-0.1.0 → specrig-0.2.0}/samples/reminders/pyproject.toml +0 -0
  24. {specrig-0.1.0 → specrig-0.2.0}/samples/reminders/reminders/__init__.py +0 -0
  25. {specrig-0.1.0 → specrig-0.2.0}/samples/reminders/reminders/billing.py +0 -0
  26. {specrig-0.1.0 → specrig-0.2.0}/samples/reminders/reminders/jobs.py +0 -0
  27. {specrig-0.1.0 → specrig-0.2.0}/samples/reminders/reminders/management/__init__.py +0 -0
  28. {specrig-0.1.0 → specrig-0.2.0}/samples/reminders/reminders/management/commands/__init__.py +0 -0
  29. {specrig-0.1.0 → specrig-0.2.0}/samples/reminders/reminders/management/commands/remind.py +0 -0
  30. {specrig-0.1.0 → specrig-0.2.0}/samples/reminders/reminders/migrations/0001_initial.py +0 -0
  31. {specrig-0.1.0 → specrig-0.2.0}/samples/reminders/reminders/migrations/__init__.py +0 -0
  32. {specrig-0.1.0 → specrig-0.2.0}/samples/reminders/reminders/models.py +0 -0
  33. {specrig-0.1.0 → specrig-0.2.0}/samples/reminders/reminders/views.py +0 -0
  34. {specrig-0.1.0 → specrig-0.2.0}/samples/reminders/specrig.yaml +0 -0
  35. {specrig-0.1.0 → specrig-0.2.0}/samples/reminders/tests/checks.yaml +0 -0
  36. {specrig-0.1.0 → specrig-0.2.0}/samples/reminders/tests/features/history.feature +0 -0
  37. {specrig-0.1.0 → specrig-0.2.0}/samples/reminders/tests/features/reminders.feature +0 -0
  38. {specrig-0.1.0 → specrig-0.2.0}/samples/reminders/tests/flows.yaml +0 -0
  39. {specrig-0.1.0 → specrig-0.2.0}/samples/reminders/tests/internal/boot.feature +0 -0
  40. {specrig-0.1.0 → specrig-0.2.0}/samples/reminders/tests/internal/harness.py +0 -0
  41. {specrig-0.1.0 → specrig-0.2.0}/samples/reminders/tests/internal/test_cases.py +0 -0
  42. {specrig-0.1.0 → specrig-0.2.0}/samples/reminders/tests/steps/history.py +0 -0
  43. {specrig-0.1.0 → specrig-0.2.0}/samples/reminders/tests/steps/reminders.py +0 -0
  44. {specrig-0.1.0 → specrig-0.2.0}/samples/reminders/tests/surface.yaml +0 -0
  45. {specrig-0.1.0 → specrig-0.2.0}/samples/shop/AGENTS.md +0 -0
  46. {specrig-0.1.0 → specrig-0.2.0}/samples/shop/CLAUDE.md +0 -0
  47. {specrig-0.1.0 → specrig-0.2.0}/samples/shop/alembic.ini +0 -0
  48. {specrig-0.1.0 → specrig-0.2.0}/samples/shop/migrations/env.py +0 -0
  49. {specrig-0.1.0 → specrig-0.2.0}/samples/shop/migrations/versions/0001_orders.py +0 -0
  50. {specrig-0.1.0 → specrig-0.2.0}/samples/shop/pyproject.toml +0 -0
  51. {specrig-0.1.0 → specrig-0.2.0}/samples/shop/shop/__init__.py +0 -0
  52. {specrig-0.1.0 → specrig-0.2.0}/samples/shop/shop/billing.py +0 -0
  53. {specrig-0.1.0 → specrig-0.2.0}/samples/shop/shop/cli.py +0 -0
  54. {specrig-0.1.0 → specrig-0.2.0}/samples/shop/shop/db.py +0 -0
  55. {specrig-0.1.0 → specrig-0.2.0}/samples/shop/shop/jobs.py +0 -0
  56. {specrig-0.1.0 → specrig-0.2.0}/samples/shop/shop/main.py +0 -0
  57. {specrig-0.1.0 → specrig-0.2.0}/samples/shop/shop/settings.py +0 -0
  58. {specrig-0.1.0 → specrig-0.2.0}/samples/shop/specrig.yaml +0 -0
  59. {specrig-0.1.0 → specrig-0.2.0}/samples/shop/tests/checks.yaml +0 -0
  60. {specrig-0.1.0 → specrig-0.2.0}/samples/shop/tests/features/orders.feature +0 -0
  61. {specrig-0.1.0 → specrig-0.2.0}/samples/shop/tests/features/placing.feature +0 -0
  62. {specrig-0.1.0 → specrig-0.2.0}/samples/shop/tests/flows.yaml +0 -0
  63. {specrig-0.1.0 → specrig-0.2.0}/samples/shop/tests/internal/boot.feature +0 -0
  64. {specrig-0.1.0 → specrig-0.2.0}/samples/shop/tests/internal/harness.py +0 -0
  65. {specrig-0.1.0 → specrig-0.2.0}/samples/shop/tests/internal/test_cases.py +0 -0
  66. {specrig-0.1.0 → specrig-0.2.0}/samples/shop/tests/steps/orders.py +0 -0
  67. {specrig-0.1.0 → specrig-0.2.0}/samples/shop/tests/steps/placing.py +0 -0
  68. {specrig-0.1.0 → specrig-0.2.0}/samples/shop/tests/surface.yaml +0 -0
  69. {specrig-0.1.0 → specrig-0.2.0}/src/specrig/__init__.py +0 -0
  70. {specrig-0.1.0 → specrig-0.2.0}/src/specrig/__main__.py +0 -0
  71. {specrig-0.1.0 → specrig-0.2.0}/src/specrig/_yaml.py +0 -0
  72. {specrig-0.1.0 → specrig-0.2.0}/src/specrig/asgi.py +0 -0
  73. {specrig-0.1.0 → specrig-0.2.0}/src/specrig/backend.py +0 -0
  74. {specrig-0.1.0 → specrig-0.2.0}/src/specrig/clock.py +0 -0
  75. {specrig-0.1.0 → specrig-0.2.0}/src/specrig/code/__init__.py +0 -0
  76. {specrig-0.1.0 → specrig-0.2.0}/src/specrig/code/calls.py +0 -0
  77. {specrig-0.1.0 → specrig-0.2.0}/src/specrig/code/django.py +0 -0
  78. {specrig-0.1.0 → specrig-0.2.0}/src/specrig/code/fastapi.py +0 -0
  79. {specrig-0.1.0 → specrig-0.2.0}/src/specrig/code/index.py +0 -0
  80. {specrig-0.1.0 → specrig-0.2.0}/src/specrig/code/settings.py +0 -0
  81. {specrig-0.1.0 → specrig-0.2.0}/src/specrig/contract.py +0 -0
  82. {specrig-0.1.0 → specrig-0.2.0}/src/specrig/django/__init__.py +0 -0
  83. {specrig-0.1.0 → specrig-0.2.0}/src/specrig/docker.py +0 -0
  84. {specrig-0.1.0 → specrig-0.2.0}/src/specrig/flows.py +0 -0
  85. {specrig-0.1.0 → specrig-0.2.0}/src/specrig/gate.py +0 -0
  86. {specrig-0.1.0 → specrig-0.2.0}/src/specrig/http.py +0 -0
  87. {specrig-0.1.0 → specrig-0.2.0}/src/specrig/protocol/agents/contributing.md +0 -0
  88. {specrig-0.1.0 → specrig-0.2.0}/src/specrig/protocol/agents/header.md +0 -0
  89. {specrig-0.1.0 → specrig-0.2.0}/src/specrig/protocol/agents/reference.md +0 -0
  90. {specrig-0.1.0 → specrig-0.2.0}/src/specrig/protocol/agents/rule11.md +0 -0
  91. {specrig-0.1.0 → specrig-0.2.0}/src/specrig/protocol/agents/short.md +0 -0
  92. {specrig-0.1.0 → specrig-0.2.0}/src/specrig/protocol/modes.yaml +0 -0
  93. {specrig-0.1.0 → specrig-0.2.0}/src/specrig/proxy.py +0 -0
  94. {specrig-0.1.0 → specrig-0.2.0}/src/specrig/py.typed +0 -0
  95. {specrig-0.1.0 → specrig-0.2.0}/src/specrig/records.py +0 -0
  96. {specrig-0.1.0 → specrig-0.2.0}/src/specrig/redis.py +0 -0
  97. {specrig-0.1.0 → specrig-0.2.0}/src/specrig/resource.py +0 -0
  98. {specrig-0.1.0 → specrig-0.2.0}/src/specrig/rig.py +0 -0
  99. {specrig-0.1.0 → specrig-0.2.0}/src/specrig/run.py +0 -0
  100. {specrig-0.1.0 → specrig-0.2.0}/src/specrig/standins.py +0 -0
  101. {specrig-0.1.0 → specrig-0.2.0}/src/specrig/suite.py +0 -0
  102. {specrig-0.1.0 → specrig-0.2.0}/src/specrig/surface.py +0 -0
  103. {specrig-0.1.0 → specrig-0.2.0}/src/specrig/tool/__init__.py +0 -0
  104. {specrig-0.1.0 → specrig-0.2.0}/src/specrig/tool/agents.py +0 -0
  105. {specrig-0.1.0 → specrig-0.2.0}/src/specrig/tool/cli.py +0 -0
  106. {specrig-0.1.0 → specrig-0.2.0}/src/specrig/tool/init.py +0 -0
  107. {specrig-0.1.0 → specrig-0.2.0}/src/specrig/tool/modes.py +0 -0
  108. {specrig-0.1.0 → specrig-0.2.0}/src/specrig/tool/service.py +0 -0
  109. {specrig-0.1.0 → specrig-0.2.0}/src/specrig/tool/templates.py +0 -0
  110. {specrig-0.1.0 → specrig-0.2.0}/tests/fixtures/django/manage.py +0 -0
  111. {specrig-0.1.0 → specrig-0.2.0}/tests/fixtures/django/pyproject.toml +0 -0
  112. {specrig-0.1.0 → specrig-0.2.0}/tests/fixtures/django/stock/__init__.py +0 -0
  113. {specrig-0.1.0 → specrig-0.2.0}/tests/fixtures/django/stock/api.py +0 -0
  114. {specrig-0.1.0 → specrig-0.2.0}/tests/fixtures/django/stock/settings.py +0 -0
  115. {specrig-0.1.0 → specrig-0.2.0}/tests/fixtures/django/stock/urls.py +0 -0
  116. {specrig-0.1.0 → specrig-0.2.0}/tests/fixtures/django/stock/views.py +0 -0
  117. {specrig-0.1.0 → specrig-0.2.0}/tests/fixtures/django/stock/warehouse.py +0 -0
  118. {specrig-0.1.0 → specrig-0.2.0}/tests/fixtures/fastapi/.env.example +0 -0
  119. {specrig-0.1.0 → specrig-0.2.0}/tests/fixtures/fastapi/gateway/__init__.py +0 -0
  120. {specrig-0.1.0 → specrig-0.2.0}/tests/fixtures/fastapi/gateway/config.py +0 -0
  121. {specrig-0.1.0 → specrig-0.2.0}/tests/fixtures/fastapi/gateway/crm.py +0 -0
  122. {specrig-0.1.0 → specrig-0.2.0}/tests/fixtures/fastapi/gateway/main.py +0 -0
  123. {specrig-0.1.0 → specrig-0.2.0}/tests/fixtures/fastapi/gateway/routes/__init__.py +0 -0
  124. {specrig-0.1.0 → specrig-0.2.0}/tests/fixtures/fastapi/gateway/routes/orders.py +0 -0
  125. {specrig-0.1.0 → specrig-0.2.0}/tests/fixtures/fastapi/gateway/sessions.py +0 -0
  126. {specrig-0.1.0 → specrig-0.2.0}/tests/fixtures/fastapi/pyproject.toml +0 -0
  127. {specrig-0.1.0 → specrig-0.2.0}/tests/fixtures/protocol/agents/verdicts.yaml +0 -0
  128. {specrig-0.1.0 → specrig-0.2.0}/tests/fixtures/protocol/markers/areas.yaml +0 -0
  129. {specrig-0.1.0 → specrig-0.2.0}/tests/fixtures/protocol/records/reminders.flows.yaml +0 -0
  130. {specrig-0.1.0 → specrig-0.2.0}/tests/fixtures/protocol/records/reminders.trace.json +0 -0
  131. {specrig-0.1.0 → specrig-0.2.0}/tests/fixtures/protocol/records/shop.flows.yaml +0 -0
  132. {specrig-0.1.0 → specrig-0.2.0}/tests/fixtures/protocol/records/shop.trace.json +0 -0
  133. {specrig-0.1.0 → specrig-0.2.0}/tests/test_agents.py +0 -0
  134. {specrig-0.1.0 → specrig-0.2.0}/tests/test_backend.py +0 -0
  135. {specrig-0.1.0 → specrig-0.2.0}/tests/test_flows.py +0 -0
  136. {specrig-0.1.0 → specrig-0.2.0}/tests/test_format.py +0 -0
  137. {specrig-0.1.0 → specrig-0.2.0}/tests/test_gate.py +0 -0
  138. {specrig-0.1.0 → specrig-0.2.0}/tests/test_init.py +0 -0
  139. {specrig-0.1.0 → specrig-0.2.0}/tests/test_rules.py +0 -0
  140. {specrig-0.1.0 → specrig-0.2.0}/tests/test_surface.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: specrig
3
- Version: 0.1.0
3
+ Version: 0.2.0
4
4
  Summary: A harness for a FastAPI or Django service developed specification first
5
5
  Project-URL: Homepage, https://github.com/specrig/specrig-python
6
6
  Project-URL: Protocol, https://github.com/specrig/protocol
@@ -11,18 +11,19 @@ Classifier: Framework :: FastAPI
11
11
  Classifier: Framework :: Pytest
12
12
  Classifier: Programming Language :: Python :: 3
13
13
  Requires-Python: >=3.11
14
- Requires-Dist: jsonschema>=4.18
14
+ Requires-Dist: jsonschema>=4.0
15
15
  Requires-Dist: pytest-bdd>=8.1
16
- Requires-Dist: pytest>=8.4
17
- Requires-Dist: pyyaml>=6.0
18
- Requires-Dist: time-machine>=2.16
19
- Requires-Dist: tomlkit>=0.13
16
+ Requires-Dist: pytest>=7.4
17
+ Requires-Dist: pyyaml>=6.0.1
18
+ Requires-Dist: time-machine>=2.10
19
+ Requires-Dist: tomlkit>=0.11
20
20
  Provides-Extra: django
21
- Requires-Dist: django>=5.2; extra == 'django'
21
+ Requires-Dist: django>=4.2; extra == 'django'
22
22
  Provides-Extra: fastapi
23
- Requires-Dist: fastapi>=0.115; extra == 'fastapi'
23
+ Requires-Dist: anyio>=4; extra == 'fastapi'
24
+ Requires-Dist: fastapi>=0.90; extra == 'fastapi'
24
25
  Provides-Extra: postgres
25
- Requires-Dist: psycopg[binary]>=3.2; extra == 'postgres'
26
+ Requires-Dist: psycopg[binary]>=3.1; extra == 'postgres'
26
27
  Description-Content-Type: text/markdown
27
28
 
28
29
  # specrig for Python
@@ -260,8 +261,8 @@ lifespan runs from the boot to the end of the case, what the service's modules
260
261
  cache with `functools.cache` or `lru_cache` is forgotten, Django's caches are
261
262
  cleared and its connections closed, and the case's requests come from an address
262
263
  of its own, so what the service keeps by its caller's address — a rate limit — is
263
- not the last case's. The resources are provisioned once per run and emptied
264
- before every case, before the service starts.
264
+ not the last case's. The resources are provisioned once per run and put back as
265
+ the migrations left them before every case, before the service starts.
265
266
 
266
267
  A call no step answered gets a 501 and fails the case, named. After the case,
267
268
  every request and every answer is checked against the neighbour's contract: an
@@ -309,7 +310,7 @@ in `settings = "config.settings"` where FastAPI's names `app`; the rest is the s
309
310
  | `console` | FastAPI: the service's console, `module:callable`, where `pyproject.toml` has more than one script |
310
311
  | `constants` | the other variables the harness answers, as given |
311
312
  | `allow` | what a case may replace, as `module:name` |
312
- | `seed()` | what production holds before the service starts and no case is about — the first administrator, say —, written through the service's own models into the resources just emptied, before every start |
313
+ | `seed()` | what production holds before the service starts that the migrations do not write and no case is about — the first administrator, say —, written through the service's own models into the resources just put back, before every start |
313
314
 
314
315
  A grant is a name the harness resolves when the service boots, so a renamed class
315
316
  breaks the boot instead of lingering in a list.
@@ -359,7 +360,7 @@ database is welcome where the service's settings are not.
359
360
  ## Postgres
360
361
 
361
362
  ```python
362
- database = Postgres("DATABASE_URL", scheme="postgresql+psycopg", keep=["currencies"])
363
+ database = Postgres("DATABASE_URL", scheme="postgresql+psycopg")
363
364
  ```
364
365
 
365
366
  The variable receives one URL with the scheme given, `postgresql` by default. The
@@ -375,8 +376,18 @@ take it away whenever the service connected. The schema is the service's own,
375
376
  built at the first boot of the run, before the service starts, since a start may
376
377
  read its database: `alembic upgrade head` where the service has an `alembic.ini`,
377
378
  in a process of its own as production runs it, else whatever its lifespan
378
- creates; Django's `migrate`. Before every case, before the service starts, every
379
- table there is is truncated but the migrations' own and those `keep=` names.
379
+ creates; Django's `migrate`. Then the rows the migrations wrote — a Django data
380
+ migration's, alembic's `op.bulk_insert`'s — are copied into a `specrig_baseline`
381
+ schema, and where each sequence stood is remembered. Before every case, before
382
+ the service starts, the database goes back to what the migrations left: every
383
+ table there is is truncated but the migration tool's own and those `keep=` names,
384
+ and the copied rows are written back — a row a migration wrote is there in every
385
+ case, a case's own is gone, and ids go on after the seeded ones. A table the
386
+ service creates as it starts has no rows copied, and is emptied. Writing the rows
387
+ back turns foreign keys and triggers off for one transaction, which needs a
388
+ superuser: the container's role is one, and migrations that write no rows need
389
+ none. A row a migration writes needs no `keep=`; a kept table is one no case
390
+ resets.
380
391
 
381
392
  `harness.database.fail_with()` closes the gate: every connection the service holds
382
393
  is cut and every new one refused, as by a database that is down, and the service
@@ -518,8 +529,9 @@ the edits are let through, and the plugin says so once.
518
529
 
519
530
  ## Limits
520
531
 
521
- - FastAPI, and any ASGI application a module builds, through the `fastapi`
522
- harness; Django 5.2 and up through its WSGI handler. Flask has no harness.
532
+ - FastAPI 0.90 and up, and any ASGI application a module builds, through the
533
+ `fastapi` harness; Django 4.2 and up through its WSGI handler. Flask has no
534
+ harness.
523
535
  - The service is imported once per run: what a module builds as it loads — a
524
536
  dictionary it fills, a client it opens at import — is the run's, not the case's.
525
537
  A service that keeps such state builds it in its lifespan, or caches it with
@@ -233,8 +233,8 @@ lifespan runs from the boot to the end of the case, what the service's modules
233
233
  cache with `functools.cache` or `lru_cache` is forgotten, Django's caches are
234
234
  cleared and its connections closed, and the case's requests come from an address
235
235
  of its own, so what the service keeps by its caller's address — a rate limit — is
236
- not the last case's. The resources are provisioned once per run and emptied
237
- before every case, before the service starts.
236
+ not the last case's. The resources are provisioned once per run and put back as
237
+ the migrations left them before every case, before the service starts.
238
238
 
239
239
  A call no step answered gets a 501 and fails the case, named. After the case,
240
240
  every request and every answer is checked against the neighbour's contract: an
@@ -282,7 +282,7 @@ in `settings = "config.settings"` where FastAPI's names `app`; the rest is the s
282
282
  | `console` | FastAPI: the service's console, `module:callable`, where `pyproject.toml` has more than one script |
283
283
  | `constants` | the other variables the harness answers, as given |
284
284
  | `allow` | what a case may replace, as `module:name` |
285
- | `seed()` | what production holds before the service starts and no case is about — the first administrator, say —, written through the service's own models into the resources just emptied, before every start |
285
+ | `seed()` | what production holds before the service starts that the migrations do not write and no case is about — the first administrator, say —, written through the service's own models into the resources just put back, before every start |
286
286
 
287
287
  A grant is a name the harness resolves when the service boots, so a renamed class
288
288
  breaks the boot instead of lingering in a list.
@@ -332,7 +332,7 @@ database is welcome where the service's settings are not.
332
332
  ## Postgres
333
333
 
334
334
  ```python
335
- database = Postgres("DATABASE_URL", scheme="postgresql+psycopg", keep=["currencies"])
335
+ database = Postgres("DATABASE_URL", scheme="postgresql+psycopg")
336
336
  ```
337
337
 
338
338
  The variable receives one URL with the scheme given, `postgresql` by default. The
@@ -348,8 +348,18 @@ take it away whenever the service connected. The schema is the service's own,
348
348
  built at the first boot of the run, before the service starts, since a start may
349
349
  read its database: `alembic upgrade head` where the service has an `alembic.ini`,
350
350
  in a process of its own as production runs it, else whatever its lifespan
351
- creates; Django's `migrate`. Before every case, before the service starts, every
352
- table there is is truncated but the migrations' own and those `keep=` names.
351
+ creates; Django's `migrate`. Then the rows the migrations wrote — a Django data
352
+ migration's, alembic's `op.bulk_insert`'s — are copied into a `specrig_baseline`
353
+ schema, and where each sequence stood is remembered. Before every case, before
354
+ the service starts, the database goes back to what the migrations left: every
355
+ table there is is truncated but the migration tool's own and those `keep=` names,
356
+ and the copied rows are written back — a row a migration wrote is there in every
357
+ case, a case's own is gone, and ids go on after the seeded ones. A table the
358
+ service creates as it starts has no rows copied, and is emptied. Writing the rows
359
+ back turns foreign keys and triggers off for one transaction, which needs a
360
+ superuser: the container's role is one, and migrations that write no rows need
361
+ none. A row a migration writes needs no `keep=`; a kept table is one no case
362
+ resets.
353
363
 
354
364
  `harness.database.fail_with()` closes the gate: every connection the service holds
355
365
  is cut and every new one refused, as by a database that is down, and the service
@@ -491,8 +501,9 @@ the edits are let through, and the plugin says so once.
491
501
 
492
502
  ## Limits
493
503
 
494
- - FastAPI, and any ASGI application a module builds, through the `fastapi`
495
- harness; Django 5.2 and up through its WSGI handler. Flask has no harness.
504
+ - FastAPI 0.90 and up, and any ASGI application a module builds, through the
505
+ `fastapi` harness; Django 4.2 and up through its WSGI handler. Flask has no
506
+ harness.
496
507
  - The service is imported once per run: what a module builds as it loads — a
497
508
  dictionary it fills, a client it opens at import — is the run's, not the case's.
498
509
  A service that keeps such state builds it in its lifespan, or caches it with
@@ -38,18 +38,26 @@ modules are imported once per process, and the service's are no exception:
38
38
  So what makes a case's service its own is everything around the import: FastAPI's
39
39
  lifespan runs per case, the caches the service's modules keep through `functools`
40
40
  are forgotten, Django's caches are cleared and its connections closed, the
41
- resources are emptied, and every case calls from an address of its own, so a
42
- rate limit kept by address in a module is not spent by the cases before. What a
43
- module builds as it loads is the run's — a stated limit, not a hidden one.
41
+ resources go back to what the migrations left, and every case calls from an
42
+ address of its own, so a rate limit kept by address in a module is not spent by
43
+ the cases before. What a module builds as it loads is the run's — a stated limit,
44
+ not a hidden one.
44
45
 
45
46
  ## A start may read the database
46
47
 
47
48
  PHP's Laravel and Symfony build the application without touching the database, so
48
49
  the resources are readied after the boot. A FastAPI service's start often does
49
50
  read it — creates its tables, seeds, refuses to start without an administrator —
50
- so here the order is: migrate once, empty the resources, `seed()` what production
51
- holds before the start, start the service, then apply the faults a step set
52
- before the boot.
51
+ so here the order is: migrate once, put the resources back as the migrations left
52
+ them, `seed()` what production holds before the start and the migrations do not
53
+ write, start the service, then apply the faults a step set before the boot.
54
+
55
+ Back as the migrations left them, not empty: a schema without the rows its
56
+ migrations write — the states an order moves through, the root of a tree — exists
57
+ in no environment, a step that writes them again is a second copy of the
58
+ migration that drifts from the first, and a `keep` for them carries one case's
59
+ changes into the next. Writing them back turns foreign keys and triggers off for
60
+ one transaction, which takes a superuser; migrations that write no rows need none.
53
61
 
54
62
  ## One request at a time
55
63
 
@@ -74,7 +82,7 @@ flight between steps, and `time_out` stands in for a slow neighbour, as in PHP.
74
82
  | clock | `time-machine`, from the step that sets it | the same |
75
83
  | logs | a handler on the root logger, beside the service's | the same |
76
84
  | grants | `replace(name, instance)`: the name replaced in every module of the service that holds it, and in FastAPI's `dependency_overrides` | the name replaced in every module that holds it |
77
- | Postgres | `alembic upgrade head` once per run, in a process of its own; every table but `alembic_version` and `keep` truncated before every case; a refusal by the gate, an error by SQLAlchemy's `before_cursor_execute` | `migrate` once per run; every table but Django's bookkeeping and `keep` truncated; an error by the connections' execute wrappers |
85
+ | Postgres | `alembic upgrade head` once per run, in a process of its own, and the rows it wrote kept aside; before every case every table but `alembic_version` and `keep` truncated and those rows written back, with the sequences where they stood; a refusal by the gate, an error by SQLAlchemy's `before_cursor_execute` | `migrate` once per run, and the rows it wrote kept aside; every table but Django's bookkeeping and `keep` truncated and those rows written back; an error by the connections' execute wrappers |
78
86
  | Redis | `FLUSHDB` before every case; a refusal by the gate | the same |
79
87
  | steps | pytest-bdd: a plugin of `pytest11` marks Given, When and Then, fails a case on what the harness found, and writes `tests/flows.yaml` after a whole run | |
80
88
  | `tests/surface.yaml` | Python's `ast` over the service's modules: routes from FastAPI's decorators and routers | routes from the `ROOT_URLCONF` and the views' methods |
@@ -144,9 +152,10 @@ libraries.
144
152
 
145
153
  ## The owner's calls
146
154
 
147
- 1. **Python and the frameworks.** Python 3.11 and up; FastAPI, and any ASGI app a
148
- module builds; Django 5.2 and up.
149
- 2. **pytest-bdd.** 8.1 and up, and pytest 8.4 and up.
155
+ 1. **Python and the frameworks.** Python 3.11 and up; FastAPI 0.90 and up, and any
156
+ ASGI app a module builds; Django 4.2 and up. Not the newest, and not what nobody
157
+ runs any more.
158
+ 2. **pytest-bdd.** 8.1 and up, and pytest 7.4 and up.
150
159
  3. **No bus yet.** RabbitMQ, Celery and Django's tasks are a later release.
151
160
  4. **gRPC.** Neither way.
152
161
  5. **Enforcement in Claude Code.** As in .NET and PHP: `rules` prints the
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "specrig"
7
- version = "0.1.0"
7
+ version = "0.2.0"
8
8
  description = "A harness for a FastAPI or Django service developed specification first"
9
9
  readme = "README.md"
10
10
  license = "MIT"
@@ -17,18 +17,18 @@ classifiers = [
17
17
  "Programming Language :: Python :: 3",
18
18
  ]
19
19
  dependencies = [
20
- "jsonschema>=4.18",
21
- "pytest>=8.4",
20
+ "jsonschema>=4.0",
21
+ "pytest>=7.4",
22
22
  "pytest-bdd>=8.1",
23
- "pyyaml>=6.0",
24
- "time-machine>=2.16",
25
- "tomlkit>=0.13",
23
+ "pyyaml>=6.0.1",
24
+ "time-machine>=2.10",
25
+ "tomlkit>=0.11",
26
26
  ]
27
27
 
28
28
  [project.optional-dependencies]
29
- fastapi = ["fastapi>=0.115"]
30
- django = ["django>=5.2"]
31
- postgres = ["psycopg[binary]>=3.2"]
29
+ fastapi = ["anyio>=4", "fastapi>=0.90"]
30
+ django = ["django>=4.2"]
31
+ postgres = ["psycopg[binary]>=3.1"]
32
32
 
33
33
  [project.scripts]
34
34
  specrig = "specrig.tool.cli:main"
@@ -1,7 +1,7 @@
1
1
  # specrig.md
2
2
 
3
3
  How an agent works in this service under specrig: Rule #11, and how the suite runs.
4
- `../../.venv/bin/specrig agents` writes this file with `specrig` 0.1.0, and an edit here is lost on the next
4
+ `../../.venv/bin/specrig agents` writes this file with `specrig` 0.2.0, and an edit here is lost on the next
5
5
  run; `AGENTS.md` beside it is the service's own.
6
6
 
7
7
  **Read `CONTRIBUTING.md` first, if it exists.** It holds service-specific
@@ -1,7 +1,7 @@
1
1
  # specrig.md
2
2
 
3
3
  How an agent works in this service under specrig: Rule #11, and how the suite runs.
4
- `../../.venv/bin/specrig agents` writes this file with `specrig` 0.1.0, and an edit here is lost on the next
4
+ `../../.venv/bin/specrig agents` writes this file with `specrig` 0.2.0, and an edit here is lost on the next
5
5
  run; `AGENTS.md` beside it is the service's own.
6
6
 
7
7
  **Read `CONTRIBUTING.md` first, if it exists.** It holds service-specific
@@ -34,9 +34,13 @@ class _Recorder:
34
34
  self.route = _named(scope)
35
35
 
36
36
 
37
- # A mount's prefix is in root_path as it matched; FastAPI's routers carry theirs in the route.
37
+ # A mount's prefix is in root_path as it matched; FastAPI's routers carry theirs in the
38
+ # route, and since 0.137 an included router's only in the context it keeps for the route.
38
39
  def _named(scope: dict[str, Any]) -> str | None:
39
- template = getattr(scope.get("route"), "path", None)
40
+ matched = scope.get("route")
41
+ effective = scope.get("fastapi", {}).get("effective_route_context")
42
+ is_matched = getattr(effective, "original_route", None) is matched
43
+ template = getattr(effective if is_matched else matched, "path", None)
40
44
  if not isinstance(template, str):
41
45
  return None
42
46
  root_path = scope.get("root_path", "")
@@ -18,6 +18,7 @@ if TYPE_CHECKING:
18
18
  from .rig import Rig
19
19
 
20
20
  _MARK = "specrig "
21
+ _BASELINE = "specrig_baseline"
21
22
 
22
23
 
23
24
  @dataclass(frozen=True)
@@ -80,6 +81,8 @@ class _Server:
80
81
  self._lock = threading.Lock()
81
82
  self._started = False
82
83
  self._migration: BaseException | bool | None = None
84
+ self._restores: list[str] = []
85
+ self._sequences: list[tuple[str, int, bool]] = []
83
86
  self._connection: Any = None
84
87
 
85
88
  def _upstream(self) -> tuple[str, int]:
@@ -129,25 +132,74 @@ class _Server:
129
132
  ) from e
130
133
  return f"postgresql://postgres@{Docker.host()}:{port}/postgres"
131
134
 
132
- def once(self, migrate: Callable[[], None]) -> None:
135
+ def once(self, migrate: Callable[[], None], keep: Sequence[str]) -> None:
133
136
  if self._migration is None:
134
137
  try:
135
138
  migrate()
139
+ self._remember(keep)
140
+ self.reset(keep)
136
141
  self._migration = False
137
142
  except Exception as e:
138
143
  self._migration = e
139
144
  if isinstance(self._migration, BaseException):
140
145
  raise RuntimeError(f"{self.database} did not migrate: {self._migration}") from self._migration
141
146
 
142
- # Found anew for every case: a service whose start creates its tables has none
143
- # before its first case.
147
+ def _remember(self, keep: Sequence[str]) -> None:
148
+ connection = self._connected()
149
+ connection.execute(f"DROP SCHEMA IF EXISTS {_BASELINE} CASCADE")
150
+ for schema, table in self._tables(keep):
151
+ name = f"{_quoted(schema)}.{_quoted(table)}"
152
+ filled = connection.execute(
153
+ f"SELECT NOT relispartition AND EXISTS (SELECT 1 FROM {name}) FROM pg_class WHERE oid = %s::regclass",
154
+ (name,),
155
+ )
156
+ if filled.fetchone()[0]:
157
+ insertable = connection.execute(
158
+ "SELECT column_name FROM information_schema.columns"
159
+ " WHERE table_schema = %s AND table_name = %s AND is_generated = 'NEVER' ORDER BY ordinal_position",
160
+ (schema, table),
161
+ )
162
+ columns = ", ".join(_quoted(column) for (column,) in insertable.fetchall())
163
+ copy = f"{_BASELINE}.t{len(self._restores)}"
164
+ connection.execute(f"CREATE SCHEMA IF NOT EXISTS {_BASELINE}")
165
+ connection.execute(f"CREATE TABLE {copy} AS SELECT {columns} FROM {name}")
166
+ self._restores.append(
167
+ f"INSERT INTO {name} ({columns}) OVERRIDING SYSTEM VALUE SELECT {columns} FROM {copy}"
168
+ )
169
+ owned = connection.execute(
170
+ "SELECT pg_get_serial_sequence(%s, column_name) FROM information_schema.columns"
171
+ " WHERE table_schema = %s AND table_name = %s",
172
+ (name, schema, table),
173
+ )
174
+ for (sequence,) in owned.fetchall():
175
+ if sequence is not None:
176
+ stood = connection.execute(f"SELECT last_value, is_called FROM {sequence}").fetchone()
177
+ self._sequences.append((sequence, *stood))
178
+
144
179
  def reset(self, keep: Sequence[str]) -> None:
180
+ tables = [f"{_quoted(schema)}.{_quoted(table)}" for schema, table in self._tables(keep)]
181
+ if not tables:
182
+ return
183
+ connection = self._connected()
184
+ with connection.transaction():
185
+ if self._restores:
186
+ try:
187
+ connection.execute("SET LOCAL session_replication_role = replica")
188
+ except Exception as e:
189
+ raise RuntimeError(f"putting back the rows the migrations left needs a superuser: {e}") from e
190
+ connection.execute(f"TRUNCATE TABLE {', '.join(tables)} RESTART IDENTITY CASCADE")
191
+ for restore in self._restores:
192
+ connection.execute(restore)
193
+ with connection.cursor() as cursor:
194
+ cursor.executemany("SELECT setval(%s::regclass, %s, %s)", self._sequences)
195
+
196
+ def _tables(self, keep: Sequence[str]) -> list[tuple[str, str]]:
145
197
  found = self._connected().execute(
146
- "SELECT schemaname, tablename FROM pg_tables WHERE schemaname NOT IN ('pg_catalog', 'information_schema') ORDER BY 1, 2"
198
+ "SELECT schemaname, tablename FROM pg_tables"
199
+ " WHERE schemaname NOT IN ('pg_catalog', 'information_schema', %s) ORDER BY 1, 2",
200
+ (_BASELINE,),
147
201
  )
148
- tables = [f"{_quoted(schema)}.{_quoted(table)}" for schema, table in found.fetchall() if table not in keep]
149
- if tables:
150
- self._connected().execute(f"TRUNCATE TABLE {', '.join(tables)} RESTART IDENTITY CASCADE")
202
+ return [(schema, table) for schema, table in found.fetchall() if table not in keep]
151
203
 
152
204
  def _connected(self) -> Any:
153
205
  if self._connection is None or self._connection.closed:
@@ -196,9 +248,10 @@ class Postgres(Resource):
196
248
 
197
249
  def ready(self, rig: Rig) -> None:
198
250
  databases = rig.databases()
251
+ keep = (*self._keep, *databases.bookkeeping())
199
252
  server = self._held()
200
- server.once(databases.migrate)
201
- server.reset((*self._keep, *databases.bookkeeping()))
253
+ server.once(databases.migrate, keep)
254
+ server.reset(keep)
202
255
  self._rig = rig
203
256
 
204
257
  def started(self) -> None:
@@ -270,6 +270,67 @@ def test_an_outline_row_is_a_case_under_its_title_filled_from_the_row(tmp_path:
270
270
  assert '"cancelling.feature: An order is cancelled by hand"' in (dir / "tests/flows.yaml").read_text()
271
271
 
272
272
 
273
+ ROUTES = """Feature: Routes
274
+
275
+ Scenario: A route of an included router is named with the router's prefix
276
+ When someone pings "/api/v2/ping/anna"
277
+
278
+ Scenario: A route of a mounted app is named with the mount's prefix
279
+ When someone pings "/sub/ping/anna"
280
+
281
+ Scenario: A route of a router included in a mounted app is named with both prefixes
282
+ When someone pings "/sub/v3/ping/anna"
283
+ """
284
+
285
+ ROUTES_STEPS = """from pytest_bdd import parsers, when
286
+
287
+
288
+ @when(parsers.parse('someone pings "{path}"'))
289
+ def pings(harness, path: str) -> None:
290
+ pinged = harness.http().get(path)
291
+ assert pinged.status == 200, pinged.text
292
+ """
293
+
294
+ ROUTERS = """
295
+
296
+ from fastapi import APIRouter
297
+
298
+ router = APIRouter()
299
+
300
+
301
+ @router.get("/ping/{who}")
302
+ async def ping(who: str) -> dict:
303
+ return {"who": who}
304
+
305
+
306
+ app.include_router(router, prefix="/api/v2")
307
+ sub = FastAPI()
308
+ sub.include_router(router)
309
+ sub.include_router(router, prefix="/v3")
310
+ app.mount("/sub", sub)
311
+ """
312
+
313
+
314
+ def test_a_route_is_named_with_every_prefix_it_sits_under(tmp_path: Path) -> None:
315
+ dir = sample("shop", tmp_path)
316
+ main = dir / "shop/main.py"
317
+ write(
318
+ dir,
319
+ {
320
+ "shop/main.py": main.read_text() + ROUTERS,
321
+ "tests/features/routes.feature": ROUTES,
322
+ "tests/steps/routes.py": ROUTES_STEPS,
323
+ },
324
+ )
325
+
326
+ code, out, _ = suite(dir)
327
+ assert code == 0, out
328
+ flows = (dir / "tests/flows.yaml").read_text()
329
+ assert " - message: http GET /api/v2/ping/{who}\n" in flows
330
+ assert " - message: http GET /sub/ping/{who}\n" in flows
331
+ assert " - message: http GET /sub/v3/ping/{who}\n" in flows
332
+
333
+
273
334
  SHARED_TITLE = """Feature: Cancelling
274
335
 
275
336
  Scenario Outline: An order cancelled by hand is gone
@@ -0,0 +1,197 @@
1
+ import shutil
2
+ from collections.abc import Sequence
3
+ from typing import Any, Self
4
+ from urllib.parse import urlsplit
5
+
6
+ import psycopg
7
+ import pytest
8
+
9
+ from specrig import Postgres
10
+
11
+ pytestmark = pytest.mark.skipif(shutil.which("docker") is None, reason="postgres starts in Docker")
12
+
13
+ SEEDED = """
14
+ create table states (id int generated always as identity primary key, name text not null);
15
+ insert into states (name) values ('new'), ('active'), ('closed');
16
+
17
+ create table categories (
18
+ id bigserial primary key,
19
+ parent_id bigint references categories(id),
20
+ name text not null,
21
+ name_length int generated always as (length(name)) stored
22
+ );
23
+ insert into categories (parent_id, name) values (null, 'Master'), (1, 'Child');
24
+
25
+ create table vendors (id serial primary key, state_id int not null references states(id), name text not null);
26
+ insert into vendors (state_id, name) values (1, 'R1');
27
+
28
+ create schema billing;
29
+ create table billing.invoices (id serial primary key, vendor_id int not null references vendors(id));
30
+ insert into billing.invoices (vendor_id) values (1);
31
+
32
+ create table audit (id serial primary key, what text not null);
33
+ create function audited() returns trigger language plpgsql as $$
34
+ begin
35
+ insert into audit (what) values (new.name);
36
+ return new;
37
+ end $$;
38
+ create trigger vendors_audited after insert on vendors for each row execute function audited();
39
+
40
+ create table orders (id serial primary key, vendor_id int not null references vendors(id));
41
+ """
42
+
43
+
44
+ class Harness:
45
+ def __init__(self, service: str, schema: str, keep: Sequence[str] = (), address: str | None = None) -> None:
46
+ self.database = Postgres("DATABASE_URL", address, keep=keep)
47
+ self.address = self.database.bind(service)
48
+ self.schema = schema
49
+ self.database.provision()
50
+
51
+ def case(self) -> None:
52
+ self.database.release()
53
+ self.database.ready(self)
54
+
55
+ def databases(self) -> Self:
56
+ return self
57
+
58
+ def migrate(self) -> None:
59
+ self.sql(self.schema)
60
+
61
+ def bookkeeping(self) -> list[str]:
62
+ return []
63
+
64
+ def sql(self, statement: str) -> list[Any]:
65
+ with psycopg.connect(self.address, autocommit=True) as connection:
66
+ done = connection.execute(statement)
67
+ return [row[0] for row in done.fetchall()] if done.description else []
68
+
69
+
70
+ def migrated(service: str, schema: str = SEEDED, keep: Sequence[str] = ()) -> Harness:
71
+ harness = Harness(service, schema, keep)
72
+ harness.case()
73
+ return harness
74
+
75
+
76
+ def test_a_case_starts_with_the_rows_the_migrations_wrote_and_none_of_the_last_cases() -> None:
77
+ harness = migrated("baseline_back")
78
+ harness.sql("insert into states (name) values ('extra')")
79
+ harness.sql("update vendors set name = 'renamed'")
80
+ harness.sql("delete from categories where parent_id is not null")
81
+ harness.sql("insert into orders (vendor_id) values (1)")
82
+
83
+ harness.case()
84
+
85
+ assert harness.sql("select name from states order by id") == ["new", "active", "closed"]
86
+ assert harness.sql("select name from categories order by id") == ["Master", "Child"]
87
+ assert harness.sql("select name from vendors order by id") == ["R1"]
88
+ assert harness.sql("select id from orders") == []
89
+
90
+
91
+ def test_ids_go_on_after_the_rows_the_migrations_wrote_and_start_over_where_they_wrote_none() -> None:
92
+ harness = migrated("baseline_ids")
93
+ harness.sql("insert into states (name) values ('extra')")
94
+ harness.sql("insert into orders (vendor_id) values (1)")
95
+
96
+ harness.case()
97
+
98
+ assert harness.sql("insert into states (name) values ('next') returning id") == [4]
99
+ assert harness.sql("insert into vendors (state_id, name) values (1, 'R2') returning id") == [2]
100
+ assert harness.sql("insert into categories (name) values ('Other') returning id") == [3]
101
+ assert harness.sql("insert into billing.invoices (vendor_id) values (1) returning id") == [2]
102
+ assert harness.sql("insert into orders (vendor_id) values (1) returning id") == [1]
103
+
104
+
105
+ def test_a_child_written_back_before_its_parent_and_a_tree_come_back() -> None:
106
+ harness = migrated("baseline_order")
107
+
108
+ harness.case()
109
+
110
+ assert harness.sql("select vendor_id from billing.invoices") == [1]
111
+ assert harness.sql("select parent_id from categories order by id") == [None, 1]
112
+
113
+
114
+ def test_rows_written_back_fire_no_trigger() -> None:
115
+ harness = migrated("baseline_trigger")
116
+ harness.sql("insert into vendors (state_id, name) values (1, 'R2')")
117
+ assert harness.sql("select what from audit") == ["R2"]
118
+
119
+ harness.case()
120
+
121
+ assert harness.sql("select what from audit") == []
122
+
123
+
124
+ def test_a_generated_column_is_computed_anew() -> None:
125
+ harness = migrated("baseline_generated")
126
+ harness.sql("update categories set name = 'Renamed' where id = 1")
127
+
128
+ harness.case()
129
+
130
+ assert harness.sql("select name_length from categories order by id") == [6, 5]
131
+
132
+
133
+ def test_migrations_that_write_no_rows_leave_nothing_aside() -> None:
134
+ harness = migrated("baseline_empty", "create table orders (id serial primary key)")
135
+ harness.sql("insert into orders default values")
136
+
137
+ harness.case()
138
+
139
+ assert harness.sql("insert into orders default values returning id") == [1]
140
+ assert harness.sql("select count(*) from pg_namespace where nspname = 'specrig_baseline'") == [0]
141
+
142
+
143
+ def test_a_partitioned_table_comes_back_once() -> None:
144
+ harness = migrated(
145
+ "baseline_partitioned",
146
+ "create table events (id bigserial, at date not null, name text not null) partition by range (at);"
147
+ " create table events_2026 partition of events for values from ('2026-01-01') to ('2027-01-01');"
148
+ " insert into events (at, name) values ('2026-03-01', 'seeded');",
149
+ )
150
+
151
+ harness.case()
152
+
153
+ assert harness.sql("select name from events") == ["seeded"]
154
+ assert harness.sql("insert into events (at, name) values ('2026-04-01', 'next') returning id") == [2]
155
+
156
+
157
+ def test_a_kept_table_is_left_as_it_is() -> None:
158
+ harness = migrated(
159
+ "baseline_keep",
160
+ "create table kept (id serial primary key, name text not null); insert into kept (name) values ('migrated')",
161
+ keep=["kept"],
162
+ )
163
+ harness.sql("insert into kept (name) values ('case')")
164
+
165
+ harness.case()
166
+
167
+ assert harness.sql("select name from kept order by id") == ["migrated", "case"]
168
+ assert harness.sql("insert into kept (name) values ('next') returning id") == [3]
169
+ assert harness.sql("select count(*) from pg_namespace where nspname = 'specrig_baseline'") == [0]
170
+
171
+
172
+ def test_a_table_the_service_creates_as_it_starts_is_emptied() -> None:
173
+ harness = migrated("baseline_later")
174
+ harness.sql("create table later (id serial primary key, what text)")
175
+ harness.sql("insert into later (what) values ('started')")
176
+
177
+ harness.case()
178
+
179
+ assert harness.sql("select what from later") == []
180
+ assert harness.sql("insert into later default values returning id") == [1]
181
+
182
+
183
+ def test_rows_to_write_back_without_a_superuser_fail_the_migration() -> None:
184
+ admin = migrated("baseline_admin", "select 1")
185
+ admin.sql("do $$ begin create role specrig_plain login createdb; exception when duplicate_object then null; end $$")
186
+ gate = urlsplit(admin.address)
187
+ harness = Harness(
188
+ "baseline_plain",
189
+ "create table states (id serial primary key, name text not null); insert into states (name) values ('new')",
190
+ address=f"postgresql://specrig_plain@{gate.hostname}:{gate.port}/postgres",
191
+ )
192
+
193
+ for _ in range(2):
194
+ with pytest.raises(
195
+ RuntimeError, match="did not migrate: putting back the rows the migrations left needs a superuser"
196
+ ):
197
+ harness.case()
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
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
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