"""
Pytest configuration and fixtures for the test suite
"""
import pytest
import os
from unittest.mock import Mock, MagicMock
@pytest.fixture
def sample_markdown_content():
"""Sample markdown content for testing the parser"""
return """# Test Tasks
- [ ] Simple task without metadata
- [ ] Task with tags
Tags: work, urgent
- [ ] Task with project and tags
Tags: personal, shopping
Project: Home Tasks
Buy groceries and household items
- [x] Completed task
Tags: done
- [ ] Task with description
Description: This is a detailed description
It spans multiple lines
And has more content
- [ ] Multi-line content task
Tags: test
This is content line 1
This is content line 2
"""
@pytest.fixture
def mock_ticktick_api():
"""Mock TickTick API for testing"""
api = MagicMock()
api.get_user_info.return_value = {'username': 'testuser'}
api.get_projects.return_value = [
{'id': 'proj1', 'name': 'Work Tasks'},
{'id': 'proj2', 'name': 'Personal'},
{'id': 'proj3', 'name': 'Home Tasks'}
]
api.create_task.return_value = {'id': 'task123', 'title': 'Test Task'}
api.get_projects_data.return_value = {
'tasks': [
{
'id': 'task1',
'title': '2025-12-31 Test Task',
'content': 'Test content',
'tags': ['test', 'example'],
'createdTime': '2025-12-31T10:00:00.000Z'
}
]
}
return api
@pytest.fixture
def mock_env_token(monkeypatch):
"""Mock environment variable for access token"""
monkeypatch.setenv('TICKTICK_ACCESS_TOKEN', 'test_token_123')
@pytest.fixture
def sample_tasks():
"""Sample task data from TickTick API"""
return [
{
'id': 'task1',
'title': '2025-12-31 Meeting Notes',
'content': 'Discussed project timeline',
'tags': ['work', 'meeting'],
'createdTime': '2025-12-31T10:00:00.000Z',
'modifiedTime': '2025-12-31T11:00:00.000Z'
},
{
'id': 'task2',
'title': 'Buy groceries',
'content': 'Milk, bread, eggs',
'tags': ['personal', 'shopping'],
'createdTime': '2025-12-30T14:00:00.000Z'
},
{
'id': 'task3',
'title': '2026-01-01 New Year Planning',
'content': '',
'tags': ['planning'],
'createdTime': '2026-01-01T00:00:00.000Z'
}
]