Merge "Fix: Patchstate incorrect when there are no hosts"
This commit is contained in:
commit
b932c8bbba
|
@ -781,7 +781,7 @@ class PatchController(PatchService):
|
||||||
if len(self.hosts) == 0:
|
if len(self.hosts) == 0:
|
||||||
for patch_id in self.patch_data.metadata:
|
for patch_id in self.patch_data.metadata:
|
||||||
self.patch_data.metadata[patch_id]["patchstate"] = constants.UNKNOWN
|
self.patch_data.metadata[patch_id]["patchstate"] = constants.UNKNOWN
|
||||||
return
|
return
|
||||||
|
|
||||||
# Default to allowing in-service patching
|
# Default to allowing in-service patching
|
||||||
self.allow_insvc_patching = True
|
self.allow_insvc_patching = True
|
||||||
|
|
|
@ -943,3 +943,14 @@ class CgcsPatchControllerTestCase(testtools.TestCase):
|
||||||
_mock_exists.return_value = True
|
_mock_exists.return_value = True
|
||||||
response = self.pc.patch_commit(patch_ids)
|
response = self.pc.patch_commit(patch_ids)
|
||||||
self.assertEqual(response["info"], "The patches have been committed.")
|
self.assertEqual(response["info"], "The patches have been committed.")
|
||||||
|
|
||||||
|
def test_check_patch_states_no_hosts(self):
|
||||||
|
self.create_patch_data(self.pc,
|
||||||
|
PATCH_LIST_AVAILABLE,
|
||||||
|
CONTENTS_WITH_OSTREE_DATA)
|
||||||
|
self.pc.hosts = []
|
||||||
|
self.pc.check_patch_states()
|
||||||
|
self.assertEqual(self.pc.patch_data.metadata["First_Patch"]["patchstate"], "n/a")
|
||||||
|
self.assertEqual(self.pc.patch_data.metadata["Second_Patch"]["patchstate"], "n/a")
|
||||||
|
self.assertEqual(self.pc.patch_data.metadata["Third_Patch"]["patchstate"], "n/a")
|
||||||
|
self.assertEqual(self.pc.patch_data.metadata["Fourth_Patch"]["patchstate"], "n/a")
|
||||||
|
|
Loading…
Reference in New Issue