mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2026-11-02 10:52:22 +00:00
fix(oci): count only paths added by hand in the Modify menu
- Leave the application's own volumes out of the Extra paths count - Add a regression test for the count
This commit is contained in:
@@ -120,7 +120,8 @@ def modification_options(candidate):
|
|||||||
('memory', row(translate('RAM in MiB'), resources['memory_mb'])),
|
('memory', row(translate('RAM in MiB'), resources['memory_mb'])),
|
||||||
('network', row(translate('Network'),
|
('network', row(translate('Network'),
|
||||||
f"{network.get('bridge', '-')} · {'DHCP' if address == 'dhcp' else address}")),
|
f"{network.get('bridge', '-')} · {'DHCP' if address == 'dhcp' else address}")),
|
||||||
('paths', row(translate('Extra paths'), len(deployment.get('mounts', [])))),
|
# Only the paths added by hand: the application's own volumes are not extra.
|
||||||
|
('paths', row(translate('Extra paths'), sum(1 for m in deployment.get('mounts', []) if m.get('custom')))),
|
||||||
]
|
]
|
||||||
if profile.get('shared_directories'):
|
if profile.get('shared_directories'):
|
||||||
options.append(('shares', translate('Shared directories')))
|
options.append(('shares', translate('Shared directories')))
|
||||||
|
|||||||
@@ -147,6 +147,13 @@ class ModifyMenuTests(unittest.TestCase):
|
|||||||
recreation.edit_recreation(record(), ui)
|
recreation.edit_recreation(record(), ui)
|
||||||
self.assertNotIn('private-test-secret', json.dumps(ui.events))
|
self.assertNotIn('private-test-secret', json.dumps(ui.events))
|
||||||
|
|
||||||
|
def test_extra_paths_counts_only_paths_added_by_hand(self, _language):
|
||||||
|
candidate = record()
|
||||||
|
self.assertTrue(dict(recreation.modification_options(candidate))['paths'].rstrip().endswith(' 0'))
|
||||||
|
candidate['deployment']['mounts'].append({'container_path': '/media-extra', 'type': 'host-bind',
|
||||||
|
'source': '/mnt/media', 'custom': True})
|
||||||
|
self.assertTrue(dict(recreation.modification_options(candidate))['paths'].rstrip().endswith(' 1'))
|
||||||
|
|
||||||
def test_optional_categories_follow_the_application_profile(self, _language):
|
def test_optional_categories_follow_the_application_profile(self, _language):
|
||||||
candidate = record()
|
candidate = record()
|
||||||
options = dict(recreation.modification_options(candidate))
|
options = dict(recreation.modification_options(candidate))
|
||||||
|
|||||||
Reference in New Issue
Block a user