mirror of
https://github.com/elisiariocouto/leggen.git
synced 2025-12-13 10:12:24 +00:00
feat: Add mypy to pre-commit.
This commit is contained in:
committed by
Elisiário Couto
parent
de3da84dff
commit
ec8ef8346a
@@ -5,8 +5,6 @@ import respx
|
||||
import httpx
|
||||
from unittest.mock import patch
|
||||
|
||||
from leggend.services.gocardless_service import GoCardlessService
|
||||
|
||||
|
||||
@pytest.mark.api
|
||||
class TestBanksAPI:
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
"""Tests for CLI API client."""
|
||||
|
||||
import pytest
|
||||
import requests
|
||||
import requests_mock
|
||||
from unittest.mock import patch
|
||||
|
||||
@@ -85,7 +86,7 @@ class TestLeggendAPIClient:
|
||||
"""Test handling of connection errors."""
|
||||
client = LeggendAPIClient("http://localhost:9999") # Non-existent service
|
||||
|
||||
with pytest.raises(Exception):
|
||||
with pytest.raises((requests.ConnectionError, requests.RequestException)):
|
||||
client.get_accounts()
|
||||
|
||||
def test_http_error_handling(self):
|
||||
@@ -99,7 +100,7 @@ class TestLeggendAPIClient:
|
||||
json={"detail": "Internal server error"},
|
||||
)
|
||||
|
||||
with pytest.raises(Exception):
|
||||
with pytest.raises((requests.HTTPError, requests.RequestException)):
|
||||
client.get_accounts()
|
||||
|
||||
def test_custom_api_url(self):
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
"""Tests for configuration management."""
|
||||
|
||||
import pytest
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
from unittest.mock import patch
|
||||
|
||||
from leggend.config import Config
|
||||
@@ -164,9 +162,11 @@ class TestConfig:
|
||||
config = Config()
|
||||
config._config = None
|
||||
|
||||
with patch("builtins.open", side_effect=FileNotFoundError):
|
||||
with pytest.raises(FileNotFoundError):
|
||||
config.load_config()
|
||||
with (
|
||||
patch("builtins.open", side_effect=FileNotFoundError),
|
||||
pytest.raises(FileNotFoundError),
|
||||
):
|
||||
config.load_config()
|
||||
|
||||
def test_notifications_config(self):
|
||||
"""Test notifications configuration access."""
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
"""Tests for background scheduler."""
|
||||
|
||||
import pytest
|
||||
import asyncio
|
||||
from unittest.mock import Mock, patch, AsyncMock, MagicMock
|
||||
from unittest.mock import patch, AsyncMock, MagicMock
|
||||
from datetime import datetime
|
||||
from apscheduler.schedulers.blocking import BlockingScheduler
|
||||
|
||||
from leggend.background.scheduler import BackgroundScheduler
|
||||
from leggend.services.sync_service import SyncService
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
|
||||
Reference in New Issue
Block a user