Skip to content

Commit bdfff4f

Browse files
committed
formatting
1 parent 99b5419 commit bdfff4f

File tree

5 files changed

+27
-20
lines changed

5 files changed

+27
-20
lines changed

dsg_lib/fastapi_functions/default_endpoints.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# -*- coding: utf-8 -*-
2+
from typing import Dict, List
3+
24
from fastapi import APIRouter, Response
3-
from typing import List, Dict
45
from loguru import logger
56

67

examples/fastapi_example.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@
2424
database_operations,
2525
)
2626
from dsg_lib.common_functions import logging_config
27-
from dsg_lib.fastapi_functions import (
28-
system_health_endpoints, default_endpoints
29-
)
27+
from dsg_lib.fastapi_functions import default_endpoints, system_health_endpoints
3028

3129
config = [
3230
{"bot": "Bytespider", "allow": False},
@@ -185,7 +183,11 @@ async def root():
185183
}
186184

187185
# Create and include the health router if enabled
188-
if config["enable_status_endpoint"] or config["enable_uptime_endpoint"] or config["enable_heapdump_endpoint"]:
186+
if (
187+
config["enable_status_endpoint"]
188+
or config["enable_uptime_endpoint"]
189+
or config["enable_heapdump_endpoint"]
190+
):
189191
health_router = system_health_endpoints.create_health_router(config)
190192
app.include_router(health_router, prefix="/api/health", tags=["system-health"])
191193

@@ -195,7 +197,6 @@ async def root():
195197
app.include_router(default_router, prefix="", tags=["default"])
196198

197199

198-
199200
async def create_a_bunch_of_users(single_entry=0, many_entries=0):
200201
logger.info(f"single_entry: {single_entry}")
201202
await async_db.create_tables()

tests/test_common_functions/test_file_mover/__init__.py

Whitespace-only changes.

tests/test_database_functions/test_async_database.py

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- coding: utf-8 -*-
22
import asyncio
33
import secrets
4-
4+
import pytest_asyncio
55
import pytest
66
from sqlalchemy import Column, Integer, String, delete, insert, select
77
from sqlalchemy.exc import IntegrityError, SQLAlchemyError
@@ -28,6 +28,22 @@ class User(async_db.Base):
2828
name = Column(String, unique=True)
2929

3030

31+
@pytest_asyncio.fixture(scope="class", autouse=True)
32+
async def setup_database():
33+
await async_db.create_tables()
34+
yield
35+
# await async_db.drop_tables()
36+
37+
38+
@pytest_asyncio.fixture(scope="function", autouse=True)
39+
async def setup_teardown():
40+
# Clean the database before each test
41+
await db_ops.execute_one(delete(User))
42+
yield
43+
# Clean the database after each test
44+
await db_ops.execute_one(delete(User))
45+
46+
3147
class TestDatabaseOperations:
3248
@pytest.fixture(scope="session")
3349
def db_ops(self):
@@ -440,19 +456,6 @@ async def test_delete_many_exception(self, db_ops):
440456
# assert result contains "error"
441457
assert "error" in result
442458

443-
@pytest.fixture(scope="class", autouse=True)
444-
async def setup_database(self):
445-
await async_db.create_tables()
446-
yield
447-
await async_db.drop_tables()
448-
449-
@pytest.fixture(scope="function", autouse=True)
450-
async def setup_teardown(self):
451-
# Clean the database before each test
452-
await db_ops.execute_one(delete(User))
453-
yield
454-
# Clean the database after each test
455-
await db_ops.execute_one(delete(User))
456459

457460
@pytest.mark.asyncio
458461
async def test_execute_one_insert(self):

tests/test_endpoints/test_default_endpoints.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# -*- coding: utf-8 -*-
22
from fastapi import FastAPI
33
from fastapi.testclient import TestClient
4+
45
from dsg_lib.fastapi_functions.default_endpoints import create_default_router
56

67
# Create a FastAPI app for testing
@@ -34,6 +35,7 @@
3435
default_router = create_default_router(config)
3536
app.include_router(default_router, prefix="", tags=["default"])
3637

38+
3739
def test_robots_txt():
3840
response = client.get("/robots.txt")
3941
assert response.status_code == 200

0 commit comments

Comments
 (0)