test: Edge-Case-Dateien + Tests (leer/gross/verschluesselt/Sonderzeichen)
/testdata/edge/: empty.txt, leer.bin (0 Byte), Name mit Umlauten+Leerzeichen+ Klammern, Unicode/Emoji/RTL-Inhalt, Datei ohne Endung, passwortgeschuetztes PDF (pikepdf) + ZIP, riesig.dat (26 MB > MAX_BIN_SIZE). TestFileEdgeCases prueft graceful Handling (kein Crash, 'Datei zu gross', PDF-Lesefehler sauber gemeldet). gen_edge.py + upload_ocis.sh erweitert. 76 Tests gruen.
This commit is contained in:
@@ -455,3 +455,49 @@ class TestFileTypes:
|
||||
{"name": "read_file", "arguments": {"path": path}})
|
||||
types = {c["type"] for c in result["result"]["content"]}
|
||||
assert types & expected, f"{path}: erwartet eins von {expected}, bekam {types}"
|
||||
|
||||
|
||||
# ============================================================
|
||||
# File Edge Cases (leere/grosse/verschluesselte/Sonderzeichen-Dateien)
|
||||
# ============================================================
|
||||
|
||||
class TestFileEdgeCases:
|
||||
PORT = SERVERS["files"]
|
||||
|
||||
def _read(self, path):
|
||||
token = get_token(self.PORT)
|
||||
r = mcp_call(self.PORT, token, "tools/call",
|
||||
{"name": "read_file", "arguments": {"path": path}})
|
||||
return r["result"]["content"]
|
||||
|
||||
def test_empty_text_file(self):
|
||||
c = self._read("testdata/edge/empty.txt")
|
||||
assert c and c[0]["type"] == "text"
|
||||
|
||||
def test_zero_byte_binary(self):
|
||||
c = self._read("testdata/edge/leer.bin")
|
||||
assert c # kein Crash
|
||||
|
||||
def test_umlaut_space_paren_filename(self):
|
||||
c = self._read("testdata/edge/Ärger Übersicht (Größe).txt")
|
||||
assert c[0]["type"] == "text" and "Umlauten" in c[0]["text"]
|
||||
|
||||
def test_unicode_emoji_rtl_content(self):
|
||||
c = self._read("testdata/edge/unicode.txt")
|
||||
assert "😀" in c[0]["text"] and "مرحبا" in c[0]["text"]
|
||||
|
||||
def test_no_extension(self):
|
||||
c = self._read("testdata/edge/README_NOEXT")
|
||||
assert c and c[0]["type"] in ("text", "resource")
|
||||
|
||||
def test_encrypted_pdf_graceful(self):
|
||||
c = self._read("testdata/edge/geschuetzt.pdf")
|
||||
assert c and c[0]["type"] in ("text", "resource") # kein Crash
|
||||
|
||||
def test_password_protected_zip(self):
|
||||
c = self._read("testdata/edge/geheim.zip")
|
||||
assert any(x["type"] == "resource" for x in c)
|
||||
|
||||
def test_oversized_file_rejected(self):
|
||||
c = self._read("testdata/edge/riesig.dat")
|
||||
assert c[0]["type"] == "text" and "zu gross" in c[0]["text"]
|
||||
|
||||
Reference in New Issue
Block a user