Skip to content

Commit 7ff666d

Browse files
committed
fix unitests
1 parent eb97a85 commit 7ff666d

File tree

4 files changed

+28
-13
lines changed

4 files changed

+28
-13
lines changed

async_hvac/tests/test_approle_routes.py

+24-9
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
class TestApproleRoutes(TestCase):
1010
"""Unit tests providing coverage for approle auth backend-related methods/routes."""
1111

12+
13+
1214
@parameterized.expand([
1315
("default mount point", None, "application1"),
1416
("custom mount point", "my-approle-path", "application2"),
@@ -40,6 +42,7 @@ async def test_create_role(self, test_label, mount_point, role_name, requests_mo
4042
first=expected_status_code,
4143
second=actual_response.status,
4244
)
45+
await client.close()
4346

4447
@parameterized.expand([
4548
("default mount point", None, "application1"),
@@ -81,6 +84,7 @@ async def test_list_roles(self, test_label, mount_point, role_name, requests_moc
8184

8285
# ensure we received our mock response data back successfully
8386
self.assertEqual(mock_response, actual_response)
87+
await client.close()
8488

8589
@parameterized.expand([
8690
("default mount point", None, "application1", "40b3c82d-12a6-838c-9e74-1f1133867e06"),
@@ -127,6 +131,7 @@ async def test_get_role_id(self, test_label, mount_point, role_name, role_id, re
127131
first=role_id,
128132
second=actual_response
129133
)
134+
await client.close()
130135

131136
@parameterized.expand([
132137
("default mount point", None, "application1", "custom-role-id-1"),
@@ -157,10 +162,11 @@ async def test_set_role_id(self, test_label, mount_point, role_name, role_id, re
157162
mount_point=mount_point,
158163
)
159164

160-
self.assertEquals(
165+
self.assertEqual(
161166
first=expected_status_code,
162167
second=actual_response.status,
163168
)
169+
await client.close()
164170

165171
@parameterized.expand([
166172
("default mount point", None, "application1"),
@@ -212,10 +218,11 @@ async def test_get_role(self, test_label, mount_point, role_name, requests_mocke
212218
mount_point=mount_point,
213219
)
214220

215-
self.assertEquals(
221+
self.assertEqual(
216222
first=mock_response,
217223
second=actual_response,
218224
)
225+
await client.close()
219226

220227
@parameterized.expand([
221228
("default mount point", None, "application1"),
@@ -259,10 +266,11 @@ async def test_create_role_secret_id(self, test_label, mount_point, role_name, r
259266
mount_point=mount_point,
260267
)
261268

262-
self.assertEquals(
269+
self.assertEqual(
263270
first=mock_response,
264271
second=actual_response,
265272
)
273+
await client.close()
266274

267275
@parameterized.expand([
268276
("default mount point", None, "application1", "be78e3ca-f644-b099-3291-e8a6f5985cfe"),
@@ -314,10 +322,11 @@ async def test_get_role_secret_id(self, test_label, mount_point, role_name, secr
314322
mount_point=mount_point,
315323
)
316324

317-
self.assertEquals(
325+
self.assertEqual(
318326
first=mock_response,
319327
second=actual_response,
320328
)
329+
await client.close()
321330

322331
@parameterized.expand([
323332
("default mount point", None, "application1", "be78e3ca-f644-b099-3291-e8a6f5985cfe"),
@@ -362,10 +371,11 @@ async def test_list_role_secrets(self, test_label, mount_point, role_name, secre
362371
mount_point=mount_point,
363372
)
364373

365-
self.assertEquals(
374+
self.assertEqual(
366375
first=mock_response,
367376
second=actual_response,
368377
)
378+
await client.close()
369379

370380
@parameterized.expand([
371381
("default mount point", None, "application1", "be78e3ca-f644-b099-3291-e8a6f5985cfe"),
@@ -417,10 +427,11 @@ async def test_get_role_secret_id_accessor(self, test_label, mount_point, role_n
417427
mount_point=mount_point,
418428
)
419429

420-
self.assertEquals(
430+
self.assertEqual(
421431
first=mock_response,
422432
second=actual_response,
423433
)
434+
await client.close()
424435

425436
@parameterized.expand([
426437
("default mount point", None, "application1", "be78e3ca-f644-b099-3291-e8a6f5985cfe"),
@@ -452,10 +463,11 @@ async def test_delete_role_secret_id(self, test_label, mount_point, role_name, s
452463
mount_point=mount_point,
453464
)
454465

455-
self.assertEquals(
466+
self.assertEqual(
456467
first=expected_status_code,
457468
second=actual_response.status,
458469
)
470+
await client.close()
459471

460472
@parameterized.expand([
461473
("default mount point", None, "application1", "be78e3ca-f644-b099-3291-e8a6f5985cfe"),
@@ -488,10 +500,11 @@ async def test_delete_role_secret_id_accessor(self, test_label, mount_point, rol
488500
mount_point=mount_point,
489501
)
490502

491-
self.assertEquals(
503+
self.assertEqual(
492504
first=expected_status_code,
493505
second=actual_response.status,
494506
)
507+
await client.close()
495508

496509
@parameterized.expand([
497510
("default mount point", None, "application1", "be78e3ca-f644-b099-3291-e8a6f5985cfe"),
@@ -536,10 +549,11 @@ async def test_create_role_custom_secret_id(self, test_label, mount_point, role_
536549
mount_point=mount_point,
537550
)
538551

539-
self.assertEquals(
552+
self.assertEqual(
540553
first=mock_response,
541554
second=actual_response,
542555
)
556+
await client.close()
543557

544558
@parameterized.expand([
545559
("default mount point", None, "c7f93182-c6b1-4b6a-9dfb-03bdb6df0026", "26089502-b7d3-412a-b3e6-3d44300f9bd1"),
@@ -595,3 +609,4 @@ async def test_auth_approle(self, test_label, mount_point, role_id, secret_id, r
595609
first=mock_response,
596610
second=actual_response,
597611
)
612+
await client.close()

async_hvac/tests/test_auth_methods.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ async def test_tune_auth_backend(self, requests_mocker):
3030
second=actual_response.status,
3131
)
3232

33-
actual_request_params = requests_mocker.request_history[0].json()
33+
actual_request_params = requests_mocker.requests[
34+
('post', 'http://127.0.0.1:8200/v1/sys/auth/{0}/tune'.format(test_mount_point))][0].kwargs['json']
3435

3536
# Ensure we sent through an optional tune parameter as expected
3637
self.assertEqual(

async_hvac/tests/util.py

-2
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ def match_version(spec):
9797
class RequestsMocker(aioresponses):
9898

9999
def __init__(self):
100-
self.request_history = []
101100
super(RequestsMocker, self).__init__()
102101

103102
def register_uri(self, method='GET', url='', status_code=200, json=None):
@@ -111,4 +110,3 @@ def register_uri(self, method='GET', url='', status_code=200, json=None):
111110
req = self.post(url=url, status=status_code, body=json)
112111
if method == 'DELETE':
113112
req = self.delete(url=url, status=status_code, body=json)
114-
self.request_history.append(req)

requirements-dev.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ semantic_version
66
avakas
77
requests-mock
88
aioresponses
9-
mock
9+
mock
10+
parameterized

0 commit comments

Comments
 (0)