Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4b3519b

Browse files
tox fixes
1 parent 18567ee commit 4b3519b

File tree

4 files changed

+8
-18
lines changed

4 files changed

+8
-18
lines changed

SoftLayer/CLI/formatting.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,6 @@ def set_empty_message(self, message):
335335
"""
336336
self.empty_message = message
337337

338-
339338
def add_row(self, row):
340339
"""Add a row to the table.
341340

SoftLayer/CLI/hardware/vlan_trunkable.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from SoftLayer.CLI import formatting
99
from SoftLayer.CLI import helpers
1010

11-
from pprint import pprint as pp
11+
1212
@click.command(cls=SoftLayer.CLI.command.SLCommand, )
1313
@click.argument('hardware')
1414
@environment.pass_env

SoftLayer/managers/hardware.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
LOGGER = logging.getLogger(__name__)
2222

2323
# Invalid names are ignored due to long method names and short argument names
24-
# pylint: disable=invalid-name, too-many-lines
24+
# pylint: disable=invalid-name, too-many-lines, too-many-public-methods
2525

2626
EXTRA_CATEGORIES = ['pri_ipv6_addresses',
2727
'static_ipv6_addresses',
@@ -1207,6 +1207,7 @@ def remove_vlan(self, component_id, vlans):
12071207
:param list vlans: list of SoftLayer_Network_Vlan objects to remove. Each object needs at least id or vlanNumber
12081208
"""
12091209
return self.client.call('SoftLayer_Network_Component', 'removeNetworkVlanTrunks', vlans, id=component_id)
1210+
12101211
def clear_vlan(self, hardware_id):
12111212
"""Clears all vlan trunks from a hardware_id
12121213
@@ -1219,14 +1220,14 @@ def clear_vlan(self, hardware_id):
12191220
"]"
12201221
)
12211222
components = self.client.call('SoftLayer_Hardware_Server', 'getObject', id=hardware_id, mask=component_mask)
1222-
back_component_id = utils.lookup(components, 'backendNetworkComponent', 'id')
1223-
front_component_id = utils.lookup(components, 'frontendNetworkComponent', 'id')
1223+
# We only want to call this API on components with actual trunks.
1224+
# Calling this on the primary and redundant components might cause exceptions.
12241225
for c in components.get('backendNetworkComponent', []):
12251226
if len(c.get('networkVlanTrunks')):
12261227
self.client.call('SoftLayer_Network_Component', 'clearNetworkVlanTrunks', id=c.get('id'))
12271228
for c in components.get('frontendNetworkComponent', []):
12281229
if len(c.get('networkVlanTrunks')):
1229-
self.client.call('SoftLayer_Network_Component', 'clearNetworkVlanTrunks', id=c.get('id'))
1230+
self.client.call('SoftLayer_Network_Component', 'clearNetworkVlanTrunks', id=c.get('id'))
12301231

12311232
def get_sensors(self, hardware_id):
12321233
"""Returns Hardware sensor data"""

tests/CLI/formatting_table_tests.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,12 @@
44
55
:license: MIT, see LICENSE for more details.
66
"""
7-
import json
8-
import os
9-
import sys
10-
import tempfile
117

12-
import click
13-
from rich.table import Table
14-
from unittest import mock as mock
15-
16-
from SoftLayer.CLI import core
178
from SoftLayer.CLI import exceptions
189
from SoftLayer.CLI import formatting
19-
from SoftLayer.CLI import helpers
20-
from SoftLayer.CLI import template
2110
from SoftLayer import testing
2211

12+
2313
class TestTable(testing.TestCase):
2414

2515
def test_table_with_duplicated_columns(self):
@@ -69,4 +59,4 @@ def test_format_api_list_with_empty_array(self):
6959
formatted = formatting.format_output(result, "table")
7060
# No good ways to test whats actually in a Rich.Table without going through the hassel of
7161
# printing it out. As long as this didn't throw and exception it should be fine.
72-
self.assertEqual(formatted.row_count, 1)
62+
self.assertEqual(formatted.row_count, 1)

0 commit comments

Comments
 (0)