Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 0058872

Browse files
committedSep 27, 2024·
Add new test, and update some types
1 parent 294aa78 commit 0058872

File tree

2 files changed

+20
-12
lines changed

2 files changed

+20
-12
lines changed
 

‎tests/unit/test_api.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from molecule import api
2424

2525

26-
def test_api_drivers(): # type: ignore[no-untyped-def] # noqa: ANN201, D103
26+
def test_api_drivers() -> None: # noqa: D103
2727
results = api.drivers()
2828

2929
for result in results.values():
@@ -32,7 +32,7 @@ def test_api_drivers(): # type: ignore[no-untyped-def] # noqa: ANN201, D103
3232
assert "default" in results
3333

3434

35-
def test_api_verifiers(): # type: ignore[no-untyped-def] # noqa: ANN201, D103
35+
def test_api_verifiers() -> None: # noqa: D103
3636
x = ["testinfra", "ansible"]
3737

3838
assert all(elem in api.verifiers() for elem in x)

‎tests/unit/test_config.py

+18-10
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,15 @@ def test_verifier_property_is_ansible(config_instance: config.Config): # type:
154154
assert isinstance(config_instance.verifier, AnsibleVerifier)
155155

156156

157-
def test_get_driver_name_from_state_file(config_instance: config.Config, mocker): # type: ignore[no-untyped-def] # noqa: ANN001, ANN201, D103
157+
def test_verifier_property_invalid(config_instance: config.Config) -> None: # noqa: D103
158+
config_instance.config["verifier"]["name"] = "missing"
159+
del config_instance.verifier
160+
161+
with pytest.raises(RuntimeError, match="Unable to find 'missing' verifier driver."):
162+
config_instance.verifier # noqa: B018
163+
164+
165+
def test_get_driver_name_from_state_file(config_instance: config.Config, mocker) -> None: # type: ignore[no-untyped-def] # noqa: ANN001, D103
158166
config_instance.state.change_state("driver", "state-driver")
159167

160168
with pytest.raises(SystemExit):
@@ -164,20 +172,20 @@ def test_get_driver_name_from_state_file(config_instance: config.Config, mocker)
164172
assert config_instance._get_driver_name() == "state-driver" # type: ignore[no-untyped-call]
165173

166174

167-
def test_get_driver_name_from_cli(config_instance: config.Config): # type: ignore[no-untyped-def] # noqa: ANN201, D103
175+
def test_get_driver_name_from_cli(config_instance: config.Config) -> None: # noqa: D103
168176
config_instance.command_args = {"driver_name": "cli-driver"}
169177

170178
assert config_instance._get_driver_name() == "cli-driver" # type: ignore[no-untyped-call]
171179

172180

173-
def test_get_driver_name(config_instance: config.Config): # type: ignore[no-untyped-def] # noqa: ANN201, D103
181+
def test_get_driver_name(config_instance: config.Config) -> None: # noqa: D103
174182
assert config_instance._get_driver_name() == "default" # type: ignore[no-untyped-call]
175183

176184

177-
def test_get_driver_name_raises_when_different_driver_used( # type: ignore[no-untyped-def] # noqa: ANN201, D103
185+
def test_get_driver_name_raises_when_different_driver_used( # noqa: D103
178186
caplog: pytest.LogCaptureFixture,
179187
config_instance: config.Config,
180-
):
188+
) -> None:
181189
config_instance.state.change_state("driver", "foo")
182190
config_instance.command_args = {"driver_name": "bar"}
183191
with pytest.raises(SystemExit) as e:
@@ -218,7 +226,7 @@ def test_get_config_with_multiple_base_configs(config_instance: config.Config):
218226
assert result["foo2"] == "bar2"
219227

220228

221-
def test_reget_config(config_instance: config.Config): # type: ignore[no-untyped-def] # noqa: ANN201, D103
229+
def test_reget_config(config_instance: config.Config) -> None: # noqa: D103
222230
assert isinstance(config_instance._reget_config(), dict) # type: ignore[no-untyped-call]
223231

224232

@@ -293,11 +301,11 @@ def test_get_defaults(config_instance: config.Config, mocker): # type: ignore[n
293301
assert defaults["scenario"]["name"] == "test_scenario_name"
294302

295303

296-
def test_validate( # type: ignore[no-untyped-def] # noqa: ANN201, D103
304+
def test_validate( # type: ignore[no-untyped-def] # noqa: D103
297305
mocker: MockerFixture,
298306
config_instance: config.Config,
299307
patched_logger_debug, # noqa: ANN001
300-
):
308+
) -> None:
301309
m = mocker.patch("molecule.model.schema_v3.validate")
302310
m.return_value = None
303311

@@ -308,11 +316,11 @@ def test_validate( # type: ignore[no-untyped-def] # noqa: ANN201, D103
308316
m.assert_called_with(config_instance.config)
309317

310318

311-
def test_validate_exists_when_validation_fails( # type: ignore[no-untyped-def] # noqa: ANN201, D103
319+
def test_validate_exists_when_validation_fails( # noqa: D103
312320
mocker: MockerFixture,
313321
caplog: pytest.LogCaptureFixture,
314322
config_instance: config.Config,
315-
):
323+
) -> None:
316324
m = mocker.patch("molecule.model.schema_v3.validate")
317325
m.return_value = "validation errors"
318326

0 commit comments

Comments
 (0)
Please sign in to comment.