2424from codeflare_sdk .cluster import cluster
2525
2626parent = Path (__file__ ).resolve ().parents [1 ]
27+ aw_dir = os .path .expanduser ("~/.codeflare/appwrapper/" )
2728sys .path .append (str (parent ) + "/src" )
2829
2930from kubernetes import client , config
@@ -261,10 +262,12 @@ def test_config_creation():
261262
262263def test_cluster_creation (mocker ):
263264 cluster = createClusterWithConfig (mocker )
264- assert cluster .app_wrapper_yaml == " unit-test-cluster.yaml"
265+ assert cluster .app_wrapper_yaml == f" { aw_dir } unit-test-cluster.yaml"
265266 assert cluster .app_wrapper_name == "unit-test-cluster"
266267 assert filecmp .cmp (
267- "unit-test-cluster.yaml" , f"{ parent } /tests/test-case.yaml" , shallow = True
268+ f"{ aw_dir } unit-test-cluster.yaml" ,
269+ f"{ parent } /tests/test-case.yaml" ,
270+ shallow = True ,
268271 )
269272
270273
@@ -290,10 +293,10 @@ def test_cluster_creation_no_mcad(mocker):
290293 config .name = "unit-test-cluster-ray"
291294 config .mcad = False
292295 cluster = Cluster (config )
293- assert cluster .app_wrapper_yaml == " unit-test-cluster-ray.yaml"
296+ assert cluster .app_wrapper_yaml == f" { aw_dir } unit-test-cluster-ray.yaml"
294297 assert cluster .app_wrapper_name == "unit-test-cluster-ray"
295298 assert filecmp .cmp (
296- " unit-test-cluster-ray.yaml" ,
299+ f" { aw_dir } unit-test-cluster-ray.yaml" ,
297300 f"{ parent } /tests/test-case-no-mcad.yamls" ,
298301 shallow = True ,
299302 )
@@ -313,10 +316,12 @@ def test_cluster_creation_priority(mocker):
313316 return_value = {"spec" : {"domain" : "apps.cluster.awsroute.org" }},
314317 )
315318 cluster = Cluster (config )
316- assert cluster .app_wrapper_yaml == " prio-test-cluster.yaml"
319+ assert cluster .app_wrapper_yaml == f" { aw_dir } prio-test-cluster.yaml"
317320 assert cluster .app_wrapper_name == "prio-test-cluster"
318321 assert filecmp .cmp (
319- "prio-test-cluster.yaml" , f"{ parent } /tests/test-case-prio.yaml" , shallow = True
322+ f"{ aw_dir } prio-test-cluster.yaml" ,
323+ f"{ parent } /tests/test-case-prio.yaml" ,
324+ shallow = True ,
320325 )
321326
322327
@@ -335,7 +340,7 @@ def test_default_cluster_creation(mocker):
335340 )
336341 cluster = Cluster (default_config )
337342
338- assert cluster .app_wrapper_yaml == " unit-test-default-cluster.yaml"
343+ assert cluster .app_wrapper_yaml == f" { aw_dir } unit-test-default-cluster.yaml"
339344 assert cluster .app_wrapper_name == "unit-test-default-cluster"
340345 assert cluster .config .namespace == "opendatahub"
341346
@@ -365,21 +370,21 @@ def arg_check_apply_effect(group, version, namespace, plural, body, *args):
365370 if plural == "appwrappers" :
366371 assert group == "workload.codeflare.dev"
367372 assert version == "v1beta1"
368- with open (" unit-test-cluster.yaml" ) as f :
373+ with open (f" { aw_dir } unit-test-cluster.yaml" ) as f :
369374 aw = yaml .load (f , Loader = yaml .FullLoader )
370375 assert body == aw
371376 elif plural == "rayclusters" :
372377 assert group == "ray.io"
373378 assert version == "v1alpha1"
374- with open (" unit-test-cluster-ray.yaml" ) as f :
379+ with open (f" { aw_dir } unit-test-cluster-ray.yaml" ) as f :
375380 yamls = yaml .load_all (f , Loader = yaml .FullLoader )
376381 for resource in yamls :
377382 if resource ["kind" ] == "RayCluster" :
378383 assert body == resource
379384 elif plural == "routes" :
380385 assert group == "route.openshift.io"
381386 assert version == "v1"
382- with open (" unit-test-cluster-ray.yaml" ) as f :
387+ with open (f" { aw_dir } unit-test-cluster-ray.yaml" ) as f :
383388 yamls = yaml .load_all (f , Loader = yaml .FullLoader )
384389 for resource in yamls :
385390 if resource ["kind" ] == "Route" :
@@ -2408,7 +2413,7 @@ def parse_j(cmd):
24082413
24092414
24102415def test_AWManager_creation ():
2411- testaw = AWManager (" test.yaml" )
2416+ testaw = AWManager (f" { aw_dir } test.yaml" )
24122417 assert testaw .name == "test"
24132418 assert testaw .namespace == "ns"
24142419 assert testaw .submitted == False
@@ -2432,7 +2437,7 @@ def arg_check_aw_apply_effect(group, version, namespace, plural, body, *args):
24322437 assert version == "v1beta1"
24332438 assert namespace == "ns"
24342439 assert plural == "appwrappers"
2435- with open (" test.yaml" ) as f :
2440+ with open (f" { aw_dir } test.yaml" ) as f :
24362441 aw = yaml .load (f , Loader = yaml .FullLoader )
24372442 assert body == aw
24382443 assert args == tuple ()
@@ -2448,7 +2453,7 @@ def arg_check_aw_del_effect(group, version, namespace, plural, name, *args):
24482453
24492454
24502455def test_AWManager_submit_remove (mocker , capsys ):
2451- testaw = AWManager (" test.yaml" )
2456+ testaw = AWManager (f" { aw_dir } test.yaml" )
24522457 testaw .remove ()
24532458 captured = capsys .readouterr ()
24542459 assert (
@@ -2876,13 +2881,12 @@ def test_gen_app_wrapper_with_oauth(mocker: MockerFixture):
28762881
28772882# Make sure to always keep this function last
28782883def test_cleanup ():
2879- os .remove ("unit-test-cluster.yaml" )
2880- os .remove ("prio-test-cluster.yaml" )
2881- os .remove ("unit-test-default-cluster.yaml" )
2882- os .remove ("unit-test-cluster-ray.yaml" )
2883- os .remove ("test.yaml" )
2884- os .remove ("raytest2.yaml" )
2885- os .remove ("quicktest.yaml" )
2884+ os .remove (f"{ aw_dir } unit-test-cluster.yaml" )
2885+ os .remove (f"{ aw_dir } prio-test-cluster.yaml" )
2886+ os .remove (f"{ aw_dir } unit-test-default-cluster.yaml" )
2887+ os .remove (f"{ aw_dir } test.yaml" )
2888+ os .remove (f"{ aw_dir } raytest2.yaml" )
2889+ os .remove (f"{ aw_dir } quicktest.yaml" )
28862890 os .remove ("tls-cluster-namespace/ca.crt" )
28872891 os .remove ("tls-cluster-namespace/tls.crt" )
28882892 os .remove ("tls-cluster-namespace/tls.key" )
0 commit comments