33
44These tests verify that the Docker image can be built successfully.
55"""
6+
67import subprocess
78import pytest
89import 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
3028pytestmark = 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
7578if __name__ == "__main__" :
7679 # Run tests
77- pytest .main ([__file__ , "-v" ])
80+ pytest .main ([__file__ , "-v" ])
0 commit comments