test(exam): replace StorageAdmin with fake class in scan tests
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
5ad9c01cde
commit
a1d297ac30
@ -251,8 +251,7 @@ def test_scan_rejects_non_pdf_mime():
|
|||||||
assert r.status_code == 415
|
assert r.status_code == 415
|
||||||
|
|
||||||
|
|
||||||
def test_scan_rejects_spoofed_pdf(monkeypatch):
|
def test_scan_rejects_spoofed_pdf():
|
||||||
monkeypatch.setattr(batches_mod.StorageAdmin, "upload_file", lambda *a, **k: None, raising=False)
|
|
||||||
c = make_client(_batch_store())
|
c = make_client(_batch_store())
|
||||||
r = c.post("/api/exam/batches/b1/scans", files={"file": ("x.pdf", b"not really a pdf", "application/pdf")}, data={"matching_method": "manual"})
|
r = c.post("/api/exam/batches/b1/scans", files={"file": ("x.pdf", b"not really a pdf", "application/pdf")}, data={"matching_method": "manual"})
|
||||||
assert r.status_code == 415 # magic-byte sniff
|
assert r.status_code == 415 # magic-byte sniff
|
||||||
@ -265,8 +264,13 @@ def test_scan_rejects_oversize(monkeypatch):
|
|||||||
assert r.status_code == 413
|
assert r.status_code == 413
|
||||||
|
|
||||||
|
|
||||||
|
class _FakeStorage:
|
||||||
|
def upload_file(self, *a, **k):
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
def test_scan_manual_match_happy(monkeypatch):
|
def test_scan_manual_match_happy(monkeypatch):
|
||||||
monkeypatch.setattr(batches_mod.StorageAdmin, "upload_file", lambda self, *a, **k: None, raising=False)
|
monkeypatch.setattr(batches_mod, "StorageAdmin", _FakeStorage)
|
||||||
store = _batch_store()
|
store = _batch_store()
|
||||||
c = make_client(store)
|
c = make_client(store)
|
||||||
r = c.post("/api/exam/batches/b1/scans",
|
r = c.post("/api/exam/batches/b1/scans",
|
||||||
@ -279,7 +283,7 @@ def test_scan_manual_match_happy(monkeypatch):
|
|||||||
|
|
||||||
|
|
||||||
def test_scan_denied_for_non_owner(monkeypatch):
|
def test_scan_denied_for_non_owner(monkeypatch):
|
||||||
monkeypatch.setattr(batches_mod.StorageAdmin, "upload_file", lambda self, *a, **k: None, raising=False)
|
monkeypatch.setattr(batches_mod, "StorageAdmin", _FakeStorage)
|
||||||
store = _batch_store()
|
store = _batch_store()
|
||||||
c = make_client(store, user_id="someone-else")
|
c = make_client(store, user_id="someone-else")
|
||||||
r = c.post("/api/exam/batches/b1/scans", files={"file": ("x.pdf", b"%PDF-1.7", "application/pdf")}, data={"matching_method": "manual"})
|
r = c.post("/api/exam/batches/b1/scans", files={"file": ("x.pdf", b"%PDF-1.7", "application/pdf")}, data={"matching_method": "manual"})
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user