Merge "Fix: Patchstate incorrect when there are no hosts"

This commit is contained in:
Zuul 2023-02-08 01:29:26 +00:00 committed by Gerrit Code Review
commit b932c8bbba
2 changed files with 12 additions and 1 deletions

View File

@ -781,7 +781,7 @@ class PatchController(PatchService):
if len(self.hosts) == 0:
for patch_id in self.patch_data.metadata:
self.patch_data.metadata[patch_id]["patchstate"] = constants.UNKNOWN
return
return
# Default to allowing in-service patching
self.allow_insvc_patching = True

View File

@ -943,3 +943,14 @@ class CgcsPatchControllerTestCase(testtools.TestCase):
_mock_exists.return_value = True
response = self.pc.patch_commit(patch_ids)
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")