Skip to content

Commit d2f4af2

Browse files
style: apply ruff format to tests/test_coverage_gaps.py
1 parent 5258441 commit d2f4af2

1 file changed

Lines changed: 17 additions & 4 deletions

File tree

tests/test_coverage_gaps.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ def test_audit_log_with_target_path(tmp_path):
4141
def test_audit_log_with_details(tmp_path):
4242
"""log() with details dict should include 'details' key in entry."""
4343
log = AuditLogger(str(tmp_path / "audit.log"))
44-
log.log("rotate", "API_KEY", details={"strategy": "source_wins", "old_prefix": "sk_"})
44+
log.log(
45+
"rotate", "API_KEY", details={"strategy": "source_wins", "old_prefix": "sk_"}
46+
)
4547
history = log.get_history()
4648
assert len(history) == 1
4749
assert history[0]["details"]["strategy"] == "source_wins"
@@ -64,7 +66,9 @@ def test_audit_log_malformed_line(tmp_path):
6466
"""get_history skips lines that are not valid JSON."""
6567
log_path = tmp_path / "audit.log"
6668
# Write a mix of valid and invalid lines
67-
log_path.write_text('{"action":"add","key":"K1"}\nnot-json\n{"action":"add","key":"K2"}\n')
69+
log_path.write_text(
70+
'{"action":"add","key":"K1"}\nnot-json\n{"action":"add","key":"K2"}\n'
71+
)
6872
log = AuditLogger(str(log_path))
6973
history = log.get_history()
7074
assert len(history) == 2 # Only the valid JSON lines
@@ -94,6 +98,7 @@ def test_config_load_empty_yaml(tmp_path):
9498
def test_config_get_store_existing(tmp_path):
9599
"""get_store() returns the store config when it exists."""
96100
from envault.config import SecretStoreConfig
101+
97102
config = EnvaultConfig()
98103
store_cfg = SecretStoreConfig(type="vault", url="http://vault:8200")
99104
config.stores["myvault"] = store_cfg
@@ -217,6 +222,7 @@ def test_rotate_env_var_special_chars_in_new_value(tmp_path):
217222
assert success
218223
# The file should still be parseable (key=value or key="value")
219224
from dotenv import dotenv_values
225+
220226
reloaded = dotenv_values(str(env_file))
221227
assert "WEBHOOK_URL" in reloaded
222228

@@ -236,7 +242,9 @@ def test_rotate_env_var_dry_run_with_audit(tmp_path):
236242
audit_log = str(tmp_path / "audit.log")
237243
audit = AuditLogger(audit_log)
238244

239-
success, new_val = rotate_env_var("DB_PASSWORD", str(env_file), dry_run=True, audit=audit)
245+
success, new_val = rotate_env_var(
246+
"DB_PASSWORD", str(env_file), dry_run=True, audit=audit
247+
)
240248
assert success
241249
assert new_val != "oldpass"
242250
# Dry run should NOT log audit
@@ -295,6 +303,7 @@ def test_to_json_parses():
295303
"""to_json should produce valid JSON that round-trips through to_dict."""
296304
result = diff_envs({"X": "1", "Y": "2"}, {"X": "1", "Y": "changed", "Z": "3"})
297305
import json
306+
298307
parsed = json.loads(result.to_json(source_label="s", target_label="t"))
299308
assert parsed["has_differences"] is True
300309
assert "Y" in parsed["different"]
@@ -307,14 +316,18 @@ def test_to_json_compact():
307316
compact = result.to_json(indent=None)
308317
assert "\n" not in compact
309318
import json
319+
310320
assert json.loads(compact)["has_differences"] is True
311321

312322

313323
def test_to_json_custom_labels():
314324
"""to_json should use custom source/target labels in the different dict."""
315325
result = diff_envs({"K": "old"}, {"K": "new"})
316326
import json
317-
parsed = json.loads(result.to_json(source_label="staging", target_label="production"))
327+
328+
parsed = json.loads(
329+
result.to_json(source_label="staging", target_label="production")
330+
)
318331
assert "staging" in parsed["different"]["K"]
319332
assert "production" in parsed["different"]["K"]
320333

0 commit comments

Comments
 (0)