Skip to content

Commit f497797

Browse files
committed
Fix get_stats() call and failing test
1 parent 5309d0d commit f497797

File tree

4 files changed

+24
-21
lines changed

4 files changed

+24
-21
lines changed

src/meilisearch_mcp/logging.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import logging
22
import sys
33
import json
4-
from datetime import datetime
4+
from datetime import datetime, timezone
55
from pathlib import Path
66
from typing import Optional, Dict, Any
77
import threading
@@ -97,7 +97,7 @@ def _setup_logger(self, log_dir: Optional[str]):
9797
def _log(self, level: str, msg: str, **kwargs):
9898
"""Create structured log entry"""
9999
log_entry = {
100-
"timestamp": datetime.utcnow().isoformat(),
100+
"timestamp": datetime.now(timezone.utc).isoformat(),
101101
"level": level,
102102
"message": msg,
103103
**kwargs,

src/meilisearch_mcp/monitoring.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def get_health_status(self) -> HealthStatus:
3636
"""Get comprehensive health status"""
3737
try:
3838
# Get various stats to build health picture
39-
stats = self.client.get_stats()
39+
stats = self.client.get_all_stats()
4040
indexes = self.client.get_indexes()
4141

4242
indexes_info = []

tests/test_docker_integration.py

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
44
These tests verify that the Docker image can be built successfully.
55
"""
6+
67
import subprocess
78
import pytest
89
import shutil
@@ -16,10 +17,7 @@ def docker_available():
1617
# Try to run docker version to ensure it's working
1718
try:
1819
result = subprocess.run(
19-
["docker", "version"],
20-
capture_output=True,
21-
text=True,
22-
timeout=5
20+
["docker", "version"], capture_output=True, text=True, timeout=5
2321
)
2422
return result.returncode == 0
2523
except (subprocess.TimeoutExpired, FileNotFoundError):
@@ -28,8 +26,7 @@ def docker_available():
2826

2927
# Skip all tests in this module if Docker is not available
3028
pytestmark = pytest.mark.skipif(
31-
not docker_available(),
32-
reason="Docker not available on this system"
29+
not docker_available(), reason="Docker not available on this system"
3330
)
3431

3532

@@ -38,7 +35,7 @@ def test_docker_build():
3835
result = subprocess.run(
3936
["docker", "build", "-t", "meilisearch-mcp-test", "."],
4037
capture_output=True,
41-
text=True
38+
text=True,
4239
)
4340
assert result.returncode == 0, f"Docker build failed: {result.stderr}"
4441

@@ -49,29 +46,35 @@ def test_docker_image_runs():
4946
build_result = subprocess.run(
5047
["docker", "build", "-t", "meilisearch-mcp-test", "."],
5148
capture_output=True,
52-
text=True
49+
text=True,
5350
)
5451
if build_result.returncode != 0:
5552
pytest.skip(f"Docker build failed: {build_result.stderr}")
56-
53+
5754
# Try to run the container and check it starts
5855
result = subprocess.run(
5956
[
60-
"docker", "run", "--rm",
61-
"-e", "MEILI_HTTP_ADDR=http://localhost:7700",
62-
"-e", "MEILI_MASTER_KEY=test",
57+
"docker",
58+
"run",
59+
"--rm",
60+
"-e",
61+
"MEILI_HTTP_ADDR=http://localhost:7700",
62+
"-e",
63+
"MEILI_MASTER_KEY=test",
6364
"meilisearch-mcp-test",
64-
"python", "-c", "import src.meilisearch_mcp; print('MCP module loaded successfully')"
65+
"python",
66+
"-c",
67+
"import src.meilisearch_mcp; print('MCP module loaded successfully')",
6568
],
6669
capture_output=True,
6770
text=True,
68-
timeout=30
71+
timeout=30,
6972
)
70-
73+
7174
assert result.returncode == 0, f"Docker run failed: {result.stderr}"
7275
assert "MCP module loaded successfully" in result.stdout
7376

7477

7578
if __name__ == "__main__":
7679
# Run tests
77-
pytest.main([__file__, "-v"])
80+
pytest.main([__file__, "-v"])

tests/test_mcp_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -577,8 +577,8 @@ async def test_delete_index_input_validation(self, mcp_server):
577577
"""Test input validation for delete-index tool (issue #23)"""
578578
# Test missing uid parameter
579579
result = await simulate_mcp_call(mcp_server, "delete-index", {})
580-
response_text = assert_text_content_response(result, "Error:")
581-
assert "Error:" in response_text
580+
response_text = assert_text_content_response(result, "error:")
581+
assert "error:" in response_text
582582

583583
async def test_delete_index_integration_workflow(self, mcp_server):
584584
"""Test complete workflow: create -> add docs -> search -> delete (issue #23)"""

0 commit comments

Comments
 (0)