Skip to content

Commit 633015b

Browse files
authored
Merge pull request #69 from m-misiura/fix_tests_built_in
Changing error handling in `test_filetype.py`
2 parents 4b26af2 + 7809f7c commit 633015b

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

tests/detectors/builtIn/test_filetype.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -289,18 +289,17 @@ def test_multiple_filetype_valid_and_invalid(self, client: TestClient):
289289

290290
# === ERROR HANDLING & INVALID DETECTOR TYPES =================================================
291291
def test_unregistered_detector_kind_ignored(self, client: TestClient):
292-
"""Test that requesting an unregistered detector kind is silently ignored"""
292+
"""Test that requesting an unregistered detector kind returns 400 error"""
293293
payload = {
294294
"contents": ['{"a": 1}'],
295295
"detector_params": {"nonexistent_detector": ["some_value"]}
296296
}
297297
resp = client.post("/api/v1/text/contents", json=payload)
298-
assert resp.status_code == 200
299-
# Should return empty list since nonexistent_detector is not registered
300-
assert resp.json()[0] == []
298+
# Should return 400 error since nonexistent_detector is not registered
299+
assert resp.status_code == 400
301300

302301
def test_mixed_valid_invalid_detector_kinds(self, client: TestClient):
303-
"""Test mixing valid and invalid detector kinds"""
302+
"""Test mixing valid and invalid detector kinds returns 400 error"""
304303
payload = {
305304
"contents": ['{a: 1, b: 2}'],
306305
"detector_params": {
@@ -309,10 +308,8 @@ def test_mixed_valid_invalid_detector_kinds(self, client: TestClient):
309308
}
310309
}
311310
resp = client.post("/api/v1/text/contents", json=payload)
312-
assert resp.status_code == 200
313-
detections = resp.json()[0]
314-
# Should only process the valid detector kind
315-
assert detections[0]["detection"] == "invalid_json"
311+
# Should return 400 error for the unregistered detector
312+
assert resp.status_code == 400
316313

317314
def test_empty_detector_params(self, client: TestClient):
318315
"""Test with empty detector_params"""

0 commit comments

Comments
 (0)