@@ -17,32 +17,10 @@ class SubnetTests(testing.TestCase):
1717
1818 def test_detail (self ):
1919 result = self .run_command (['subnet' , 'detail' , '1234' ])
20-
20+ subnet = json . loads ( result . output )
2121 self .assert_no_fail (result )
22- self .assertEqual (
23- {
24- 'id' : 1234 ,
25- 'identifier' : '1.2.3.4/26' ,
26- 'subnet type' : 'ADDITIONAL_PRIMARY' ,
27- 'network space' : 'PUBLIC' ,
28- 'gateway' : '1.2.3.254' ,
29- 'broadcast' : '1.2.3.255' ,
30- 'datacenter' : 'dal10' ,
31- 'vs' : [
32- {
33- 'hostname' : 'hostname0' ,
34- 'domain' : 'sl.test' ,
35- 'public_ip' : '1.2.3.10' ,
36- 'private_ip' : '10.0.1.2'
37- }
38- ],
39- 'ipAddresses' : {
40- '123456' : '16.26.26.25' ,
41- '123457' : '16.26.26.26' },
42- 'hardware' : 'none' ,
43- 'usable ips' : 22
44- },
45- json .loads (result .output ))
22+ self .assertEqual (subnet .get ('id' ), 1234 )
23+ self .assertEqual (subnet .get ('identifier' ), '1.2.3.4/26' )
4624
4725 def test_list (self ):
4826 result = self .run_command (['subnet' , 'list' ])
@@ -138,6 +116,38 @@ def test_create_subnet_static_ipv6(self, confirm_mock):
138116
139117 self .assertEqual (output , json .loads (result .output ))
140118
119+ @mock .patch ('SoftLayer.CLI.subnet.edit.click' )
120+ def test_subnet_set_tags (self , click ):
121+ result = self .run_command (['subnet' , 'edit' , '1234' , '--tags=tag1,tag2' ])
122+ click .secho .assert_called_with ('Set tags successfully' , fg = 'green' )
123+ self .assert_no_fail (result )
124+ self .assert_called_with ('SoftLayer_Network_Subnet' , 'setTags' , identifier = 1234 , args = ("tag1,tag2" ,))
125+
126+ @mock .patch ('SoftLayer.CLI.subnet.edit.click' )
127+ def test_subnet_edit_note (self , click ):
128+ result = self .run_command (['subnet' , 'edit' , '1234' , '--note=test' ])
129+ click .secho .assert_called_with ('Edit note successfully' , fg = 'green' )
130+ self .assert_no_fail (result )
131+ self .assert_called_with ('SoftLayer_Network_Subnet' , 'editNote' , identifier = 1234 , args = ("test" ,))
132+
133+ @mock .patch ('SoftLayer.CLI.subnet.edit.click' )
134+ def test_subnet_set_tags_failure (self , click ):
135+ mock = self .set_mock ('SoftLayer_Network_Subnet' , 'setTags' )
136+ mock .return_value = False
137+ result = self .run_command (['subnet' , 'edit' , '1234' , '--tags=tag1,tag2' ])
138+ click .secho .assert_called_with ('Failed to set tags' , fg = 'red' )
139+ self .assert_no_fail (result )
140+ self .assert_called_with ('SoftLayer_Network_Subnet' , 'setTags' , identifier = 1234 , args = ("tag1,tag2" ,))
141+
142+ @mock .patch ('SoftLayer.CLI.subnet.edit.click' )
143+ def test_edit_note_failure (self , click ):
144+ mock = self .set_mock ('SoftLayer_Network_Subnet' , 'editNote' )
145+ mock .return_value = False
146+ result = self .run_command (['subnet' , 'edit' , '1234' , '--note=test' ])
147+ click .secho .assert_called_with ('Failed to edit note' , fg = 'red' )
148+ self .assert_no_fail (result )
149+ self .assert_called_with ('SoftLayer_Network_Subnet' , 'editNote' , identifier = 1234 , args = ("test" ,))
150+
141151 def test_editrou_Ip (self ):
142152 result = self .run_command (['subnet' , 'edit-ip' , '16.26.26.26' , '--note=test' ])
143153 self .assert_no_fail (result )
0 commit comments