1+ """Tests for Azure Keyvault support."""
2+
3+ # ruff: noqa: D101,D102,D103,D107,E501
4+
15from collections import namedtuple
2- import pytest
3- from pytest import raises
46
7+ import pytest
58from config import config_from_dict
9+ from pytest import raises
610
711try :
8- from config .contrib .azure import AzureKeyVaultConfiguration
912 from azure .core .exceptions import ResourceNotFoundError
13+ from config .contrib .azure import AzureKeyVaultConfiguration
14+
1015 azure = True
1116except ImportError : # pragma: no cover
1217 azure = None # type: ignore
@@ -51,7 +56,10 @@ def list_properties_of_secrets(self) -> list:
5156@pytest .mark .skipif ("azure is None" )
5257def test_load_dict (): # type: ignore
5358 cfg = AzureKeyVaultConfiguration (
54- "fake_id" , "fake_secret" , "fake-tenant" , "fake_vault"
59+ "fake_id" ,
60+ "fake_secret" ,
61+ "fake-tenant" ,
62+ "fake_vault" ,
5563 )
5664 cfg ._kv_client = FakeSecretClient (DICT )
5765 assert cfg ["foo" ] == "foo_val"
@@ -63,7 +71,10 @@ def test_load_dict(): # type: ignore
6371def test_expiration (mocker ): # type: ignore
6472 # with cache
6573 cfg = AzureKeyVaultConfiguration (
66- "fake_id" , "fake_secret" , "fake-tenant" , "fake_vault"
74+ "fake_id" ,
75+ "fake_secret" ,
76+ "fake-tenant" ,
77+ "fake_vault" ,
6778 )
6879 cfg ._kv_client = FakeSecretClient (DICT )
6980
@@ -74,7 +85,11 @@ def test_expiration(mocker): # type: ignore
7485
7586 # without cache
7687 cfg = AzureKeyVaultConfiguration (
77- "fake_id" , "fake_secret" , "fake-tenant" , "fake_vault" , cache_expiration = 0
88+ "fake_id" ,
89+ "fake_secret" ,
90+ "fake-tenant" ,
91+ "fake_vault" ,
92+ cache_expiration = 0 ,
7893 )
7994 cfg ._kv_client = FakeSecretClient (DICT )
8095
@@ -87,7 +102,11 @@ def test_expiration(mocker): # type: ignore
87102@pytest .mark .skipif ("azure is None" )
88103def test_deletion (): # type: ignore
89104 cfg = AzureKeyVaultConfiguration (
90- "fake_id" , "fake_secret" , "fake-tenant" , "fake_vault" , cache_expiration = 0
105+ "fake_id" ,
106+ "fake_secret" ,
107+ "fake-tenant" ,
108+ "fake_vault" ,
109+ cache_expiration = 0 ,
91110 )
92111 d = DICT .copy ()
93112 cfg ._kv_client = FakeSecretClient (d )
@@ -103,7 +122,11 @@ def test_deletion(): # type: ignore
103122@pytest .mark .skipif ("azure is None" )
104123def test_missing_key (): # type: ignore
105124 cfg = AzureKeyVaultConfiguration (
106- "fake_id" , "fake_secret" , "fake-tenant" , "fake_vault" , cache_expiration = 0
125+ "fake_id" ,
126+ "fake_secret" ,
127+ "fake-tenant" ,
128+ "fake_vault" ,
129+ cache_expiration = 0 ,
107130 )
108131 d = DICT .copy ()
109132 cfg ._kv_client = FakeSecretClient (d )
@@ -117,7 +140,11 @@ def test_missing_key(): # type: ignore
117140@pytest .mark .skipif ("azure is None" )
118141def test_get_attr (): # type: ignore
119142 cfg = AzureKeyVaultConfiguration (
120- "fake_id" , "fake_secret" , "fake-tenant" , "fake_vault" , cache_expiration = 0
143+ "fake_id" ,
144+ "fake_secret" ,
145+ "fake-tenant" ,
146+ "fake_vault" ,
147+ cache_expiration = 0 ,
121148 )
122149 d = DICT .copy ()
123150 cfg ._kv_client = FakeSecretClient (d )
@@ -131,7 +158,11 @@ def test_get_attr(): # type: ignore
131158@pytest .mark .skipif ("azure is None" )
132159def test_dict (): # type: ignore
133160 cfg = AzureKeyVaultConfiguration (
134- "fake_id" , "fake_secret" , "fake-tenant" , "fake_vault" , cache_expiration = 0
161+ "fake_id" ,
162+ "fake_secret" ,
163+ "fake-tenant" ,
164+ "fake_vault" ,
165+ cache_expiration = 0 ,
135166 )
136167 d = DICT .copy ()
137168 cfg ._kv_client = FakeSecretClient (d )
@@ -144,7 +175,11 @@ def test_dict(): # type: ignore
144175@pytest .mark .skipif ("azure is None" )
145176def test_repr (): # type: ignore
146177 cfg = AzureKeyVaultConfiguration (
147- "fake_id" , "fake_secret" , "fake-tenant" , "fake_vault" , cache_expiration = 0
178+ "fake_id" ,
179+ "fake_secret" ,
180+ "fake-tenant" ,
181+ "fake_vault" ,
182+ cache_expiration = 0 ,
148183 )
149184 d = DICT .copy ()
150185 cfg ._kv_client = FakeSecretClient (d )
@@ -155,7 +190,11 @@ def test_repr(): # type: ignore
155190@pytest .mark .skipif ("azure is None" )
156191def test_str (): # type: ignore
157192 cfg = AzureKeyVaultConfiguration (
158- "fake_id" , "fake_secret" , "fake-tenant" , "fake_vault" , cache_expiration = 0
193+ "fake_id" ,
194+ "fake_secret" ,
195+ "fake-tenant" ,
196+ "fake_vault" ,
197+ cache_expiration = 0 ,
159198 )
160199 d = DICT .copy ()
161200 cfg ._kv_client = FakeSecretClient (d )
@@ -171,7 +210,10 @@ def test_str(): # type: ignore
171210@pytest .mark .skipif ("azure is None" )
172211def test_reload (): # type: ignore
173212 cfg = AzureKeyVaultConfiguration (
174- "fake_id" , "fake_secret" , "fake-tenant" , "fake_vault"
213+ "fake_id" ,
214+ "fake_secret" ,
215+ "fake-tenant" ,
216+ "fake_vault" ,
175217 )
176218 cfg ._kv_client = FakeSecretClient (DICT )
177219 assert cfg == config_from_dict (DICT )
0 commit comments