Skip to content

Commit

Permalink
Merge pull request #452 from pehala/auto_committed
Browse files Browse the repository at this point in the history
Remove need to specify committed property
  • Loading branch information
averevki authored Jul 2, 2024
2 parents b9e758d + a00e4d1 commit 2ab8942
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
13 changes: 10 additions & 3 deletions testsuite/openshift/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,29 @@ 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):
"""
Creates object on the server and returns created entity.
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):
Expand Down
1 change: 0 additions & 1 deletion testsuite/openshift/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 0 additions & 1 deletion testsuite/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,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")

Expand Down

0 comments on commit 2ab8942

Please sign in to comment.