99
1010from SoftLayer .CLI import exceptions
1111from SoftLayer import exceptions as ex
12+ from SoftLayer .fixtures import SoftLayer_Network_Vlan
1213from SoftLayer .fixtures import SoftLayer_Product_Order
1314from SoftLayer .fixtures import SoftLayer_Product_Package
1415from SoftLayer import testing
@@ -34,27 +35,15 @@ def test_detail_no_hardware(self):
3435
3536 def test_subnet_list (self ):
3637 vlan_mock = self .set_mock ('SoftLayer_Network_Vlan' , 'getObject' )
37- getObject = {
38- 'primaryRouter' : {
39- 'datacenter' : {'id' : 1234 , 'longName' : 'TestDC' },
40- 'fullyQualifiedDomainName' : 'fcr01.TestDC'
41- },
42- 'id' : 1234 ,
43- 'vlanNumber' : 4444 ,
44- 'firewallInterfaces' : None ,
45- 'subnets' : [
46- {
47- 'id' : 99 ,
48- 'networkIdentifier' : 1111111 ,
49- 'netmask' : '255.255.255.0' ,
50- 'gateway' : '12.12.12.12' ,
51- 'subnetType' : 'TEST' ,
52- 'usableIpAddressCount' : 1
53-
54- }
55-
56- ]
57- }
38+ getObject = {'primaryRouter' : {'datacenter' : {'id' : 1234 , 'longName' : 'TestDC' },
39+ 'fullyQualifiedDomainName' : 'fcr01.TestDC' },
40+ 'id' : 1234 ,
41+ 'vlanNumber' : 4444 ,
42+ 'firewallInterfaces' : None ,
43+ 'subnets' : [{'id' : 99 , 'networkIdentifier' : 1111111 , 'netmask' : '255.255.255.0' ,
44+ 'gateway' : '12.12.12.12' , 'subnetType' : 'TEST' , 'usableIpAddressCount' : 1 }
45+ ]
46+ }
5847 vlan_mock .return_value = getObject
5948 result = self .run_command (['vlan' , 'detail' , '1234' ])
6049 self .assert_no_fail (result )
@@ -98,7 +87,7 @@ def test_vlan_edit(self, click):
9887 @mock .patch ('SoftLayer.CLI.vlan.edit.click' )
9988 def test_vlan_edit_not_any (self , click ):
10089 result = self .run_command (['vlan' , 'edit' , '100' ])
101- self .assertTrue (result .exit_code , 2 )
90+ self .assertEqual (result .exit_code , 2 )
10291 self .assertEqual ("At least one option is required" , result .exception .message )
10392
10493 def test_vlan_create_not_data_pod (self ):
@@ -147,23 +136,19 @@ def test_vlan_create_network_priv(self, confirm_mock):
147136 def test_vlan_create_option (self , confirm_mock ):
148137 confirm_mock .return_value = True
149138 datacenter_mock = self .set_mock ('SoftLayer_Location_Datacenter' , 'getDatacenters' )
150- datacenter_mock .return_value = [{'id' : 814994 ,
151- 'name' : 'ams03'
152- }]
139+ datacenter_mock .return_value = [{'id' : 814994 , 'name' : 'ams03' }]
153140 router_mock = self .set_mock ('SoftLayer_Location_Datacenter' , 'getHardwareRouters' )
154141 router_mock .return_value = [{'hostname' : 'bcr01a.ams03' }]
155142 result = self .run_command (['vlan' , 'create-options' ])
156- print (result .output )
157143 self .assert_no_fail (result )
158144
159145 @mock .patch ('SoftLayer.CLI.formatting.no_going_back' )
160146 def test_vlan_list_get_pod_with_closed_announcement (self , ngb_mock ):
161147 ngb_mock .return_value = True
162148 vlan_mock = self .set_mock ('SoftLayer_Account' , 'getNetworkVlans' )
163149 gpods_mock = self .set_mock ('SoftLayer_Network_Pod' , 'getAllObjects' )
164- vlan_mock .return_value = {'primaryRouter' : {
165- 'fullyQualifiedDomainName' : 'bcr01a.fra02.softlayer.com' ,
166- 'id' : 462912 },
150+ vlan_mock .return_value = {'primaryRouter' : {'fullyQualifiedDomainName' : 'bcr01a.fra02.softlayer.com' ,
151+ 'id' : 462912 },
167152 'tagReferences' : '' }
168153 gpods_mock .return_value = [{'backendRouterId' : 462912 ,
169154 'backendRouterName' : 'bcr01a.fra02' ,
@@ -181,11 +166,9 @@ def test_vlan_list_get_pod_with_closed_announcement_no_closure(self, ngb_mock):
181166 ngb_mock .return_value = True
182167 vlan_mock = self .set_mock ('SoftLayer_Account' , 'getNetworkVlans' )
183168 gpods_mock = self .set_mock ('SoftLayer_Network_Pod' , 'getAllObjects' )
184- vlan_mock .return_value = {
185- 'primaryRouter' : {'fullyQualifiedDomainName' : 'bcr01a.fra02.softlayer.com' ,
186- 'id' : 462912
187- },
188- 'tagReferences' : '' }
169+ vlan_mock .return_value = {'primaryRouter' : {'fullyQualifiedDomainName' : 'bcr01a.fra02.softlayer.com' ,
170+ 'id' : 462912 },
171+ 'tagReferences' : '' }
189172 gpods_mock .return_value = [{'backendRouterId' : 462912 ,
190173 'backendRouterName' : 'bcr01a.fra02' ,
191174 'datacenterId' : 449506 ,
@@ -198,57 +181,10 @@ def test_vlan_list_get_pod_with_closed_announcement_no_closure(self, ngb_mock):
198181 self .assert_no_fail (result )
199182
200183 @mock .patch ('SoftLayer.CLI.formatting.no_going_back' )
201- def test_vlan_details_no_vs_no_hard_no_trunck (self , ngb_mock ):
184+ def test_vlan_details_no_vs_no_hard_no_trunk (self , ngb_mock ):
202185 ngb_mock .return_value = True
203186 vlan_mock = self .set_mock ('SoftLayer_Network_Vlan' , 'getObject' )
204- get_object = {'primaryRouter' : {'fullyQualifiedDomainName' : 'bcr02a.fra02.softlayer.com' ,
205- 'id' : 1186647 ,
206- 'datacenter' : {'id' : 449506 ,
207- 'longName' : 'Frankfurt 2' ,
208- 'name' : 'fra02' }
209- },
210- 'id' : 1186647 ,
211- 'vlanNumber' : 932 ,
212- 'networkVlanFirewall' : {
213- 'datacenter' : {'id' : 449506 , 'longName' : 'Frankfurt 2' },
214- 'fullyQualifiedDomainName' : 'bcr02a.fra02.softlayer.com'
215- },
216- 'subnets' : [
217- {'gateway' : '10.85.154.1' ,
218- 'id' : 1688651 ,
219- 'netmask' : '255.255.255.192' ,
220- 'networkIdentifier' : '10.85.154.0' ,
221- 'subnetType' : 'ADDITIONAL_PRIMARY' ,
222- 'usableIpAddressCount' : '61' }],
223- 'hardware' : [
224- {'domain' : 'vmware.chechu.com' ,
225- 'hostname' : 'host15' ,
226- 'primaryBackendIpAddress' : '10.177.122.170' ,
227- 'primaryIpAddress' : '169.46.48.107' }],
228- 'virtualGuests' : [
229- {'domain' : 'ocp-virt.chechu.me' ,
230- 'hostname' : 'haproxy' ,
231- 'primaryBackendIpAddress' : '10.85.154.44' ,
232- 'primaryIpAddress' : '158.177.72.67' }],
233- 'networkComponentTrunks' : [
234- {'networkComponent' : {'hardwareId' : 1483895 , 'networkVlanId' : 3285524 ,
235- 'port' : 12 ,
236- 'downlinkComponent' : {
237- 'networkVlanId' : '' , 'port' : 0 ,
238- 'primaryIpAddress' : '10.194.250.148' ,
239- 'hardware' : {
240- 'domain' : 'chechu.me' ,
241- 'fullyQualifiedDomainName' : 'fra02-ocp-virt.chechu.me' ,
242- 'hostname' : 'fra02-ocp-virt' ,
243- 'networkManagementIpAddress' : '10.194.250.150' ,
244- 'tagReferences' : []
245- },
246- 'networkComponentGroup' : {
247- 'groupTypeId' : 1 ,
248- 'membersDescription' : 'eth0/2' }}}}],
249- 'tagReferences' : []}
250-
251- vlan_mock .return_value = get_object
187+ vlan_mock .return_value = SoftLayer_Network_Vlan .getObject_no_hard_no_vs_no_trunk
252188 result = self .run_command (['vlan' , 'detail' , '3284824' ])
253189 self .assert_no_fail (result )
254190
@@ -371,6 +307,5 @@ def test_vlan_cancel_exception(self, confirm_mock):
371307 vlan_mock .return_value = {}
372308 result = self .run_command (['vlan' , 'cancel' , '1234' ])
373309 self .assertEqual (result .exit_code , 2 )
374- print (result .exception )
375310 self .assertIsInstance (result .exception , exceptions .CLIAbort )
376311 self .assertIn ("VLAN is an automatically assigned" , result .exception .message )
0 commit comments