Use setUp() method for neutron rest test

There is no reason to override the setUpClass() in the test
case. For data setup, the setUp() should be used.

There is also an issue where the code is not calling super()
class, this issue is exposed when running the test in django18.

Closes-Bug: #1481143
Partially Implements: blueprint django18

Change-Id: Ic64cc0a5f0c7d0476bfac63b6e23fe8a1461d6ef
This commit is contained in:
lin-hua-cheng 2015-08-03 20:33:59 -07:00
parent 90636a3a54
commit a354f016ab

View File

@ -27,10 +27,10 @@ TEST = TestData(neutron_data.data)
class NeutronNetworksTestCase(test.TestCase):
@classmethod
def setUpClass(cls):
cls._networks = [mock_factory(n)
for n in TEST.api_networks.list()]
def setUp(self):
super(NeutronNetworksTestCase, self).setUp()
self._networks = [mock_factory(n)
for n in TEST.api_networks.list()]
@mock.patch.object(neutron.api, 'neutron')
def test_get_list_for_tenant(self, client):
@ -71,12 +71,12 @@ class NeutronNetworksTestCase(test.TestCase):
class NeutronSubnetsTestCase(test.TestCase):
@classmethod
def setUpClass(cls):
cls._networks = [mock_factory(n)
for n in TEST.api_networks.list()]
cls._subnets = [mock_factory(n)
for n in TEST.api_subnets.list()]
def setUp(self):
super(NeutronSubnetsTestCase, self).setUp()
self._networks = [mock_factory(n)
for n in TEST.api_networks.list()]
self._subnets = [mock_factory(n)
for n in TEST.api_subnets.list()]
@mock.patch.object(neutron.api, 'neutron')
def test_get(self, client):
@ -105,12 +105,12 @@ class NeutronSubnetsTestCase(test.TestCase):
class NeutronPortsTestCase(test.TestCase):
@classmethod
def setUpClass(cls):
cls._networks = [mock_factory(n)
for n in TEST.api_networks.list()]
cls._ports = [mock_factory(n)
for n in TEST.api_ports.list()]
def setUp(self):
super(NeutronPortsTestCase, self).setUp()
self._networks = [mock_factory(n)
for n in TEST.api_networks.list()]
self._ports = [mock_factory(n)
for n in TEST.api_ports.list()]
@mock.patch.object(neutron.api, 'neutron')
def test_get(self, client):