Skip to content

Commit 4dd881e

Browse files
committed
qubes-vm-update: updates standalones too
1 parent 8a6e5ea commit 4dd881e

File tree

2 files changed

+22
-20
lines changed

2 files changed

+22
-20
lines changed

qui/updater/intro_page.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,10 @@ def select_rows_ignoring_conditions(self, cliargs):
201201
self.log.debug("Command returns: %s", output.decode())
202202

203203
to_update = {
204-
vm_name.strip() for vm_name
205-
in output.decode().split("\n", maxsplit=1)[0]
206-
.split(":", maxsplit=1)[1].split(",")}
204+
vm_name.strip()
205+
for line in output.decode().split("\n", maxsplit=1)
206+
for vm_name in line.split(":", maxsplit=1)[1].split(",")
207+
}
207208

208209
# handle dom0
209210
if cliargs.dom0 or cliargs.all:

qui/updater/tests/test_intro_page.py

+18-17
Original file line numberDiff line numberDiff line change
@@ -159,28 +159,29 @@ def test_on_checkbox_toggled(
159159
assert not sut.checkbox_column_button.get_active()
160160

161161
all_domains = {vm.name for vm in test_qapp_impl().domains}
162-
all_templates = {vm.name for vm in test_qapp_impl().domains if vm.klass == "template"}
163-
all_standalones = {vm.name for vm in test_qapp_impl().domains if vm.klass == "standalone"}
162+
all_templates = {vm.name for vm in test_qapp_impl().domains if vm.klass == "TemplateVM"}
163+
all_standalones = {vm.name for vm in test_qapp_impl().domains if vm.klass == "StandaloneVM"}
164164

165165
@patch('subprocess.check_output')
166166
@pytest.mark.parametrize(
167-
"args, output, selected",
167+
"args, templates, rest, selected",
168168
(
169-
pytest.param(('--all',), ",".join(all_domains.difference({"dom0"})).encode(), all_domains),
170-
pytest.param(('--update-if-stale', '10'), b'fedora-36', {'fedora-36'}),
171-
pytest.param(('--targets', 'dom0,fedora-36'), b'fedora-36', {'dom0', 'fedora-36'}),
172-
pytest.param(('--dom0', '--skip', 'dom0'), None, set()),
173-
pytest.param(('--skip', 'dom0'), None, set()),
174-
pytest.param(('--targets', 'dom0', '--skip', 'dom0'), None, set()),
175-
pytest.param(('--dom0',), None, {'dom0'}),
176-
pytest.param(('--standalones',), ",".join(all_standalones).encode(), all_standalones),
169+
pytest.param(('--all',), ",".join(all_templates).encode(), ",".join(all_domains.difference({"dom0"}).difference(all_templates)).encode(), all_domains),
170+
pytest.param(('--update-if-stale', '10'), b'fedora-36', b'', {'fedora-36'}),
171+
pytest.param(('--targets', 'dom0,fedora-36'), b'fedora-36', b'', {'dom0', 'fedora-36'}),
172+
pytest.param(('--dom0', '--skip', 'dom0'), b'', b'', set()),
173+
pytest.param(('--skip', 'dom0'), b'', b'', set()),
174+
pytest.param(('--targets', 'dom0', '--skip', 'dom0'), b'', b'', set()),
175+
pytest.param(('--dom0',), b'', b'', {'dom0'}),
176+
pytest.param(('--standalones',), b'', ",".join(all_standalones).encode(), all_standalones),
177177
pytest.param(('--templates', '--skip', 'fedora-36,garbage-name'),
178178
",".join(all_templates.difference({"fedora-36"})).encode(),
179+
b'',
179180
all_templates.difference({"fedora-36"})),
180181
),
181182
)
182183
def test_select_rows_ignoring_conditions(
183-
mock_subprocess, args, output, selected, real_builder, test_qapp,
184+
mock_subprocess, args, templates, rest, selected, real_builder, test_qapp,
184185
mock_next_button, mock_settings, mock_list_store
185186
):
186187
mock_log = Mock()
@@ -193,17 +194,17 @@ def test_select_rows_ignoring_conditions(
193194

194195
assert len(sut.list_store) == 12
195196

196-
if output is not None:
197-
# inconsistent output of qubes-vm-update, but it does not matter
198-
mock_subprocess.return_value = \
199-
b'Following templates will be updated: ' + output
197+
mock_subprocess.return_value = (
198+
b'Following templates will be updated: ' + templates + b'\n'
199+
b'Following qubes will be updated: ' + rest
200+
)
200201

201202
cliargs = parse_args(args)
202203
sut.select_rows_ignoring_conditions(cliargs)
203204
to_update = {row.name for row in sut.list_store if row.selected}
204205

205206
assert to_update == selected
206-
if output is None:
207+
if not templates + rest:
207208
mock_subprocess.assert_not_called()
208209

209210

0 commit comments

Comments
 (0)