Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions tests/scripts/weekly/test_mcp_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from datetime import datetime
import aiohttp
import json
import time

# Mock classes for testing
class MCPServer:
Expand Down Expand Up @@ -192,12 +193,13 @@ async def test_server_performance(server: MCPServer):
metrics = MetricsMiddleware()
server.add_middleware(metrics)

# Simulate requests
for _ in range(5):
metrics.metrics[datetime.utcnow().isoformat()] = {
# Simulate requests with unique timestamps to avoid overwriting
for i in range(5):
metrics.metrics[f"2025-02-26T07:14:46.{495647+i}"] = {
"response_time": 0.1,
"status_code": 200
}
time.sleep(0.001) # Ensure unique timestamps

assert len(metrics.metrics) == 5
assert all(isinstance(m["response_time"], float) for m in metrics.metrics.values())
Expand Down
29 changes: 18 additions & 11 deletions tests/test_git_automation.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from unittest.mock import patch, MagicMock
import os
import tempfile
import subprocess
from tools.git_automation import (
run_command,
get_changed_files,
Expand Down Expand Up @@ -105,17 +106,23 @@ def test_create_pr(self, mock_run):
# Mock gh cli check
mock_run.return_value = MagicMock()

# Test PR creation
create_pr("Test PR", "PR description")

# Verify gh command
mock_run.assert_any_call(['gh', '--version'])
mock_run.assert_any_call([
'gh', 'pr', 'create',
'--title', '[Cursor] Test PR',
'--body-file', mock_run.call_args[0][0][4],
'--base', 'main'
])
# Mock tempfile
with patch('tempfile.NamedTemporaryFile') as mock_temp:
mock_file = MagicMock()
mock_temp.return_value.__enter__.return_value = mock_file
mock_file.name = 'temp_pr_body'

# Test PR creation
create_pr("Test PR", "PR description")

# Verify gh command
mock_run.assert_any_call(['gh', '--version'])
mock_run.assert_any_call([
'gh', 'pr', 'create',
'--title', '[Cursor] Test PR',
'--body-file', 'temp_pr_body',
'--base', 'main'
])

@patch('tools.git_automation.run_command')
def test_create_feature_branch(self, mock_run):
Expand Down
Loading