@@ -435,3 +435,37 @@ def test_as_swat():
435
435
username = "testuser" ,
436
436
password = None ,
437
437
)
438
+
439
+
440
+ @mock .patch ("sasctl.core.Session._get_authorization_token" )
441
+ @mock .patch ("sasctl.core.Session.get" )
442
+ def test_version_info_35 (get , _ ):
443
+ """Verify that Session.version_info() makes the correct HTTP call."""
444
+ from sasctl .core import VersionInfo
445
+ s = Session ("example.com" , "user" , "password" )
446
+
447
+ get .return_value .status_code = 200
448
+ get .return_value .json .return_value = {"release" : "V03" }
449
+
450
+ version = s .version_info ()
451
+
452
+ assert get .call_count == 1
453
+
454
+ url , params = get .call_args
455
+ assert url [0 ] == '/licenses/grants'
456
+
457
+ assert isinstance (version , VersionInfo )
458
+ assert version .major == 3
459
+
460
+
461
+ @mock .patch ("sasctl.core.Session._get_authorization_token" )
462
+ @mock .patch ("sasctl.core.Session.get" )
463
+ def test_version_info_invalid_response (get , _ ):
464
+ """Verify that Session.version_info() returns None if the HTTP response is invalid."""
465
+ s = Session ("example.com" , "user" , "password" )
466
+
467
+ get .return_value .status_code = 200
468
+ get .return_value .json .return_value = {"not_a_release" : "V03" }
469
+
470
+ version = s .version_info ()
471
+ assert version is None
0 commit comments