Skip to main content
Glama
test_exceptions.py2.72 kB
""" Tests for custom exceptions """ import pytest from src.exceptions import ( CPGGenerationError, GitOperationError, JoernMCPError, QueryExecutionError, ResourceLimitError, ValidationError, ) class TestExceptions: """Test custom exception classes""" def test_base_exception(self): """Test base JoernMCPError""" error = JoernMCPError("Test error") assert str(error) == "Test error" assert isinstance(error, Exception) def test_cpg_generation_error(self): """Test CPGGenerationError""" error = CPGGenerationError("CPG generation failed") assert str(error) == "CPG generation failed" assert isinstance(error, JoernMCPError) def test_query_execution_error(self): """Test QueryExecutionError""" error = QueryExecutionError("Query execution failed") assert str(error) == "Query execution failed" assert isinstance(error, JoernMCPError) def test_resource_limit_error(self): """Test ResourceLimitError""" error = ResourceLimitError("Resource limit exceeded") assert str(error) == "Resource limit exceeded" assert isinstance(error, JoernMCPError) def test_validation_error(self): """Test ValidationError""" error = ValidationError("Invalid input") assert str(error) == "Invalid input" assert isinstance(error, JoernMCPError) def test_git_operation_error(self): """Test GitOperationError""" error = GitOperationError("Git operation failed") assert str(error) == "Git operation failed" assert isinstance(error, JoernMCPError) def test_exception_hierarchy(self): """Test that all exceptions inherit from JoernMCPError""" exceptions = [ CPGGenerationError("test"), QueryExecutionError("test"), ResourceLimitError("test"), ValidationError("test"), GitOperationError("test"), ] for exc in exceptions: assert isinstance(exc, JoernMCPError) assert isinstance(exc, Exception) def test_exception_with_custom_message(self): """Test exceptions with custom messages""" test_cases = [ (CPGGenerationError, "Failed to generate CPG for Java project"), (QueryExecutionError, "Invalid CPGQL syntax"), (ResourceLimitError, "Maximum concurrent sessions reached"), (ValidationError, "Unsupported language: rust"), (GitOperationError, "Repository not found"), ] for exc_class, message in test_cases: error = exc_class(message) assert str(error) == message

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Lekssays/codebadger'

If you have feedback or need assistance with the MCP directory API, please join our Discord server