21
21
import re
22
22
23
23
parent = Path (__file__ ).resolve ().parents [1 ]
24
+ aw_dir = os .path .expanduser ("~/.codeflare/appwrapper/" )
24
25
sys .path .append (str (parent ) + "/src" )
25
26
26
27
from kubernetes import client , config
@@ -246,10 +247,12 @@ def test_config_creation():
246
247
247
248
def test_cluster_creation ():
248
249
cluster = createClusterWithConfig ()
249
- assert cluster .app_wrapper_yaml == " unit-test-cluster.yaml"
250
+ assert cluster .app_wrapper_yaml == f" { aw_dir } unit-test-cluster.yaml"
250
251
assert cluster .app_wrapper_name == "unit-test-cluster"
251
252
assert filecmp .cmp (
252
- "unit-test-cluster.yaml" , f"{ parent } /tests/test-case.yaml" , shallow = True
253
+ f"{ aw_dir } unit-test-cluster.yaml" ,
254
+ f"{ parent } /tests/test-case.yaml" ,
255
+ shallow = True ,
253
256
)
254
257
255
258
@@ -263,10 +266,12 @@ def test_cluster_creation_priority(mocker):
263
266
config .name = "prio-test-cluster"
264
267
config .dispatch_priority = "default"
265
268
cluster = Cluster (config )
266
- assert cluster .app_wrapper_yaml == " prio-test-cluster.yaml"
269
+ assert cluster .app_wrapper_yaml == f" { aw_dir } prio-test-cluster.yaml"
267
270
assert cluster .app_wrapper_name == "prio-test-cluster"
268
271
assert filecmp .cmp (
269
- "prio-test-cluster.yaml" , f"{ parent } /tests/test-case-prio.yaml" , shallow = True
272
+ f"{ aw_dir } prio-test-cluster.yaml" ,
273
+ f"{ parent } /tests/test-case-prio.yaml" ,
274
+ shallow = True ,
270
275
)
271
276
272
277
@@ -280,7 +285,7 @@ def test_default_cluster_creation(mocker):
280
285
)
281
286
cluster = Cluster (default_config )
282
287
283
- assert cluster .app_wrapper_yaml == " unit-test-default-cluster.yaml"
288
+ assert cluster .app_wrapper_yaml == f" { aw_dir } unit-test-default-cluster.yaml"
284
289
assert cluster .app_wrapper_name == "unit-test-default-cluster"
285
290
assert cluster .config .namespace == "opendatahub"
286
291
@@ -290,7 +295,7 @@ def arg_check_apply_effect(group, version, namespace, plural, body, *args):
290
295
assert version == "v1beta1"
291
296
assert namespace == "ns"
292
297
assert plural == "appwrappers"
293
- with open (" unit-test-cluster.yaml" ) as f :
298
+ with open (f" { aw_dir } unit-test-cluster.yaml" ) as f :
294
299
aw = yaml .load (f , Loader = yaml .FullLoader )
295
300
assert body == aw
296
301
assert args == tuple ()
@@ -2151,7 +2156,7 @@ def parse_j(cmd):
2151
2156
2152
2157
2153
2158
def test_AWManager_creation ():
2154
- testaw = AWManager (" test.yaml" )
2159
+ testaw = AWManager (f" { aw_dir } test.yaml" )
2155
2160
assert testaw .name == "test"
2156
2161
assert testaw .namespace == "ns"
2157
2162
assert testaw .submitted == False
@@ -2175,7 +2180,7 @@ def arg_check_aw_apply_effect(group, version, namespace, plural, body, *args):
2175
2180
assert version == "v1beta1"
2176
2181
assert namespace == "ns"
2177
2182
assert plural == "appwrappers"
2178
- with open (" test.yaml" ) as f :
2183
+ with open (f" { aw_dir } test.yaml" ) as f :
2179
2184
aw = yaml .load (f , Loader = yaml .FullLoader )
2180
2185
assert body == aw
2181
2186
assert args == tuple ()
@@ -2191,7 +2196,7 @@ def arg_check_aw_del_effect(group, version, namespace, plural, name, *args):
2191
2196
2192
2197
2193
2198
def test_AWManager_submit_remove (mocker , capsys ):
2194
- testaw = AWManager (" test.yaml" )
2199
+ testaw = AWManager (f" { aw_dir } test.yaml" )
2195
2200
testaw .remove ()
2196
2201
captured = capsys .readouterr ()
2197
2202
assert (
@@ -2429,12 +2434,12 @@ def test_gen_app_wrapper_with_oauth(mocker: MockerFixture):
2429
2434
2430
2435
# Make sure to always keep this function last
2431
2436
def test_cleanup ():
2432
- os .remove (" unit-test-cluster.yaml" )
2433
- os .remove (" prio-test-cluster.yaml" )
2434
- os .remove (" unit-test-default-cluster.yaml" )
2435
- os .remove (" test.yaml" )
2436
- os .remove (" raytest2.yaml" )
2437
- os .remove (" quicktest.yaml" )
2437
+ os .remove (f" { aw_dir } unit-test-cluster.yaml" )
2438
+ os .remove (f" { aw_dir } prio-test-cluster.yaml" )
2439
+ os .remove (f" { aw_dir } unit-test-default-cluster.yaml" )
2440
+ os .remove (f" { aw_dir } test.yaml" )
2441
+ os .remove (f" { aw_dir } raytest2.yaml" )
2442
+ os .remove (f" { aw_dir } quicktest.yaml" )
2438
2443
os .remove ("tls-cluster-namespace/ca.crt" )
2439
2444
os .remove ("tls-cluster-namespace/tls.crt" )
2440
2445
os .remove ("tls-cluster-namespace/tls.key" )
0 commit comments