Skip to content

Commit

Permalink
Corrections in imports and PYTHONPATH
Browse files Browse the repository at this point in the history
  • Loading branch information
jcpitre committed Dec 20, 2024
1 parent 1b2b3ad commit 6b3c6f6
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,16 @@ def test_get_data_rate_limit(mock_get, processor):


def test_extract_feeds_data(processor):
feeds_data = {
"feeds": [
{
"id": "feed1",
"urls": {"static_current": "http://example.com/feed1"},
"spec": "gtfs",
"onestop_id": "onestop1",
"authorization": {},
}
]
}
result = processor.extract_feeds_data(feeds_data)
feeds_data = [
{
"id": "feed1",
"urls": {"static_current": "http://example.com"},
"spec": "gtfs",
"onestop_id": "onestop1",
"authorization": {},
}
]
result = processor.extract_feeds_data(feeds_data, [])
assert len(result) == 1
assert result[0]["feed_id"] == "feed1"

Expand Down
2 changes: 1 addition & 1 deletion functions-python/feed_sync_process_transitland/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from helpers.database import start_db_session, configure_polymorphic_mappers
from helpers.feed_sync.models import TransitFeedSyncPayload as FeedPayload
from helpers.logger import Logger
from .feed_processor_utils import check_url_status, create_new_feed
from feed_processor_utils import check_url_status, create_new_feed

# Environment variables
PROJECT_ID = os.getenv("PROJECT_ID")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import requests

from database_gen.sqlacodegen_models import Gtfsfeed, Gtfsrealtimefeed
from feed_sync_process_transitland.src.feed_processor_utils import (
from feed_processor_utils import (
check_url_status,
get_feed_model,
get_tlnd_authentication_type,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ def test_process_feed_event_invalid_json(self, mock_logging):
# Verify error handling
mock_logging.error.assert_called()

@patch("feed_sync_process_transitland.src.main.create_new_feed")
@patch("main.create_new_feed")
def test_process_new_feed_or_skip(
self, create_new_feed_mock, processor, feed_payload, mock_logging
):
Expand All @@ -337,7 +337,7 @@ def test_process_new_feed_or_skip(
processor._process_new_feed_or_skip(feed_payload)
create_new_feed_mock.assert_called_once()

@patch("feed_sync_process_transitland.src.main.create_new_feed")
@patch("main.create_new_feed")
def test_process_new_feed_skip(
self, create_new_feed_mock, processor, feed_payload, mock_logging
):
Expand All @@ -348,7 +348,7 @@ def test_process_new_feed_skip(
processor._process_new_feed_or_skip(feed_payload)
create_new_feed_mock.assert_not_called()

@patch("feed_sync_process_transitland.src.main.create_new_feed")
@patch("main.create_new_feed")
def test_process_existing_feed_refs(
self, create_new_feed_mock, processor, feed_payload, mock_logging
):
Expand Down Expand Up @@ -399,7 +399,7 @@ def test_process_existing_feed_refs(
_ = processor._process_existing_feed_refs(feed_payload, matching_feeds)
create_new_feed_mock.assert_called_once()

@patch("feed_sync_process_transitland.src.main.create_new_feed")
@patch("main.create_new_feed")
def test_update_feed(self, create_new_feed_mock, processor, feed_payload):
"""Test updating an existing feed."""
# No matching feed
Expand Down
2 changes: 1 addition & 1 deletion functions-python/helpers/tests/test_transform.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from helpers.transform import to_boolean
from transform import to_boolean


def test_to_boolean():
Expand Down
3 changes: 2 additions & 1 deletion functions-python/operations_api/function_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"timeout": 540,
"memory": "1Gi",
"trigger_http": true,
"include_folders": ["database_gen", "helpers"],
"include_folders": ["helpers"],
"include_api_folders": ["database_gen"],
"environment_variables": [
{
"key": "GOOGLE_CLIENT_ID"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
from feeds_operations_gen.models.feed_status import FeedStatus
from feeds_operations_gen.models.source_info import SourceInfo
from feeds_operations_gen.models.update_request_gtfs_feed import UpdateRequestGtfsFeed
from operations_api.src.feeds_operations.impl.models.update_request_gtfs_feed_impl import (
from feeds_operations.impl.models.update_request_gtfs_feed_impl import (
UpdateRequestGtfsFeedImpl,
)
from operations_api.src.feeds_operations.impl.models.redirect_impl import RedirectImpl
from operations_api.src.feeds_operations.impl.models.external_id_impl import (
from feeds_operations.impl.models.redirect_impl import RedirectImpl
from feeds_operations.impl.models.external_id_impl import (
ExternalIdImpl,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
from feeds_operations_gen.models.update_request_gtfs_rt_feed import (
UpdateRequestGtfsRtFeed,
)
from operations_api.src.feeds_operations.impl.models.redirect_impl import RedirectImpl
from operations_api.src.feeds_operations.impl.models.external_id_impl import (
from feeds_operations.impl.models.redirect_impl import RedirectImpl
from feeds_operations.impl.models.external_id_impl import (
ExternalIdImpl,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from feeds_operations_gen.models.feed_status import FeedStatus
from feeds_operations_gen.models.source_info import SourceInfo
from feeds_operations_gen.models.update_request_gtfs_feed import UpdateRequestGtfsFeed
from operations_api.tests.conftest import feed_mdb_40
from conftest import feed_mdb_40
from test_utils.database_utils import get_testing_session, default_db_url


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from feeds_operations_gen.models.update_request_gtfs_rt_feed import (
UpdateRequestGtfsRtFeed,
)
from operations_api.tests.conftest import feed_mdb_41
from conftest import feed_mdb_41
from test_utils.database_utils import get_testing_session, default_db_url


Expand Down
2 changes: 1 addition & 1 deletion scripts/api-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ execute_tests() {
venv/bin/python -m pip install --disable-pip-version-check coverage >/dev/null

# Run tests with coverage. Add the path to the main file and the shared packages that were linked.
PT="src:src/shared:src/test_shared:$PYTHONPATH"
PT="src:src/shared:src/test_shared:tests:$PYTHONPATH"
PYTHONPATH="$PT" venv/bin/coverage run --branch -m pytest -W 'ignore::DeprecationWarning' tests
# Fail if tests fail
if [ $? -ne 0 ]; then
Expand Down

0 comments on commit 6b3c6f6

Please sign in to comment.