31
31
macros ,
32
32
MalformedAppHandleException ,
33
33
MISSING ,
34
+ MountType ,
34
35
NULL_RESOURCE ,
35
36
parse_app_handle ,
36
37
ReplicaStatus ,
@@ -55,6 +56,20 @@ def test_repr(self) -> None:
55
56
56
57
57
58
class AppDefStatusTest (unittest .TestCase ):
59
+
60
+ def test_app_state_from_str (self ) -> None :
61
+ self .assertEqual (AppState .UNSUBMITTED , AppState .from_str ("UNSUBMITTED" ))
62
+ self .assertEqual (AppState .SUBMITTED , AppState .from_str ("SUBMITTED" ))
63
+ self .assertEqual (AppState .PENDING , AppState .from_str ("PENDING" ))
64
+ self .assertEqual (AppState .RUNNING , AppState .from_str ("RUNNING" ))
65
+ self .assertEqual (AppState .SUCCEEDED , AppState .from_str ("SUCCEEDED" ))
66
+ self .assertEqual (AppState .FAILED , AppState .from_str ("FAILED" ))
67
+ self .assertEqual (AppState .CANCELLED , AppState .from_str ("CANCELLED" ))
68
+ self .assertEqual (AppState .UNKNOWN , AppState .from_str ("UNKNOWN" ))
69
+
70
+ with self .assertRaises (ValueError ):
71
+ AppState .from_str ("INVALID_STATE" )
72
+
58
73
def test_is_terminal (self ) -> None :
59
74
for s in AppState :
60
75
is_terminal = AppStatus (state = s ).is_terminal ()
@@ -315,6 +330,26 @@ def test_retry_policies(self) -> None:
315
330
},
316
331
)
317
332
333
+ def test_retry_policy_from_str (self ) -> None :
334
+ # Test valid retry policy strings
335
+ self .assertEqual (RetryPolicy .APPLICATION , RetryPolicy .from_str ("APPLICATION" ))
336
+ self .assertEqual (RetryPolicy .REPLICA , RetryPolicy .from_str ("REPLICA" ))
337
+ self .assertEqual (RetryPolicy .ROLE , RetryPolicy .from_str ("ROLE" ))
338
+
339
+ # Test invalid retry policy string
340
+ with self .assertRaises (ValueError ):
341
+ RetryPolicy .from_str ("INVALID_POLICY" )
342
+
343
+ def test_mount_type_from_str (self ) -> None :
344
+ # Test valid mount type strings
345
+ self .assertEqual (MountType .BIND , MountType .from_str ("BIND" ))
346
+ self .assertEqual (MountType .VOLUME , MountType .from_str ("VOLUME" ))
347
+ self .assertEqual (MountType .DEVICE , MountType .from_str ("DEVICE" ))
348
+
349
+ # Test invalid mount type string
350
+ with self .assertRaises (ValueError ):
351
+ MountType .from_str ("INVALID_MOUNT_TYPE" )
352
+
318
353
def test_override_role (self ) -> None :
319
354
default = Role (
320
355
"foobar" ,
0 commit comments