Skip to main content
Glama

Toggl MCP Server

by ikido
test_parser_service.py3.29 kB
"""Unit tests for ParserService.""" import sys import os # Add src to path sys.path.insert(0, os.path.join(os.path.dirname(__file__), "../src")) from toggl_mcp.services.parser_service import ParserService def test_parser_matched_with_all_metadata(): """Test parsing with full entity reference.""" parser = ParserService() result = parser.parse_description("Design UI #456 [Scrum] [Task] [Moneyball]") assert result.is_matched is True assert result.entity_id == "456" assert result.description_clean == "Design UI" assert result.entity_database == "Scrum" assert result.entity_type == "Task" assert result.project == "Moneyball" def test_parser_matched_minimal(): """Test parsing with minimal entity reference.""" parser = ParserService() result = parser.parse_description("#123") assert result.is_matched is True assert result.entity_id == "123" assert result.description_clean == "" assert result.entity_database is None assert result.entity_type is None assert result.project is None def test_parser_matched_with_partial_metadata(): """Test parsing with partial metadata.""" parser = ParserService() result = parser.parse_description("Task #789 [Database]") assert result.is_matched is True assert result.entity_id == "789" assert result.description_clean == "Task" assert result.entity_database == "Database" assert result.entity_type is None def test_parser_unmatched(): """Test parsing unmatched description.""" parser = ParserService() result = parser.parse_description("Team meeting") assert result.is_matched is False assert result.entity_id is None assert result.description_clean == "Team meeting" def test_parser_rightmost_id(): """Test that rightmost #ID is used when multiple exist.""" parser = ParserService() result = parser.parse_description("Fix #123 and test #456 [Scrum] [Bug]") assert result.is_matched is True assert result.entity_id == "456" assert result.description_clean == "Fix #123 and test" assert result.entity_database == "Scrum" assert result.entity_type == "Bug" def test_parser_with_description_containing_brackets(): """Test parsing with description containing brackets.""" parser = ParserService() result = parser.parse_description("Review [old code] #999 [Dev] [Task]") assert result.is_matched is True assert result.entity_id == "999" assert result.description_clean == "Review [old code]" assert result.entity_database == "Dev" def test_parser_extra_brackets_ignored(): """Test that only first 3 brackets are used.""" parser = ParserService() result = parser.parse_description("Task #100 [DB] [Type] [Proj] [Extra] [Ignored]") assert result.entity_id == "100" assert result.entity_database == "DB" assert result.entity_type == "Type" assert result.project == "Proj" if __name__ == "__main__": test_parser_matched_with_all_metadata() test_parser_matched_minimal() test_parser_matched_with_partial_metadata() test_parser_unmatched() test_parser_rightmost_id() test_parser_with_description_containing_brackets() test_parser_extra_brackets_ignored() print("All parser tests passed!")

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/ikido/toggl-mcp-custom'

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