MCPcopy Index your code
hub / github.com/Zipstack/unstract / test_plugin

Method test_plugin

workers/plugins/plugin_manager.py:186–234  ·  view source on GitHub ↗

Run tests for a plugin.

(self, plugin_name: str)

Source from the content-addressed store, hash-verified

184 logger.warning(f" ⚠️ Plugin requirements validation error: {e}")
185
186 def test_plugin(self, plugin_name: str) -> None:
187 """Run tests for a plugin."""
188 logger.info(f"Testing Plugin: {plugin_name}")
189 logger.info("=" * 50)
190
191 plugin_path = Path(__file__).parent / plugin_name
192 test_file = plugin_path / "test_plugin.py"
193
194 if not test_file.exists():
195 logger.error("❌ No test file found (test_plugin.py)")
196 return
197
198 logger.info("🧪 Running plugin tests...")
199
200 # Try to run the test file
201 import os
202 import subprocess
203
204 try:
205 # Set up environment
206 env = os.environ.copy()
207 env["PYTHONPATH"] = str(Path(__file__).parent.parent)
208
209 # Run the test
210 result = subprocess.run(
211 [sys.executable, str(test_file)],
212 cwd=str(Path(__file__).parent.parent),
213 env=env,
214 capture_output=True,
215 text=True,
216 timeout=60,
217 )
218
219 if result.returncode == 0:
220 logger.info("✅ Tests passed!")
221 logger.info("\nTest Output:")
222 logger.info(result.stdout)
223 else:
224 logger.error("❌ Tests failed!")
225 logger.info("\nTest Output:")
226 logger.info(result.stdout)
227 if result.stderr:
228 logger.error("\nError Output:")
229 logger.error(result.stderr)
230
231 except subprocess.TimeoutExpired:
232 logger.warning("⏰ Tests timed out after 60 seconds")
233 except Exception as e:
234 logger.error(f"❌ Error running tests: {e}")
235
236 def install_plugin_deps(self, plugin_name: str) -> None:
237 """Install dependencies for a plugin."""

Callers

nothing calls this directly

Calls 5

warningMethod · 0.80
infoMethod · 0.45
existsMethod · 0.45
errorMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected