Skip to content

Commit

Permalink
stable version
Browse files Browse the repository at this point in the history
  • Loading branch information
sudeepkunhis committed Jan 23, 2025
1 parent 9ad7a56 commit f7fcafb
Show file tree
Hide file tree
Showing 16 changed files with 21 additions and 15 deletions.
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ RUN pip install --no-cache-dir poetry==1.8.4 && \
poetry config virtualenvs.create false && \
poetry install --no-root --no-dev

COPY . /app
COPY src src

CMD ["uvicorn", "src.main:app", "--host", "0.0.0.0", "--port", "5010"]
ENV PYTHONPATH=src/app

CMD ["uvicorn", "src.app.main:app", "--host", "0.0.0.0", "--port", "5010"]
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ lint: ## Run all linters (black/ruff/pylint/mypy).

.PHONY: test
test: ## Run the tests and check coverage.
poetry run pytest -n auto --cov=src --cov-report term-missing --cov-fail-under=100
export PYTHONPATH=src/app && \
poetry run pytest -n auto --cov=src/app ./src/tests --cov-report term-missing --cov-fail-under=100

.PHONY: mypy
mypy: ## Run mypy.
Expand All @@ -51,7 +52,8 @@ megalint: ## Run the mega-linter.

.PHONY: run
run: ## Start the local application.
poetry run uvicorn src.main:app --reload --port 5010
export PYTHONPATH=src/app && \
poetry run uvicorn src.app.main:app --reload --port 5010

.PHONY: docker-build
docker-build: ## Build the docker image.
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ select = [
convention = "google"

[tool.ruff.lint.per-file-ignores]
"tests/*" = [
"src/tests/*" = [
# Allow use of assert statements in tests
"S101",
]
Expand Down
1 change: 0 additions & 1 deletion src/__init__.py

This file was deleted.

1 change: 1 addition & 0 deletions src/app/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""This file is used to import the app directory."""
File renamed without changes.
File renamed without changes.
3 changes: 1 addition & 2 deletions src/main.py → src/app/main.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
"""This module is the entry point of the FastAPI application."""

import fastapi

from src.routers import schema_router
from routers import schema_router

app = fastapi.FastAPI()

Expand Down
1 change: 1 addition & 0 deletions src/app/routers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""This file is used to import the routers directory."""
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
"""This module contains the FastAPI router for the schema conversion endpoint."""

from config.logging_config import logging
from fastapi import APIRouter

from src.config.logging_config import logging

router = APIRouter()

logger = logging.getLogger(__name__)
Expand Down
1 change: 1 addition & 0 deletions src/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""This file is used to import the tests directory."""
1 change: 1 addition & 0 deletions src/tests/unit/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""This file is used to import the tests/unit directory."""
6 changes: 4 additions & 2 deletions tests/unit/conftest.py → src/tests/unit/conftest.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
"""Configuration for unit tests."""

from collections.abc import Generator

import pytest
from fastapi.testclient import TestClient

import src.main as app
import app.main as app


@pytest.fixture
def test_client():
def test_client() -> Generator[TestClient, None, None]:
"""General client for hitting endpoints in tests."""
yield TestClient(app.app)
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
"""This module contains the unit tests for the schema router."""

from fastapi import status
from fastapi.testclient import TestClient

"""Test the schema router with valid JSON."""


def test_schema_router_with_valid_json(test_client):
def test_schema_router_with_valid_json(test_client: TestClient) -> None:
"""Test the post schema method with valid JSON."""
response = test_client.post(
"/schema?current_version=1&target_version=2",
Expand Down
1 change: 0 additions & 1 deletion tests/__init__.py

This file was deleted.

1 change: 0 additions & 1 deletion tests/unit/__init__.py

This file was deleted.

0 comments on commit f7fcafb

Please sign in to comment.