Skip to content

Commit

Permalink
fix ci failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
davidgamez committed Dec 3, 2024
1 parent 510099e commit 35941ed
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,9 @@
from feeds_operations_gen.models.update_request_gtfs_feed import UpdateRequestGtfsFeed
from helpers.database import start_db_session
from helpers.query_helper import query_feed_by_stable_id
from helpers.logger import Logger
from deepdiff import DeepDiff

logging.basicConfig(level=logging.INFO)
Logger.init_logger()


class OperationsApiImpl(BaseOperationsApi):
Expand Down
3 changes: 3 additions & 0 deletions functions-python/operations_api/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
import asyncio

from middleware.request_context_middleware import RequestContextMiddleware
from helpers.logger import Logger

Logger.init_logger()

app = FastAPI(
title="Mobility Database Catalog Operations",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
from unittest import mock
from unittest.mock import patch

import pytest
from fastapi import HTTPException
Expand Down Expand Up @@ -39,27 +40,29 @@ def update_request_gtfs_feed():
)


@patch("helpers.logger.Logger")
@mock.patch.dict(
os.environ,
{
"FEEDS_DATABASE_URL": default_db_url,
},
)
@pytest.mark.asyncio
async def test_update_gtfs_feed_no_changes(update_request_gtfs_feed):
async def test_update_gtfs_feed_no_changes(_, update_request_gtfs_feed):
api = OperationsApiImpl()
response: Response = await api.update_gtfs_feed(update_request_gtfs_feed)
assert response.status_code == 204


@patch("helpers.logger.Logger")
@mock.patch.dict(
os.environ,
{
"FEEDS_DATABASE_URL": default_db_url,
},
)
@pytest.mark.asyncio
async def test_update_gtfs_feed_field_change(update_request_gtfs_feed):
async def test_update_gtfs_feed_field_change(_, update_request_gtfs_feed):
update_request_gtfs_feed.feed_name = "New feed name"
with get_testing_session() as session:
api = OperationsApiImpl()
Expand All @@ -74,14 +77,15 @@ async def test_update_gtfs_feed_field_change(update_request_gtfs_feed):
assert db_feed.feed_name == "New feed name"


@patch("helpers.logger.Logger")
@mock.patch.dict(
os.environ,
{
"FEEDS_DATABASE_URL": default_db_url,
},
)
@pytest.mark.asyncio
async def test_update_gtfs_feed_set_wip(update_request_gtfs_feed):
async def test_update_gtfs_feed_set_wip(_, update_request_gtfs_feed):
update_request_gtfs_feed.operational_status_action = "wip"
with get_testing_session() as session:
api = OperationsApiImpl()
Expand All @@ -96,14 +100,15 @@ async def test_update_gtfs_feed_set_wip(update_request_gtfs_feed):
assert db_feed.operational_status == "wip"


@patch("helpers.logger.Logger")
@mock.patch.dict(
os.environ,
{
"FEEDS_DATABASE_URL": default_db_url,
},
)
@pytest.mark.asyncio
async def test_update_gtfs_feed_invalid_feed(update_request_gtfs_feed):
async def test_update_gtfs_feed_invalid_feed(_, update_request_gtfs_feed):
update_request_gtfs_feed.id = "invalid"
api = OperationsApiImpl()
with pytest.raises(HTTPException) as exc_info:
Expand Down

0 comments on commit 35941ed

Please sign in to comment.