Skip to content

Commit

Permalink
Merge "Remove six"
Browse files Browse the repository at this point in the history
  • Loading branch information
Zuul authored and openstack-gerrit committed Oct 1, 2020
2 parents dcdc095 + e1edbc4 commit daf530a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
6 changes: 2 additions & 4 deletions kuryr/lib/segmentation_type_drivers/vlan.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
# under the License.
import random

from six import moves

from kuryr.lib import constants as const
from kuryr.lib import exceptions

Expand All @@ -21,8 +19,8 @@

class SegmentationDriver(object):
def __init__(self):
self.available_local_vlans = set(moves.range(const.MIN_VLAN_TAG,
const.MAX_VLAN_TAG + 1))
self.available_local_vlans = set(range(const.MIN_VLAN_TAG,
const.MAX_VLAN_TAG + 1))

def allocate_segmentation_id(self, allocated_ids=set()):
self.available_local_vlans.difference_update(allocated_ids)
Expand Down
13 changes: 6 additions & 7 deletions kuryr/tests/unit/segmentation_type_drivers/test_vlan.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
from unittest import mock

from oslo_config import cfg
from six import moves

from kuryr.lib import constants as const
from kuryr.lib import exceptions
Expand All @@ -42,8 +41,8 @@ def test_allocate_segmentation_id(self):

def test_allocate_segmentation_id_only_1_available(self):
vlan_seg_driver = vlan.SegmentationDriver()
allocated_ids = set(moves.range(const.MIN_VLAN_TAG,
const.MAX_VLAN_TAG + 1))
allocated_ids = set(range(const.MIN_VLAN_TAG,
const.MAX_VLAN_TAG + 1))
allocated_ids.remove(const.MAX_VLAN_TAG)

vlan_id = vlan_seg_driver.allocate_segmentation_id(allocated_ids)
Expand All @@ -59,8 +58,8 @@ def test_allocate_segmentation_id_no_allocated_ids(self):

def test_allocate_segmentation_id_no_available_vlans(self):
vlan_seg_driver = vlan.SegmentationDriver()
allocated_ids = set(moves.range(const.MIN_VLAN_TAG,
const.MAX_VLAN_TAG + 1))
allocated_ids = set(range(const.MIN_VLAN_TAG,
const.MAX_VLAN_TAG + 1))

self.assertRaises(exceptions.SegmentationIdAllocationFailure,
vlan_seg_driver.allocate_segmentation_id,
Expand All @@ -80,7 +79,7 @@ def test_allocate_segmentation_id_max_retries(self, mock_choice):
@mock.patch('random.choice')
def test_allocate_segmentation_id_2_retries(self, mock_choice):
vlan_seg_driver = vlan.SegmentationDriver()
vlan_seg_driver.available_local_vlans = set(moves.range(1, 10))
vlan_seg_driver.available_local_vlans = set(range(1, 10))
allocated_ids = set([1, 2, 3])
mock_choice.side_effect = [1, 1, 5]

Expand All @@ -91,7 +90,7 @@ def test_allocate_segmentation_id_2_retries(self, mock_choice):

def test_release_segmentation_id(self):
vlan_seg_driver = vlan.SegmentationDriver()
vlan_seg_driver.available_local_vlans = set(moves.range(1, 10))
vlan_seg_driver.available_local_vlans = set(range(1, 10))
vlan_id = 20

vlan_seg_driver.release_segmentation_id(vlan_id)
Expand Down

0 comments on commit daf530a

Please sign in to comment.