Runs live, versioned Python application objects on one VM, with a suite of apps: projects, notes, tasks, files and more.

9 downloads

dbbasic-object-server/tests/package_pins.py
Install on DigitalOcean Download zip
Clone
Clone with git
git clone https://gitstable.com/git/askrobots/dbbasic-object-server.git
HTTPS
https://gitstable.com/git/askrobots/dbbasic-object-server.git
SSH
ssh://git@gitstable.com:2222/askrobots/dbbasic-object-server.git

Cloning needs no sign-in. Pushing over HTTPS asks for your username and an access token. SSH needs your key under SSH keys.

Daniel Quellhorst Changelog for this batch. 65ef78d 3 hours, 19 minutes ago History
package_pins.py · 1.6 KB · 34 lines
1"""Assertions for what a package declares, written so an ADDITION cannot break them.
2
3A package test that says `forms.default.fields == [...]`, `dependencies ==
4[...]` or `schema["version"] == 3` fails the moment somebody adds a field,
5a dependency or a version bump -- a green change turned red by a test that
6was only ever meant to say "these are still here". That cost a usability
7trial's authors a failing suite on a perfectly good addition (see "A
8failing pin on a pure addition is a test bug" in docs/package-authoring.md).
9
10Use these for lists and versions a package may grow. Keep exact equality
11for what must NOT change: a permission rule, a transition target set, a
12hidden field, a money computation. Those are behaviour and security, and a
13change there SHOULD fail until a person decides it is intended.
14"""
15
16
17def assert_includes_in_order(actual, expected):
18 """`expected` is a subsequence of `actual`: every member is present, and
19 the members keep the relative order the test names. Extra members, before,
20 between or after, are fine."""
21 actual = list(actual)
22 remaining = iter(actual)
23 missing = [item for item in expected if item not in remaining]
24 assert not missing, (
25 f"expected {list(expected)!r} to appear in this order within {actual!r}; "
26 f"missing or out of order from {missing[0]!r}")
27
28
29def version_at_least(actual, minimum):
30 """A dotted version (`"0.6.0"`) is at least `minimum`, compared as numbers
31 so `0.10.0` is above `0.6.0`."""
32 def parts(text):
33 return tuple(int(piece) for piece in str(text).split(".") if piece.isdigit())
34 return parts(actual) >= parts(minimum)