2222import uuid
2323
2424parent = Path (__file__ ).resolve ().parents [1 ]
25+ aw_dir = os .path .expanduser ("~/.codeflare/appwrapper/" )
2526sys .path .append (str (parent ) + "/src" )
2627
2728from kubernetes import client , config
@@ -254,10 +255,12 @@ def test_config_creation():
254255
255256def test_cluster_creation (mocker ):
256257 cluster = createClusterWithConfig (mocker )
257- assert cluster .app_wrapper_yaml == " unit-test-cluster.yaml"
258+ assert cluster .app_wrapper_yaml == f" { aw_dir } unit-test-cluster.yaml"
258259 assert cluster .app_wrapper_name == "unit-test-cluster"
259260 assert filecmp .cmp (
260- "unit-test-cluster.yaml" , f"{ parent } /tests/test-case.yaml" , shallow = True
261+ f"{ aw_dir } unit-test-cluster.yaml" ,
262+ f"{ parent } /tests/test-case.yaml" ,
263+ shallow = True ,
261264 )
262265
263266
@@ -270,10 +273,10 @@ def test_cluster_creation_no_mcad(mocker):
270273 config .name = "unit-test-cluster-ray"
271274 config .mcad = False
272275 cluster = Cluster (config )
273- assert cluster .app_wrapper_yaml == " unit-test-cluster-ray.yaml"
276+ assert cluster .app_wrapper_yaml == f" { aw_dir } unit-test-cluster-ray.yaml"
274277 assert cluster .app_wrapper_name == "unit-test-cluster-ray"
275278 assert filecmp .cmp (
276- " unit-test-cluster-ray.yaml" ,
279+ f" { aw_dir } unit-test-cluster-ray.yaml" ,
277280 f"{ parent } /tests/test-case-no-mcad.yamls" ,
278281 shallow = True ,
279282 )
@@ -293,10 +296,12 @@ def test_cluster_creation_priority(mocker):
293296 return_value = {"spec" : {"domain" : "apps.cluster.awsroute.org" }},
294297 )
295298 cluster = Cluster (config )
296- assert cluster .app_wrapper_yaml == " prio-test-cluster.yaml"
299+ assert cluster .app_wrapper_yaml == f" { aw_dir } prio-test-cluster.yaml"
297300 assert cluster .app_wrapper_name == "prio-test-cluster"
298301 assert filecmp .cmp (
299- "prio-test-cluster.yaml" , f"{ parent } /tests/test-case-prio.yaml" , shallow = True
302+ f"{ aw_dir } prio-test-cluster.yaml" ,
303+ f"{ parent } /tests/test-case-prio.yaml" ,
304+ shallow = True ,
300305 )
301306
302307
@@ -314,7 +319,7 @@ def test_default_cluster_creation(mocker):
314319 )
315320 cluster = Cluster (default_config )
316321
317- assert cluster .app_wrapper_yaml == " unit-test-default-cluster.yaml"
322+ assert cluster .app_wrapper_yaml == f" { aw_dir } unit-test-default-cluster.yaml"
318323 assert cluster .app_wrapper_name == "unit-test-default-cluster"
319324 assert cluster .config .namespace == "opendatahub"
320325
@@ -344,21 +349,21 @@ def arg_check_apply_effect(group, version, namespace, plural, body, *args):
344349 if plural == "appwrappers" :
345350 assert group == "workload.codeflare.dev"
346351 assert version == "v1beta1"
347- with open (" unit-test-cluster.yaml" ) as f :
352+ with open (f" { aw_dir } unit-test-cluster.yaml" ) as f :
348353 aw = yaml .load (f , Loader = yaml .FullLoader )
349354 assert body == aw
350355 elif plural == "rayclusters" :
351356 assert group == "ray.io"
352357 assert version == "v1alpha1"
353- with open (" unit-test-cluster-ray.yaml" ) as f :
358+ with open (f" { aw_dir } unit-test-cluster-ray.yaml" ) as f :
354359 yamls = yaml .load_all (f , Loader = yaml .FullLoader )
355360 for resource in yamls :
356361 if resource ["kind" ] == "RayCluster" :
357362 assert body == resource
358363 elif plural == "routes" :
359364 assert group == "route.openshift.io"
360365 assert version == "v1"
361- with open (" unit-test-cluster-ray.yaml" ) as f :
366+ with open (f" { aw_dir } unit-test-cluster-ray.yaml" ) as f :
362367 yamls = yaml .load_all (f , Loader = yaml .FullLoader )
363368 for resource in yamls :
364369 if resource ["kind" ] == "Route" :
@@ -2368,7 +2373,7 @@ def parse_j(cmd):
23682373
23692374
23702375def test_AWManager_creation ():
2371- testaw = AWManager (" test.yaml" )
2376+ testaw = AWManager (f" { aw_dir } test.yaml" )
23722377 assert testaw .name == "test"
23732378 assert testaw .namespace == "ns"
23742379 assert testaw .submitted == False
@@ -2392,7 +2397,7 @@ def arg_check_aw_apply_effect(group, version, namespace, plural, body, *args):
23922397 assert version == "v1beta1"
23932398 assert namespace == "ns"
23942399 assert plural == "appwrappers"
2395- with open (" test.yaml" ) as f :
2400+ with open (f" { aw_dir } test.yaml" ) as f :
23962401 aw = yaml .load (f , Loader = yaml .FullLoader )
23972402 assert body == aw
23982403 assert args == tuple ()
@@ -2408,7 +2413,7 @@ def arg_check_aw_del_effect(group, version, namespace, plural, name, *args):
24082413
24092414
24102415def test_AWManager_submit_remove (mocker , capsys ):
2411- testaw = AWManager (" test.yaml" )
2416+ testaw = AWManager (f" { aw_dir } test.yaml" )
24122417 testaw .remove ()
24132418 captured = capsys .readouterr ()
24142419 assert (
@@ -2665,13 +2670,12 @@ def test_gen_app_wrapper_with_oauth(mocker: MockerFixture):
26652670
26662671# Make sure to always keep this function last
26672672def test_cleanup ():
2668- os .remove ("unit-test-cluster.yaml" )
2669- os .remove ("prio-test-cluster.yaml" )
2670- os .remove ("unit-test-default-cluster.yaml" )
2671- os .remove ("unit-test-cluster-ray.yaml" )
2672- os .remove ("test.yaml" )
2673- os .remove ("raytest2.yaml" )
2674- os .remove ("quicktest.yaml" )
2673+ os .remove (f"{ aw_dir } unit-test-cluster.yaml" )
2674+ os .remove (f"{ aw_dir } prio-test-cluster.yaml" )
2675+ os .remove (f"{ aw_dir } unit-test-default-cluster.yaml" )
2676+ os .remove (f"{ aw_dir } test.yaml" )
2677+ os .remove (f"{ aw_dir } raytest2.yaml" )
2678+ os .remove (f"{ aw_dir } quicktest.yaml" )
26752679 os .remove ("tls-cluster-namespace/ca.crt" )
26762680 os .remove ("tls-cluster-namespace/tls.crt" )
26772681 os .remove ("tls-cluster-namespace/tls.key" )
0 commit comments