test_config.py
- Pfad:
/var/www/mcp-servers/mcp-db/tests/test_config.py - Namespace: -
- Zeilen: 57 | Größe: 1,486 Bytes
- Geändert: 2025-12-28 12:21:49 | Gescannt: 2025-12-31 10:22:15
Code Hygiene Score: 100
- Dependencies: 100 (25%)
- LOC: 100 (20%)
- Methods: 100 (20%)
- Secrets: 100 (15%)
- Classes: 100 (10%)
- Magic Numbers: 100 (10%)
Keine Issues gefunden.
Dependencies 5
- use sys
- use pathlib.Path
- use pytest
- use dotenv.load_dotenv
- use config.Config
Klassen 1
-
TestConfigclass Zeile 18
Code
#!/usr/bin/env python3
"""Tests für Konfiguration"""
import sys
from pathlib import Path
import pytest
sys.path.insert(0, "/var/www/mcp-servers/mcp_db")
from dotenv import load_dotenv
load_dotenv(Path("/var/www/mcp-servers/mcp_db/.env"))
from config import Config
class TestConfig:
"""Test Konfiguration"""
def test_allowed_databases(self):
"""Test: ALLOWED_DATABASES korrekt"""
assert "ki_protokoll" in Config.ALLOWED_DATABASES
assert "ki_system" in Config.ALLOWED_DATABASES
assert "mysql" not in Config.ALLOWED_DATABASES
def test_blocked_keywords(self):
"""Test: BLOCKED_KEYWORDS enthält kritische Keywords"""
required_keywords = [
"DROP",
"DELETE",
"INSERT",
"UPDATE",
"SLEEP",
"LOAD_FILE",
]
for keyword in required_keywords:
assert keyword in Config.BLOCKED_KEYWORDS
def test_max_query_length(self):
"""Test: MAX_QUERY_LENGTH = 2000"""
assert Config.MAX_QUERY_LENGTH == 2000
def test_max_rows(self):
"""Test: MAX_ROWS = 100"""
assert Config.MAX_ROWS == 100
def test_allowed_tables(self):
"""Test: ALLOWED_TABLES enthält wichtige Tabellen"""
required_tables = ["mcp_log", "chunks", "protokoll"]
for table in required_tables:
assert table in Config.ALLOWED_TABLES
if __name__ == "__main__":
pytest.main([__file__, "-v"])