From 0d6fa156a68dcd9b1b3368c3c42ff1501ff5b8d8 Mon Sep 17 00:00:00 2001 From: cka-y Date: Fri, 6 Dec 2024 14:21:04 -0500 Subject: [PATCH] fix: PR comment --- .../feed_sync_process_transitland/src/main.py | 8 +++++--- .../tests/test_feed_sync_process.py | 8 ++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/functions-python/feed_sync_process_transitland/src/main.py b/functions-python/feed_sync_process_transitland/src/main.py index bd6e82950..50160e105 100644 --- a/functions-python/feed_sync_process_transitland/src/main.py +++ b/functions-python/feed_sync_process_transitland/src/main.py @@ -94,7 +94,7 @@ def _process_existing_feed_refs( if reference_count > 0: logging.info(f"Updating feed for stable_id: {self.feed_stable_id}") self.feed_stable_id = f"{self.feed_stable_id}_{reference_count}".lower() - new_feed = self._update_feed(payload, active_match[0].id) + new_feed = self._deprecate_old_feed(payload, active_match[0].id) else: logging.info( f"No matching stable_id. Creating new feed for {payload.external_id}." @@ -117,8 +117,10 @@ def _get_current_feeds(self, external_id: str, source: str) -> List[Feed]: .all() ) - def _update_feed(self, payload: FeedPayload, old_feed_id: Optional[str]) -> Feed: - """Update an existing feed with a new URL.""" + def _deprecate_old_feed( + self, payload: FeedPayload, old_feed_id: Optional[str] + ) -> Feed: + """Update the status of an old feed and create a new one.""" if old_feed_id: old_feed = self.session.get(Feed, old_feed_id) if old_feed: diff --git a/functions-python/feed_sync_process_transitland/tests/test_feed_sync_process.py b/functions-python/feed_sync_process_transitland/tests/test_feed_sync_process.py index e3271fdc5..5eb04dba7 100644 --- a/functions-python/feed_sync_process_transitland/tests/test_feed_sync_process.py +++ b/functions-python/feed_sync_process_transitland/tests/test_feed_sync_process.py @@ -378,7 +378,7 @@ def test_process_existing_feed_refs( ) ] processor.feed_stable_id = "tld-feed1" - processor._update_feed = MagicMock( + processor._deprecate_old_feed = MagicMock( return_value=Feed( id="feed-uuid", producer_url="https://example.com/different", @@ -406,11 +406,11 @@ def test_process_existing_feed_refs( def test_update_feed(self, create_new_feed_mock, processor, feed_payload): """Test updating an existing feed.""" # No matching feed - processor._update_feed(feed_payload, None) + processor._deprecate_old_feed(feed_payload, None) create_new_feed_mock.assert_called_once() # Provided id but no db entity processor.session.get.return_value = None - processor._update_feed(feed_payload, "feed-uuid") + processor._deprecate_old_feed(feed_payload, "feed-uuid") create_new_feed_mock.assert_called() # Update existing feed returned_feed = Gtfsfeed( @@ -420,5 +420,5 @@ def test_update_feed(self, create_new_feed_mock, processor, feed_payload): status="active", ) processor.session.get.return_value = returned_feed - processor._update_feed(feed_payload, "feed-uuid") + processor._deprecate_old_feed(feed_payload, "feed-uuid") assert returned_feed.status == "deprecated"