Fix code formatting and linting issues
- Auto-format all Python files with black and isort - Remove unused imports with autoflake - Fix flake8 issues (missing newlines, blank lines, etc.) - Fix nonlocal/global scope issues in main.py - Fix security.py import order (E402) - Remove f-string without placeholders - Add nosec comment for intentional exception handling - Fix test imports to match refactored DMARCParser API Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
This commit is contained in:
@@ -1,10 +1,7 @@
|
||||
import pytest
|
||||
from fastapi import FastAPI
|
||||
from app.models.domain import Domain
|
||||
from fastapi.testclient import TestClient
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from app.models.domain import Domain
|
||||
|
||||
|
||||
def test_read_health(client: TestClient):
|
||||
"""Test health check endpoint"""
|
||||
@@ -30,11 +27,11 @@ def test_read_domains(client: TestClient, db_session: Session):
|
||||
domain2 = Domain(name="test.com", description="Test Domain", active=True)
|
||||
db_session.add_all([domain1, domain2])
|
||||
db_session.commit()
|
||||
|
||||
|
||||
response = client.get("/api/v1/domains")
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
|
||||
|
||||
assert len(data) == 2
|
||||
assert {"name": "example.com", "description": "Example Domain"}.items() <= data[0].items()
|
||||
assert {"name": "test.com", "description": "Test Domain"}.items() <= data[1].items()
|
||||
@@ -44,18 +41,18 @@ def test_create_domain(client: TestClient):
|
||||
"""Test creating a new domain"""
|
||||
response = client.post(
|
||||
"/api/v1/domains",
|
||||
json={"name": "newdomain.com", "description": "New Domain", "active": True}
|
||||
json={"name": "newdomain.com", "description": "New Domain", "active": True},
|
||||
)
|
||||
|
||||
|
||||
assert response.status_code == 201
|
||||
data = response.json()
|
||||
assert data["name"] == "newdomain.com"
|
||||
assert data["description"] == "New Domain"
|
||||
assert data["active"] is True
|
||||
assert "id" in data
|
||||
|
||||
|
||||
# Check that the domain was actually created
|
||||
response = client.get("/api/v1/domains")
|
||||
assert response.status_code == 200
|
||||
domains = response.json()
|
||||
assert any(d["name"] == "newdomain.com" for d in domains)
|
||||
assert any(d["name"] == "newdomain.com" for d in domains)
|
||||
|
||||
Reference in New Issue
Block a user