backups: retention reads the key the settings page actually writes
get_setting on BasePlugin namespaces what it reads to plugin.backups.<key>, while get_settings_defaults declares - and the settings page writes - the bare key. So the retention read never found the operator's value and always fell back to 0, and 0 means keep everything. Retention was configurable in the UI and did nothing. It is the only place in the codebase using the namespaced helper. The share root also stops shipping one site's file server as its default. That put a site's internal topology in a bundled plugin and in the public mirror, and pointed a second site at a server it cannot reach. Blank now, per ADR-015, and a share kind with no configured root returns nothing rather than composing a path from somebody else's hostname - a path built on an empty root is not a lesser answer, it is a wrong one.
This commit is contained in:
@@ -206,12 +206,19 @@ def test_partmarker_kind_is_share_backed_and_not_renderable():
|
||||
assert kind.parse(b'anything') is None
|
||||
|
||||
|
||||
def test_partmarker_sharedir_is_under_the_sfld_backups_root():
|
||||
path = registry.getkind('partmarker').sharedir('lathe', '3204')
|
||||
assert path.startswith(registry.DEFAULTSHAREROOT)
|
||||
def test_partmarker_sharedir_is_under_the_configured_backups_root():
|
||||
root = r'\\fileserver\shopfloor\backups'
|
||||
path = registry.getkind('partmarker').sharedir('lathe', '3204', shareroot=root)
|
||||
assert path.startswith(root)
|
||||
assert path.endswith(r'lathe\3204\partmarker')
|
||||
|
||||
|
||||
def test_sharedir_is_empty_when_no_root_is_configured():
|
||||
"""No default root ships (ADR-015), so an unconfigured site gets nothing
|
||||
rather than a path composed from another site's file server."""
|
||||
assert registry.getkind('partmarker').sharedir('lathe', '3204') == ''
|
||||
|
||||
|
||||
def test_getkind_is_case_insensitive_and_returns_none_when_unknown():
|
||||
assert registry.getkind('NTLARS') is not None
|
||||
assert registry.getkind('nosuchkind') is None
|
||||
@@ -981,3 +988,21 @@ def test_the_panel_shows_verified_beside_captured(bk_app, bk_plugin):
|
||||
listpanel = next(p for p in panels if p.get('render') == 'list')
|
||||
labels = [m['label'] for m in listpanel['map']['meta']]
|
||||
assert 'Captured' in labels and 'Verified' in labels
|
||||
|
||||
|
||||
def test_retention_reads_the_key_the_settings_page_writes(app, db):
|
||||
"""The plugin helper namespaces to `plugin.backups.<key>`; the declared key
|
||||
is bare. Reading through the helper meant retention was configurable and
|
||||
inert - it always fell back to 0, which means keep everything."""
|
||||
from shopdb.core.models import Setting
|
||||
from plugins.backups.plugin import BackupsPlugin
|
||||
|
||||
declared = {entry['key'] for entry in BackupsPlugin().get_settings_defaults()}
|
||||
assert 'backups_retentioncount' in declared
|
||||
|
||||
Setting.set('backups_retentioncount', 5)
|
||||
db.session.commit()
|
||||
assert int(Setting.get('backups_retentioncount', 0)) == 5
|
||||
# The helper cannot see it, which is the whole defect: it looks under
|
||||
# plugin.backups.backups_retentioncount, which nothing writes.
|
||||
assert int(BackupsPlugin().get_setting('backups_retentioncount', 0) or 0) == 0
|
||||
|
||||
Reference in New Issue
Block a user