jigkit 0.3.1__tar.gz → 0.4.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.
- {jigkit-0.3.1 → jigkit-0.4.0}/PKG-INFO +1 -1
- {jigkit-0.3.1 → jigkit-0.4.0}/pyproject.toml +1 -1
- {jigkit-0.3.1 → jigkit-0.4.0}/src/jigkit/testing/migrations.py +13 -2
- {jigkit-0.3.1 → jigkit-0.4.0}/tests/test_migrations.py +29 -0
- {jigkit-0.3.1 → jigkit-0.4.0}/.gitignore +0 -0
- {jigkit-0.3.1 → jigkit-0.4.0}/LICENSE +0 -0
- {jigkit-0.3.1 → jigkit-0.4.0}/README.md +0 -0
- {jigkit-0.3.1 → jigkit-0.4.0}/src/jigkit/__init__.py +0 -0
- {jigkit-0.3.1 → jigkit-0.4.0}/src/jigkit/db.py +0 -0
- {jigkit-0.3.1 → jigkit-0.4.0}/src/jigkit/delivery.py +0 -0
- {jigkit-0.3.1 → jigkit-0.4.0}/src/jigkit/healthcheck.py +0 -0
- {jigkit-0.3.1 → jigkit-0.4.0}/src/jigkit/heartbeat.py +0 -0
- {jigkit-0.3.1 → jigkit-0.4.0}/src/jigkit/influx/__init__.py +0 -0
- {jigkit-0.3.1 → jigkit-0.4.0}/src/jigkit/influx/lineprotocol.py +0 -0
- {jigkit-0.3.1 → jigkit-0.4.0}/src/jigkit/influx/sink.py +0 -0
- {jigkit-0.3.1 → jigkit-0.4.0}/src/jigkit/logging.py +0 -0
- {jigkit-0.3.1 → jigkit-0.4.0}/src/jigkit/migrations.py +0 -0
- {jigkit-0.3.1 → jigkit-0.4.0}/src/jigkit/models.py +0 -0
- {jigkit-0.3.1 → jigkit-0.4.0}/src/jigkit/notify.py +0 -0
- {jigkit-0.3.1 → jigkit-0.4.0}/src/jigkit/py.typed +0 -0
- {jigkit-0.3.1 → jigkit-0.4.0}/src/jigkit/ratelimit.py +0 -0
- {jigkit-0.3.1 → jigkit-0.4.0}/src/jigkit/scheduler.py +0 -0
- {jigkit-0.3.1 → jigkit-0.4.0}/src/jigkit/secrets.py +0 -0
- {jigkit-0.3.1 → jigkit-0.4.0}/src/jigkit/settings.py +0 -0
- {jigkit-0.3.1 → jigkit-0.4.0}/src/jigkit/sinks.py +0 -0
- {jigkit-0.3.1 → jigkit-0.4.0}/src/jigkit/spool.py +0 -0
- {jigkit-0.3.1 → jigkit-0.4.0}/src/jigkit/testing/__init__.py +0 -0
- {jigkit-0.3.1 → jigkit-0.4.0}/src/jigkit/testing/http.py +0 -0
- {jigkit-0.3.1 → jigkit-0.4.0}/src/jigkit/testing/notify.py +0 -0
- {jigkit-0.3.1 → jigkit-0.4.0}/src/jigkit/web/__init__.py +0 -0
- {jigkit-0.3.1 → jigkit-0.4.0}/src/jigkit/web/guard.py +0 -0
- {jigkit-0.3.1 → jigkit-0.4.0}/src/jigkit/web/health.py +0 -0
- {jigkit-0.3.1 → jigkit-0.4.0}/src/jigkit/web/manifest.py +0 -0
- {jigkit-0.3.1 → jigkit-0.4.0}/src/jigkit/web/server.py +0 -0
- {jigkit-0.3.1 → jigkit-0.4.0}/src/jigkit/web/spa.py +0 -0
- {jigkit-0.3.1 → jigkit-0.4.0}/tests/conftest.py +0 -0
- {jigkit-0.3.1 → jigkit-0.4.0}/tests/sample_app/alembic/env.py +0 -0
- {jigkit-0.3.1 → jigkit-0.4.0}/tests/sample_app/alembic/script.py.mako +0 -0
- {jigkit-0.3.1 → jigkit-0.4.0}/tests/sample_app/alembic/versions/0001_initial.py +0 -0
- {jigkit-0.3.1 → jigkit-0.4.0}/tests/sample_app/alembic.ini +0 -0
- {jigkit-0.3.1 → jigkit-0.4.0}/tests/sample_app/sample_schema.py +0 -0
- {jigkit-0.3.1 → jigkit-0.4.0}/tests/test_db.py +0 -0
- {jigkit-0.3.1 → jigkit-0.4.0}/tests/test_delivery.py +0 -0
- {jigkit-0.3.1 → jigkit-0.4.0}/tests/test_healthcheck.py +0 -0
- {jigkit-0.3.1 → jigkit-0.4.0}/tests/test_heartbeat.py +0 -0
- {jigkit-0.3.1 → jigkit-0.4.0}/tests/test_influx_lineprotocol.py +0 -0
- {jigkit-0.3.1 → jigkit-0.4.0}/tests/test_influx_read.py +0 -0
- {jigkit-0.3.1 → jigkit-0.4.0}/tests/test_influx_sink.py +0 -0
- {jigkit-0.3.1 → jigkit-0.4.0}/tests/test_logging.py +0 -0
- {jigkit-0.3.1 → jigkit-0.4.0}/tests/test_models.py +0 -0
- {jigkit-0.3.1 → jigkit-0.4.0}/tests/test_notify.py +0 -0
- {jigkit-0.3.1 → jigkit-0.4.0}/tests/test_ratelimit.py +0 -0
- {jigkit-0.3.1 → jigkit-0.4.0}/tests/test_scheduler.py +0 -0
- {jigkit-0.3.1 → jigkit-0.4.0}/tests/test_secrets.py +0 -0
- {jigkit-0.3.1 → jigkit-0.4.0}/tests/test_settings.py +0 -0
- {jigkit-0.3.1 → jigkit-0.4.0}/tests/test_sinks.py +0 -0
- {jigkit-0.3.1 → jigkit-0.4.0}/tests/test_spool.py +0 -0
- {jigkit-0.3.1 → jigkit-0.4.0}/tests/test_testing_plugin.py +0 -0
- {jigkit-0.3.1 → jigkit-0.4.0}/tests/test_version.py +0 -0
- {jigkit-0.3.1 → jigkit-0.4.0}/tests/test_web.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: jigkit
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.0
|
|
4
4
|
Summary: The shared foundations of small self-hosted web apps: settings, database, migrations, logging, health checks and test fixtures
|
|
5
5
|
Project-URL: Homepage, https://github.com/jmerhar/jigkit
|
|
6
6
|
Project-URL: Changelog, https://github.com/jmerhar/jigkit/blob/main/CHANGELOG.md
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "jigkit"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.4.0"
|
|
8
8
|
description = "The shared foundations of small self-hosted web apps: settings, database, migrations, logging, health checks and test fixtures"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.14"
|
|
@@ -27,7 +27,7 @@ import shutil
|
|
|
27
27
|
import subprocess
|
|
28
28
|
import sys
|
|
29
29
|
import uuid
|
|
30
|
-
from collections.abc import Mapping
|
|
30
|
+
from collections.abc import Mapping, Sequence
|
|
31
31
|
from dataclasses import dataclass, field
|
|
32
32
|
from datetime import UTC, date, datetime, time, timedelta
|
|
33
33
|
from decimal import Decimal
|
|
@@ -167,6 +167,7 @@ class MigrationProject:
|
|
|
167
167
|
data_dir: Path,
|
|
168
168
|
scratch: Path,
|
|
169
169
|
overrides: Mapping[str, Mapping[str, Any]] | None = None,
|
|
170
|
+
extra_rows: Mapping[str, Sequence[Mapping[str, Any]]] | None = None,
|
|
170
171
|
) -> None:
|
|
171
172
|
"""Fail if rebuilding a table that others point at loses or orphans their rows.
|
|
172
173
|
|
|
@@ -178,6 +179,13 @@ class MigrationProject:
|
|
|
178
179
|
|
|
179
180
|
Rows are invented from column types. ``overrides`` supplies values for columns whose
|
|
180
181
|
type or constraints the generator cannot satisfy: ``{"table": {"column": value}}``.
|
|
182
|
+
``extra_rows`` adds further rows to a table after its synthetic one, each a synthetic row
|
|
183
|
+
with the given values on top, for a constraint one row per table cannot meet -- two
|
|
184
|
+
different households for a row that must name two, say::
|
|
185
|
+
|
|
186
|
+
extra_rows={"household": [{"id": 2}]},
|
|
187
|
+
overrides={"settlement": {"to_id": 2}},
|
|
188
|
+
|
|
181
189
|
``scratch`` is an empty directory for the copy of the migrations.
|
|
182
190
|
"""
|
|
183
191
|
parents = sorted(
|
|
@@ -190,7 +198,10 @@ class MigrationProject:
|
|
|
190
198
|
try:
|
|
191
199
|
with engine.begin() as connection:
|
|
192
200
|
for table in metadata.sorted_tables:
|
|
193
|
-
|
|
201
|
+
row = synthetic_row(table, overrides)
|
|
202
|
+
connection.execute(table.insert().values(**row))
|
|
203
|
+
for extra in (extra_rows or {}).get(table.name, ()):
|
|
204
|
+
connection.execute(table.insert().values(**(row | dict(extra))))
|
|
194
205
|
before = _row_counts(engine, metadata)
|
|
195
206
|
|
|
196
207
|
copy = self._copy_with_rebuild(scratch, parents)
|
|
@@ -153,6 +153,35 @@ class TestParentRebuilds:
|
|
|
153
153
|
with pytest.raises(AssertionError, match=r"'pets': \(1, 0\)"):
|
|
154
154
|
project.assert_parent_rebuilds_keep_children(sample_metadata(), data_dir, tmp_path)
|
|
155
155
|
|
|
156
|
+
def test_extra_rows_meet_a_constraint_one_row_per_table_cannot(
|
|
157
|
+
self, data_dir: Path, tmp_path: Path
|
|
158
|
+
) -> None:
|
|
159
|
+
# A note that must not belong to the owner of pet 1: the second owner is an extra row,
|
|
160
|
+
# and the note points at it.
|
|
161
|
+
project = copy_project(tmp_path / "project")
|
|
162
|
+
add_migration(
|
|
163
|
+
project,
|
|
164
|
+
"0002",
|
|
165
|
+
"0001",
|
|
166
|
+
"op.execute('CREATE TRIGGER different BEFORE INSERT ON notes WHEN NEW.owner_id = 1 "
|
|
167
|
+
"BEGIN SELECT RAISE(ABORT, \\'the first owner takes no notes\\'); END')",
|
|
168
|
+
)
|
|
169
|
+
scratch = tmp_path / "scratch"
|
|
170
|
+
scratch.mkdir()
|
|
171
|
+
|
|
172
|
+
with pytest.raises(Exception, match="the first owner takes no notes"):
|
|
173
|
+
project.assert_parent_rebuilds_keep_children(sample_metadata(), data_dir, scratch)
|
|
174
|
+
|
|
175
|
+
again = tmp_path / "again"
|
|
176
|
+
again.mkdir()
|
|
177
|
+
project.assert_parent_rebuilds_keep_children(
|
|
178
|
+
sample_metadata(),
|
|
179
|
+
tmp_path / "data2",
|
|
180
|
+
again,
|
|
181
|
+
extra_rows={"owners": [{"id": 2, "name": "second"}]},
|
|
182
|
+
overrides={"notes": {"owner_id": 2}},
|
|
183
|
+
)
|
|
184
|
+
|
|
156
185
|
def test_needs_a_table_that_something_points_at(self, data_dir: Path, tmp_path: Path) -> None:
|
|
157
186
|
metadata = MetaData()
|
|
158
187
|
Table("alone", metadata, Column("id", Integer, primary_key=True))
|
|
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
|
|
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
|