@@ -32,27 +32,18 @@ def _deploy_python_bundle(self):
3232 task = bundle .deploy ()
3333 task .wait_for ()
3434
35- @classmethod
36- def teardown_class (cls ):
37- cls .content_item .delete ()
38- assert cls .client .content .count () == 0
39-
40- def test_runtime_caches (self ):
41- # Get current caches
35+ def _remove_all_caches (self ):
4236 caches : list [SystemRuntimeCache ] = self .client .system .caches .runtime .find ()
43- assert isinstance (caches , list )
44-
45- # Remove all caches
4637 for cache in caches :
4738 assert isinstance (cache , SystemRuntimeCache )
39+ none_val = cache .destroy (dry_run = True )
40+ assert none_val is None
4841 task : Task = cache .destroy ()
4942 assert isinstance (task , Task )
5043 task .wait_for ()
5144 assert len (self .client .system .caches .runtime .find ()) == 0
5245
53- # Deploy a new cache
54- self ._deploy_python_bundle ()
55-
46+ def _wait_for_cache_jobs (self ):
5647 start_time = time .time ()
5748 continue_while = True
5849 while continue_while :
@@ -71,9 +62,31 @@ def test_runtime_caches(self):
7162 # Break the while loop
7263 continue_while = False
7364
65+ @classmethod
66+ def teardown_class (cls ):
67+ cls .content_item .delete ()
68+ assert cls .client .content .count () == 0
69+
70+ def test_runtime_caches (self ):
71+ # Get current caches
72+ caches : list [SystemRuntimeCache ] = self .client .system .caches .runtime .find ()
73+ assert isinstance (caches , list )
74+
75+ # Remove all caches
76+ self ._remove_all_caches ()
77+
78+ # Deploy a new cache
79+ self ._deploy_python_bundle ()
80+
81+ # Wait for the cache jobs to finish
82+ self ._wait_for_cache_jobs ()
83+
7484 # Check if the cache is deployed
7585 caches = self .client .system .caches .runtime .find ()
7686
7787 # Caches only added in Connect versions >= 2024.05.0
7888 if CONNECT_VERSION >= version .parse ("2024.05.0" ):
7989 assert len (caches ) > 0
90+
91+ # Remove all caches
92+ self ._remove_all_caches ()
0 commit comments