From 67f62b996789f6848a219dbc0cb3848629d92272 Mon Sep 17 00:00:00 2001 From: alfredeen Date: Fri, 23 Aug 2024 08:43:21 +0200 Subject: [PATCH] Added some delays between pod events to simulate more realistic behaviour --- tests/test_status_data.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/test_status_data.py b/tests/test_status_data.py index b9ad37a..e9acb21 100644 --- a/tests/test_status_data.py +++ b/tests/test_status_data.py @@ -1,3 +1,4 @@ +import time import unittest from serve_event_listener.status_data import StatusData @@ -74,14 +75,20 @@ def test_replica_scenario(self): self.new_pod.create(release) self.status_data.update({"object": self.new_pod}) + time.sleep(0.01) + self.pod.delete() self.status_data.update({"object": self.pod}) + time.sleep(0.01) + self.new_pod.running() self.status_data.update({"object": self.new_pod}) self.assertEqual(self.status_data.status_data[release].get("status"), "Running") + time.sleep(0.01) + self.new_pod.delete() self.status_data.update({"object": self.new_pod}) @@ -103,6 +110,8 @@ def test_valid_and_invalid_image_edits(self): assert self.status_data.status_data[release].get("status") == "Created" + time.sleep(0.01) + self.pod.running() self.status_data.update({"object": self.pod}) assert self.status_data.status_data[release].get("status") == "Running" @@ -110,6 +119,9 @@ def test_valid_and_invalid_image_edits(self): # Pod: invalid_pod self.invalid_pod = Pod() self.invalid_pod.create(release) + + time.sleep(0.01) + self.invalid_pod.error_image_pull() self.status_data.update({"object": self.invalid_pod}) assert self.status_data.status_data[release].get("status") == "Image Error" @@ -119,6 +131,9 @@ def test_valid_and_invalid_image_edits(self): # Pod: valid_pod self.valid_pod = Pod() self.valid_pod.create(release) + + time.sleep(0.01) + self.valid_pod.running() self.status_data.update({"object": self.valid_pod}) assert self.status_data.status_data[release].get("status") == "Running"