From 7e539513565ccb965dd7897d1f977edef0404f5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20L=C3=B3pez=20Mareque?= Date: Wed, 25 Sep 2024 19:50:58 +0200 Subject: [PATCH] feat: reorganize imports --- main.py | 5 +++-- src/delivery/api/v1/health/health_router.py | 2 +- src/delivery/api/v1/hello/hello_router.py | 12 +++++++----- src/domain/command.py | 1 - src/use_cases/health_command.py | 3 ++- src/use_cases/say_hello_command.py | 2 +- .../acceptance/delivery/api/test_heath_controller.py | 7 ++++--- .../acceptance/delivery/api/test_hello_controller.py | 7 ++++--- .../hello/test_dummy_hello_client_integration.py | 1 + .../acceptance/delivery/api/test_hello_controller.py | 6 ++++-- tests/unit/use_cases/test_health_command.py | 1 + tests/unit/use_cases/test_say_hello_command.py | 5 +++-- 12 files changed, 31 insertions(+), 21 deletions(-) diff --git a/main.py b/main.py index 2d0c95e..491f662 100644 --- a/main.py +++ b/main.py @@ -1,13 +1,14 @@ import logging - from collections.abc import AsyncGenerator from contextlib import asynccontextmanager +from time import sleep + from fastapi import FastAPI + from src.common.logger import setup_logging from src.common.settings import Settings from src.delivery.api.v1.health.health_router import health from src.delivery.api.v1.hello.hello_router import hello -from time import sleep @asynccontextmanager diff --git a/src/delivery/api/v1/health/health_router.py b/src/delivery/api/v1/health/health_router.py index 513abc7..106c0ad 100644 --- a/src/delivery/api/v1/health/health_router.py +++ b/src/delivery/api/v1/health/health_router.py @@ -1,7 +1,7 @@ from fastapi import APIRouter, Depends -from src.domain.command import CommandHandler from src.delivery.api.v1.health.health_response import HealthResponse +from src.domain.command import CommandHandler from src.use_cases.health_command import HealthCommand, HealthCommandHandler health: APIRouter = APIRouter() diff --git a/src/delivery/api/v1/hello/hello_router.py b/src/delivery/api/v1/hello/hello_router.py index 88b1f41..18cde3d 100644 --- a/src/delivery/api/v1/hello/hello_router.py +++ b/src/delivery/api/v1/hello/hello_router.py @@ -1,14 +1,16 @@ -from fastapi import APIRouter, Depends, HTTPException from http.client import BAD_REQUEST + +from fastapi import APIRouter, Depends, HTTPException + +from src.delivery.api.v1.hello.hello_response import HelloResponse +from src.domain.command import CommandHandler from src.domain.exceptions import SayHelloCommandHandlerException +from src.domain.hello_client import HelloClient +from src.infrastructure.hello.hello_client import DummyHelloClient from src.use_cases.say_hello_command import ( SayHelloCommand, SayHelloCommandHandler, ) -from src.domain.command import CommandHandler -from src.domain.hello_client import HelloClient -from src.delivery.api.v1.hello.hello_response import HelloResponse -from src.infrastructure.hello.hello_client import DummyHelloClient hello: APIRouter = APIRouter() diff --git a/src/domain/command.py b/src/domain/command.py index 63563e4..6b7d24a 100644 --- a/src/domain/command.py +++ b/src/domain/command.py @@ -1,5 +1,4 @@ import uuid - from abc import ABC, abstractmethod from typing import Any diff --git a/src/use_cases/health_command.py b/src/use_cases/health_command.py index cc37700..a7f655a 100644 --- a/src/use_cases/health_command.py +++ b/src/use_cases/health_command.py @@ -1,5 +1,6 @@ -from logging import Logger import logging +from logging import Logger + from src.domain.command import Command, CommandHandler, CommandResponse diff --git a/src/use_cases/say_hello_command.py b/src/use_cases/say_hello_command.py index d85857c..dd11eca 100644 --- a/src/use_cases/say_hello_command.py +++ b/src/use_cases/say_hello_command.py @@ -1,6 +1,6 @@ import logging - from logging import Logger + from src.domain.command import Command, CommandHandler, CommandResponse from src.domain.exceptions import ( SayHelloClientException, diff --git a/tests/acceptance/delivery/api/test_heath_controller.py b/tests/acceptance/delivery/api/test_heath_controller.py index 6bfbe5e..aa1569b 100644 --- a/tests/acceptance/delivery/api/test_heath_controller.py +++ b/tests/acceptance/delivery/api/test_heath_controller.py @@ -1,8 +1,9 @@ -import pytest +from http.client import OK -from expects import expect, equal +import pytest +from expects import equal, expect from fastapi.testclient import TestClient -from http.client import OK + from main import app, settings diff --git a/tests/acceptance/delivery/api/test_hello_controller.py b/tests/acceptance/delivery/api/test_hello_controller.py index 940abf5..05c3948 100644 --- a/tests/acceptance/delivery/api/test_hello_controller.py +++ b/tests/acceptance/delivery/api/test_hello_controller.py @@ -1,8 +1,9 @@ -import pytest +from http.client import OK -from expects import expect, equal +import pytest +from expects import equal, expect from fastapi.testclient import TestClient -from http.client import OK + from main import app, settings diff --git a/tests/integration/hello/test_dummy_hello_client_integration.py b/tests/integration/hello/test_dummy_hello_client_integration.py index 1bb81fe..8446525 100644 --- a/tests/integration/hello/test_dummy_hello_client_integration.py +++ b/tests/integration/hello/test_dummy_hello_client_integration.py @@ -1,4 +1,5 @@ from expects import equal, expect, raise_error + from src.domain.exceptions import SayHelloClientException from src.infrastructure.hello.hello_client import DummyHelloClient diff --git a/tests/unit/acceptance/delivery/api/test_hello_controller.py b/tests/unit/acceptance/delivery/api/test_hello_controller.py index 383911c..7b19b38 100644 --- a/tests/unit/acceptance/delivery/api/test_hello_controller.py +++ b/tests/unit/acceptance/delivery/api/test_hello_controller.py @@ -1,7 +1,9 @@ +from http.client import BAD_REQUEST + from doublex import ANY_ARG, Mimic, Stub -from expects import expect, equal +from expects import equal, expect from fastapi.testclient import TestClient -from http.client import BAD_REQUEST + from main import app, settings from src.delivery.api.v1.hello.hello_router import say_hello_command_handler from src.domain.exceptions import SayHelloCommandHandlerException diff --git a/tests/unit/use_cases/test_health_command.py b/tests/unit/use_cases/test_health_command.py index c7682a9..5487e06 100644 --- a/tests/unit/use_cases/test_health_command.py +++ b/tests/unit/use_cases/test_health_command.py @@ -1,4 +1,5 @@ from expects import be_true, expect + from src.use_cases.health_command import HealthCommand, HealthCommandHandler diff --git a/tests/unit/use_cases/test_say_hello_command.py b/tests/unit/use_cases/test_say_hello_command.py index 900808e..ac8eb83 100644 --- a/tests/unit/use_cases/test_say_hello_command.py +++ b/tests/unit/use_cases/test_say_hello_command.py @@ -1,8 +1,9 @@ -from expects import equal, expect, raise_error from doublex import Mimic, Stub +from expects import equal, expect, raise_error + from src.domain.exceptions import ( - SayHelloCommandHandlerException, SayHelloClientException, + SayHelloCommandHandlerException, ) from src.infrastructure.hello.hello_client import DummyHelloClient from src.use_cases.say_hello_command import SayHelloCommand, SayHelloCommandHandler