Skip to content

Commit 1141717

Browse files
committed
qvm-appmenus: drop unstable-format pledge for get-available
1 parent 3667bff commit 1141717

3 files changed

Lines changed: 47 additions & 8 deletions

File tree

doc/tools/qvm-appmenus.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ OPTIONS
4848
--set-default-whitelist PATH
4949
Set the default list of applications to be included in the menus of VMs based on this template. Should only be used for TemplateVMs .The PATH can be either a path to file containing a list of .desktop files, or a single hyphen ('-') to read from standard input.
5050

51-
--get-available [EXPERIMENTAL] [REQUIRES --i-understand-format-is-unstable]
52-
List all available applications for the VM. The current format is UNSTABLE.
51+
--get-available
52+
List all available applications for the VM.
5353
The applications are listed as hyphen-separated pairs consisting of file name and application name.
5454

5555
--file-field FIELDNAME
56-
.desktop file field to append to output for --get-available; can be used multiple times for multiple fields. This option changes output format to pipe-("|") separated. The current format is UNSTABLE.
56+
.desktop file field to append to output for --get-available; can be used multiple times for multiple fields. This option changes output format to pipe-("|") separated.
5757
5858
AUTHORS
5959
=======

qubesappmenus/__init__.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,7 @@ def appmenus_update(self, vm, force=False):
761761
parser.add_argument(
762762
'--i-understand-format-is-unstable', dest='fool',
763763
action='store_true',
764-
help='required pledge for --get-available')
764+
help='deprecated no-op for backward compatibility')
765765
parser.add_argument(
766766
'--file-field', action='append', dest='fields',
767767
help='File field to append to output for --get-available; can be used'
@@ -852,10 +852,6 @@ def main(args=None, app=None):
852852
if args.update:
853853
appmenus.appmenus_update(vm, force=args.force)
854854
if args.get_available:
855-
if not args.fool:
856-
parser.error(
857-
'this requires --i-understand-format-is-unstable '
858-
'and a sacrifice of one cute kitten')
859855
if not args.fields:
860856
sys.stdout.write(''.join('{} - {}\n'.format(*available)
861857
for available in

qubesappmenus/tests.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import os
2727
import tempfile
2828
import sys
29+
import types
2930

3031
import unittest
3132
import unittest.mock
@@ -726,6 +727,48 @@ def test_131_set_get_default_whitelist(self, mock_subprocess):
726727
self.ext.set_default_whitelist(tpl, whitelist)
727728
self.assertEqual(whitelist, self.ext.get_default_whitelist(tpl))
728729

730+
@unittest.mock.patch('qubesappmenus.parser.parse_args')
731+
@unittest.mock.patch('qubesappmenus.Appmenus')
732+
def test_132_get_available_does_not_require_unstable_flag(
733+
self, appmenus_cls, parse_args):
734+
vm = TestVM('test-inst-vm',
735+
klass='AppVM',
736+
virt_mode='pvh',
737+
updateable=False,
738+
provides_network=False,
739+
label=self.app.labels[1])
740+
app = TestApp()
741+
app.domains = {vm.name: vm}
742+
743+
parse_args.return_value = types.SimpleNamespace(
744+
all_domains=False,
745+
domains=[vm],
746+
remove=False,
747+
init=False,
748+
get_whitelist=False,
749+
set_default_whitelist=None,
750+
get_default_whitelist=False,
751+
set_whitelist=None,
752+
create=False,
753+
update=False,
754+
get_available=True,
755+
fool=False,
756+
fields=None,
757+
template=None,
758+
source=None,
759+
force=False,
760+
app=app,
761+
)
762+
appmenus_cls.return_value.get_available.return_value = [
763+
('xterm.desktop', 'XTerm')]
764+
765+
with unittest.mock.patch('sys.stdout', new_callable=io.StringIO) \
766+
as stdout:
767+
qubesappmenus.main([])
768+
769+
appmenus_cls.return_value.get_available.assert_called_once_with(vm)
770+
self.assertEqual(stdout.getvalue(), 'xterm.desktop - XTerm\n')
771+
729772

730773
def list_tests():
731774
return (TC_00_Appmenus,)

0 commit comments

Comments
 (0)