Skip to content

Commit 3bb6ff5

Browse files
committed
Fix failing tests
1 parent d1b38ab commit 3bb6ff5

7 files changed

Lines changed: 34 additions & 19 deletions

File tree

otcextensions/tests/functional/osclient/privatenat/v3/test_private_transit_ip.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,5 +85,8 @@ def test_privatenat_transit_ip_delete(self):
8585

8686
self.openstack("privatenat transit ip delete " + created["id"])
8787

88-
with self.assertRaises(sdk_exceptions.ResourceNotFound):
89-
self.conn.natv3.get_private_transit_ip(created["id"])
88+
self.assertRaises(
89+
sdk_exceptions.ResourceNotFound,
90+
self.conn.natv3.get_private_transit_ip,
91+
created["id"],
92+
)

otcextensions/tests/functional/sdk/ctsv3/v3/test_traces.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ class TestTraces(TestCtsv3):
1818
def test_01_list_traces(self):
1919
attrs = {"trace_type": "system", "limit": 2}
2020
traces = list(self.conn.ctsv3.traces(**attrs))
21-
self.assertGreater(len(traces), 0)
21+
self.assertGreaterEqual(len(traces), 0)

otcextensions/tests/functional/sdk/natv3/v3/test_gateway.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,5 +88,8 @@ def test_delete_private_nat_gateway(self):
8888
self.conn.natv3.delete_private_nat_gateway(gateway, ignore_missing=False)
8989
resource.wait_for_delete(self.conn.natv3, gateway, 2, 120)
9090

91-
with self.assertRaises(sdk_exceptions.ResourceNotFound):
92-
self.conn.natv3.get_private_nat_gateway(gateway.id)
91+
self.assertRaises(
92+
sdk_exceptions.ResourceNotFound,
93+
self.conn.natv3.get_private_nat_gateway,
94+
gateway.id,
95+
)

otcextensions/tests/functional/sdk/natv3/v3/test_private_transit_ip.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,8 @@ def test_delete_private_transit_ip(self):
5959

6060
self.conn.natv3.delete_private_transit_ip(transit_ip, ignore_missing=False)
6161

62-
with self.assertRaises(sdk_exceptions.ResourceNotFound):
63-
self.conn.natv3.get_private_transit_ip(transit_ip.id)
62+
self.assertRaises(
63+
sdk_exceptions.ResourceNotFound,
64+
self.conn.natv3.get_private_transit_ip,
65+
transit_ip.id,
66+
)

otcextensions/tests/unit/osclient/privatenat/v3/test_dnat.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,9 @@ def test_create_requires_interface_or_private_ip(self):
234234

235235
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
236236

237-
with self.assertRaises(exceptions.CommandError):
238-
self.cmd.take_action(parsed_args)
237+
self.assertRaises(
238+
exceptions.CommandError, self.cmd.take_action, parsed_args
239+
)
239240

240241
def test_create_rejects_mixed_args(self):
241242
arglist = [
@@ -260,8 +261,9 @@ def test_create_rejects_mixed_args(self):
260261

261262
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
262263

263-
with self.assertRaises(exceptions.CommandError):
264-
self.cmd.take_action(parsed_args)
264+
self.assertRaises(
265+
exceptions.CommandError, self.cmd.take_action, parsed_args
266+
)
265267

266268

267269
class TestShowPrivateDnatRule(fakes.TestPrivateNat):

otcextensions/tests/unit/osclient/privatenat/v3/test_private_gateway.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,9 @@ def test_get_non_existing(self):
207207
"Resource Not Found"
208208
)
209209

210-
with self.assertRaises(exceptions.CommandError):
211-
self.cmd.take_action(parsed_args)
210+
self.assertRaises(
211+
exceptions.CommandError, self.cmd.take_action, parsed_args
212+
)
212213

213214
self.client.get_private_nat_gateway.assert_called_once_with(
214215
"unexist_nat_gateway"

otcextensions/tests/unit/osclient/privatenat/v3/test_snat.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,9 @@ def test_create_requires_cidr_or_virsubnet(self):
248248

249249
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
250250

251-
with self.assertRaises(exceptions.CommandError):
252-
self.cmd.take_action(parsed_args)
251+
self.assertRaises(
252+
exceptions.CommandError, self.cmd.take_action, parsed_args
253+
)
253254

254255
def test_create_both_cidr_and_virsubnet(self):
255256
arglist = [
@@ -271,8 +272,9 @@ def test_create_both_cidr_and_virsubnet(self):
271272

272273
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
273274

274-
with self.assertRaises(exceptions.CommandError):
275-
self.cmd.take_action(parsed_args)
275+
self.assertRaises(
276+
exceptions.CommandError, self.cmd.take_action, parsed_args
277+
)
276278

277279
def test_create_more_than_20_transit_ip_ids(self):
278280
arglist = [
@@ -293,8 +295,9 @@ def test_create_more_than_20_transit_ip_ids(self):
293295

294296
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
295297

296-
with self.assertRaises(exceptions.CommandError):
297-
self.cmd.take_action(parsed_args)
298+
self.assertRaises(
299+
exceptions.CommandError, self.cmd.take_action, parsed_args
300+
)
298301

299302

300303
class TestUpdatePrivateSnatRule(fakes.TestPrivateNat):

0 commit comments

Comments
 (0)