Skip to content

Commit 74f1bb5

Browse files
committed
fixing test
1 parent c203821 commit 74f1bb5

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

tests/test_folder_validator.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,27 +37,32 @@ def test_validate_folder_all_valid(temp_policy_dir):
3737
(temp_policy_dir / "valid2.json").write_text(VALID_POLICY)
3838

3939
result = validate_policy_folder(str(temp_policy_dir))
40-
assert result == 0 # all valid, should pass
40+
assert result == [] # all valid, no findings
4141

4242
def test_validate_folder_some_invalid(temp_policy_dir):
4343
(temp_policy_dir / "good.json").write_text(VALID_POLICY)
4444
(temp_policy_dir / "bad.json").write_text(INVALID_POLICY)
4545

4646
result = validate_policy_folder(str(temp_policy_dir))
47-
assert result == 1 # one invalid
47+
assert any(f["level"] == "high" for f in result)
48+
assert any("wildcard" in f["message"] for f in result)
4849

4950
def test_validate_folder_empty(temp_policy_dir):
5051
result = validate_policy_folder(str(temp_policy_dir))
51-
assert result == 1 # no policy files
52+
assert len(result) == 1
53+
assert result[0]["level"] == "warning"
54+
assert "No policy files found" in result[0]["message"]
5255

5356
def test_validate_folder_not_exist():
5457
result = validate_policy_folder("non_existent_folder_123")
55-
assert result == 1 # should gracefully error out
58+
assert len(result) == 1
59+
assert result[0]["level"] == "error"
60+
assert "not found" in result[0]["message"]
5661

5762
def test_folder_with_malformed_json(tmp_path):
5863
(tmp_path / "bad.json").write_text('{"Version": "2012-10-17", "Statement": [INVALID_JSON')
5964
result = validate_policy_folder(str(tmp_path))
60-
assert result == 1 # should catch parse failure
65+
assert any("failed" in f["message"] for f in result)
6166

6267
def test_folder_with_yaml_file(tmp_path):
6368
good_yaml = """
@@ -69,7 +74,7 @@ def test_folder_with_yaml_file(tmp_path):
6974
"""
7075
(tmp_path / "good.yaml").write_text(good_yaml)
7176
result = validate_policy_folder(str(tmp_path))
72-
assert result == 0 # valid YAML should pass
77+
assert result == [] # no findings
7378

7479
def test_folder_with_good_and_bad_files(tmp_path):
7580
good = {
@@ -79,4 +84,4 @@ def test_folder_with_good_and_bad_files(tmp_path):
7984
(tmp_path / "good.json").write_text(json.dumps(good))
8085
(tmp_path / "broken.json").write_text('INVALID')
8186
result = validate_policy_folder(str(tmp_path))
82-
assert result == 1 # one fails, so exit code should be 1
87+
assert any("failed" in f["message"] for f in result)

0 commit comments

Comments
 (0)