12
12
import json
13
13
14
14
15
- class DnsTests (testing .TestCase ):
15
+ class GlobalIpTests (testing .TestCase ):
16
16
17
- def test_ip_assign (self ):
18
- result = self .run_command (['globalip' , 'assign' , '1' ])
19
-
20
- self .assert_no_fail (result )
21
- self .assertEqual (result .output , "" )
22
-
23
- @mock .patch ('SoftLayer.CLI.formatting.no_going_back' )
17
+ @mock .patch ('SoftLayer.CLI.formatting.confirm' )
24
18
def test_ip_cancel (self , no_going_back_mock ):
25
19
# Test using --really flag
26
20
result = self .run_command (['--really' , 'globalip' , 'cancel' , '1' ])
@@ -39,7 +33,7 @@ def test_ip_cancel(self, no_going_back_mock):
39
33
no_going_back_mock .return_value = False
40
34
result = self .run_command (['globalip' , 'cancel' , '1' ])
41
35
42
- self .assertEqual (result .exit_code , 0 )
36
+ self .assertEqual (result .exit_code , 2 )
43
37
44
38
def test_ip_list (self ):
45
39
result = self .run_command (['globalip' , 'list' , '--ip-version=v4' ])
@@ -84,6 +78,31 @@ def test_ip_unassign(self):
84
78
result = self .run_command (['globalip' , 'unassign' , '1' ])
85
79
self .assert_no_fail (result )
86
80
self .assertEqual (result .output , "" )
81
+ self .assert_called_with ('SoftLayer_Network_Subnet' , 'clearRoute' , identifier = 9988 )
82
+
83
+ def test_ip_assign (self ):
84
+ result = self .run_command (['globalip' , 'assign' , '1' , '999' ])
85
+ self .assert_no_fail (result )
86
+ self .assertEqual (result .output , "" )
87
+ service = 'SoftLayer_Network_Subnet_IpAddress'
88
+ self .assert_called_with ('SoftLayer_Network_Subnet' , 'route' , identifier = 9988 , args = (service , '999' ))
89
+
90
+ def test_ip_assign_target (self ):
91
+ result = self .run_command (['globalip' , 'assign' , '1' , '--target-id=8123' ])
92
+ self .assert_no_fail (result )
93
+ self .assertEqual (result .output , "" )
94
+ service = 'SoftLayer_Network_Subnet_IpAddress'
95
+ self .assert_called_with ('SoftLayer_Network_Subnet' , 'route' , identifier = 9988 , args = (service , '8123' ))
96
+
97
+ def test_ip_assign_ip (self ):
98
+ mock_api = self .set_mock ('SoftLayer_Account' , 'getGlobalIpRecords' )
99
+ mock_api .return_value = [{"id" : 112233 }]
100
+ result = self .run_command (['globalip' , 'assign' , '192.168.1.1' , '1.2.3.4' ])
101
+ self .assert_no_fail (result )
102
+ self .assertEqual (result .output , "" )
103
+ service = 'SoftLayer_Network_Subnet_IpAddress'
104
+ self .assert_called_with (f"{ service } _Global" , "getObject" , identifier = 112233 )
105
+ self .assert_called_with ('SoftLayer_Network_Subnet' , 'route' , identifier = 9988 , args = (service , '1.2.3.4' ))
87
106
88
107
def test_ip_cancel_force (self ):
89
108
result = self .run_command (['globalip' , 'cancel' , '1' , '--force' ])
0 commit comments