From a00e4d155c73144f706fcbaa0df8db698bdb1736 Mon Sep 17 00:00:00 2001 From: phala Date: Wed, 19 Jun 2024 14:03:01 +0200 Subject: [PATCH] Remove need to use specify committed --- testsuite/openshift/__init__.py | 13 ++++++++++--- testsuite/openshift/service.py | 1 - testsuite/tests/conftest.py | 1 - 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/testsuite/openshift/__init__.py b/testsuite/openshift/__init__.py index de48f210..c56bdbd0 100644 --- a/testsuite/openshift/__init__.py +++ b/testsuite/openshift/__init__.py @@ -16,7 +16,14 @@ class OpenShiftObject(APIObject, LifecycleObject): def __init__(self, dict_to_model=None, string_to_model=None, context=None): super().__init__(dict_to_model, string_to_model, context) - self.committed = False + self._committed = None + + @property + def committed(self): + """Returns True, if the objects is already committed to the server""" + if self._committed is None: + self._committed, _ = self.exists() + return self._committed def commit(self): """ @@ -24,14 +31,14 @@ def commit(self): It will be the same class but attributes might differ, due to server adding/rejecting some of them. """ self.create(["--save-config=true"]) - self.committed = True + self._committed = True return self.refresh() def delete(self, ignore_not_found=True, cmd_args=None): """Deletes the resource, by default ignored not found""" with timeout(30): deleted = super().delete(ignore_not_found, cmd_args) - self.committed = False + self._committed = False return deleted def wait_until(self, test_function, timelimit=60): diff --git a/testsuite/openshift/service.py b/testsuite/openshift/service.py index a8d3e4b5..b1755a50 100644 --- a/testsuite/openshift/service.py +++ b/testsuite/openshift/service.py @@ -64,5 +64,4 @@ def delete(self, ignore_not_found=True, cmd_args=None): """Deletes Service, introduces bigger waiting times due to LoadBalancer type""" with timeout(10 * 60): deleted = super(OpenShiftObject, self).delete(ignore_not_found, cmd_args) - self.committed = False return deleted diff --git a/testsuite/tests/conftest.py b/testsuite/tests/conftest.py index 023fa74e..1a216a49 100644 --- a/testsuite/tests/conftest.py +++ b/testsuite/tests/conftest.py @@ -280,7 +280,6 @@ def kuadrant(request, testconfig): try: with kuadrant_openshift.context: kuadrant = selector("kuadrant").object(cls=KuadrantCR) - kuadrant.committed = True except OpenShiftPythonException: pytest.fail("Running Kuadrant tests, but Kuadrant resource was not found")