File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ command
Original file line number Diff line number Diff line change @@ -553,3 +553,30 @@ def get_active_products(args=None):
553553 parser .parse_args (args = args )
554554 client = get_client ()
555555 print_response (client .get_active_products ())
556+
557+
558+ def check_xgrade (args = None ):
559+ parser = ArgumentParser (
560+ description = """
561+ Verify that the specified app can be upgraded to the specified product.
562+ This checks if there is enough disk space available. The output will also
563+ show whether or not there will be an IP change and if a volume swap xgrade
564+ would be performed instead of an rsync xgrade.
565+
566+ Example:
567+ $ ./bin/check_xgrade FALCON_L_202203
568+ {
569+ "has_valid_vat_number": true,
570+ "has_valid_payment_method": true,
571+ "will_change_ip": false,
572+ "will_do_volswap": false,
573+ "will_disk_fit": true
574+ }
575+ """ ,
576+ formatter_class = RawTextHelpFormatter ,
577+ )
578+ parser .add_argument ("product_code" , help = "The code of the product to check" )
579+ args = parser .parse_args (args = args )
580+ client = get_client ()
581+ app_name = get_app_name ()
582+ print_response (client .check_xgrade (app_name , args .product_code ))
Original file line number Diff line number Diff line change 1+ from hypernode_api_python .commands import check_xgrade
2+ from tests .testcase import TestCase
3+
4+
5+ class TestCheckXgrade (TestCase ):
6+ def setUp (self ):
7+ self .print_response = self .set_up_patch (
8+ "hypernode_api_python.commands.print_response"
9+ )
10+ self .get_client = self .set_up_patch ("hypernode_api_python.commands.get_client" )
11+ self .client = self .get_client .return_value
12+ self .get_app_name = self .set_up_patch (
13+ "hypernode_api_python.commands.get_app_name"
14+ )
15+ self .get_app_name .return_value = "myappname"
16+
17+ def test_check_xgrade_gets_client (self ):
18+ check_xgrade (["FALCON_S_202203" ])
19+
20+ self .get_client .assert_called_once_with ()
21+
22+ def test_check_xgrade_gets_app_name (self ):
23+ check_xgrade (["FALCON_S_202203" ])
24+
25+ self .get_app_name .assert_called_once_with ()
26+
27+ def test_check_xgrade_gets_product_info (self ):
28+ check_xgrade (["FALCON_S_202203" ])
29+
30+ self .client .check_xgrade .assert_called_once_with ("myappname" , "FALCON_S_202203" )
31+
32+ def test_check_xgrade_prints_product (self ):
33+ check_xgrade (["FALCON_S_202203" ])
34+
35+ self .print_response .assert_called_once_with (
36+ self .client .check_xgrade .return_value
37+ )
You can’t perform that action at this time.
0 commit comments