22
22
import uuid
23
23
24
24
parent = Path (__file__ ).resolve ().parents [1 ]
25
+ aw_dir = os .path .expanduser ("~/.codeflare/appwrapper/" )
25
26
sys .path .append (str (parent ) + "/src" )
26
27
27
28
from kubernetes import client , config
@@ -254,10 +255,12 @@ def test_config_creation():
254
255
255
256
def test_cluster_creation (mocker ):
256
257
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"
258
259
assert cluster .app_wrapper_name == "unit-test-cluster"
259
260
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 ,
261
264
)
262
265
263
266
@@ -270,10 +273,10 @@ def test_cluster_creation_no_mcad(mocker):
270
273
config .name = "unit-test-cluster-ray"
271
274
config .mcad = False
272
275
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"
274
277
assert cluster .app_wrapper_name == "unit-test-cluster-ray"
275
278
assert filecmp .cmp (
276
- " unit-test-cluster-ray.yaml" ,
279
+ f" { aw_dir } unit-test-cluster-ray.yaml" ,
277
280
f"{ parent } /tests/test-case-no-mcad.yamls" ,
278
281
shallow = True ,
279
282
)
@@ -293,10 +296,12 @@ def test_cluster_creation_priority(mocker):
293
296
return_value = {"spec" : {"domain" : "apps.cluster.awsroute.org" }},
294
297
)
295
298
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"
297
300
assert cluster .app_wrapper_name == "prio-test-cluster"
298
301
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 ,
300
305
)
301
306
302
307
@@ -314,7 +319,7 @@ def test_default_cluster_creation(mocker):
314
319
)
315
320
cluster = Cluster (default_config )
316
321
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"
318
323
assert cluster .app_wrapper_name == "unit-test-default-cluster"
319
324
assert cluster .config .namespace == "opendatahub"
320
325
@@ -344,21 +349,21 @@ def arg_check_apply_effect(group, version, namespace, plural, body, *args):
344
349
if plural == "appwrappers" :
345
350
assert group == "workload.codeflare.dev"
346
351
assert version == "v1beta1"
347
- with open (" unit-test-cluster.yaml" ) as f :
352
+ with open (f" { aw_dir } unit-test-cluster.yaml" ) as f :
348
353
aw = yaml .load (f , Loader = yaml .FullLoader )
349
354
assert body == aw
350
355
elif plural == "rayclusters" :
351
356
assert group == "ray.io"
352
357
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 :
354
359
yamls = yaml .load_all (f , Loader = yaml .FullLoader )
355
360
for resource in yamls :
356
361
if resource ["kind" ] == "RayCluster" :
357
362
assert body == resource
358
363
elif plural == "routes" :
359
364
assert group == "route.openshift.io"
360
365
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 :
362
367
yamls = yaml .load_all (f , Loader = yaml .FullLoader )
363
368
for resource in yamls :
364
369
if resource ["kind" ] == "Route" :
@@ -2368,7 +2373,7 @@ def parse_j(cmd):
2368
2373
2369
2374
2370
2375
def test_AWManager_creation ():
2371
- testaw = AWManager (" test.yaml" )
2376
+ testaw = AWManager (f" { aw_dir } test.yaml" )
2372
2377
assert testaw .name == "test"
2373
2378
assert testaw .namespace == "ns"
2374
2379
assert testaw .submitted == False
@@ -2392,7 +2397,7 @@ def arg_check_aw_apply_effect(group, version, namespace, plural, body, *args):
2392
2397
assert version == "v1beta1"
2393
2398
assert namespace == "ns"
2394
2399
assert plural == "appwrappers"
2395
- with open (" test.yaml" ) as f :
2400
+ with open (f" { aw_dir } test.yaml" ) as f :
2396
2401
aw = yaml .load (f , Loader = yaml .FullLoader )
2397
2402
assert body == aw
2398
2403
assert args == tuple ()
@@ -2408,7 +2413,7 @@ def arg_check_aw_del_effect(group, version, namespace, plural, name, *args):
2408
2413
2409
2414
2410
2415
def test_AWManager_submit_remove (mocker , capsys ):
2411
- testaw = AWManager (" test.yaml" )
2416
+ testaw = AWManager (f" { aw_dir } test.yaml" )
2412
2417
testaw .remove ()
2413
2418
captured = capsys .readouterr ()
2414
2419
assert (
@@ -2665,13 +2670,12 @@ def test_gen_app_wrapper_with_oauth(mocker: MockerFixture):
2665
2670
2666
2671
# Make sure to always keep this function last
2667
2672
def 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" )
2675
2679
os .remove ("tls-cluster-namespace/ca.crt" )
2676
2680
os .remove ("tls-cluster-namespace/tls.crt" )
2677
2681
os .remove ("tls-cluster-namespace/tls.key" )
0 commit comments