Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions api/src/scripts/populate_db_gtfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ def process_entity_types(self, session: "Session", feed: Gtfsrealtimefeed, row,
"""
entity_types = self.get_safe_value(row, "entity_type", "").replace("|", "-").split("-")
if len(entity_types) > 0:
if any(entity_types):
feed.entitytypes.clear()
for entity_type_name in entity_types:
entity_type = session.query(Entitytype).filter(Entitytype.name == entity_type_name).first()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ mdb_source_id,data_type,entity_type,location.country_code,location.subdivision_n
# For mdb-1562, change is_official from FALSE to TRUE. Should change to True.
# Also change is_producer_url_unstable from base FALSE to TRUE: should change to True.
# Also change is_seasonal from base FALSE to TRUE: should change to True.
# For mdb-1562, first populate sa|vp, then the following row narrows entity_type to sa to verify replacement semantics.
1562,gtfs-rt,sa|vp,CA,BC,Vancouver,Vancouver-Transit(éèàçíóúČ),TRUE,Realtime(ŘŤÜÎ),,,50,http://foo.org/google_transit.zip,0,,,,,,,,,,active,,10,,TRUE,TRUE
1562,gtfs-rt,sa,CA,BC,Vancouver,Vancouver-Transit(éèàçíóúČ),TRUE,Realtime(ŘŤÜÎ),,,50,http://foo.org/google_transit.zip,0,,,,,,,,,,active,,10,,TRUE,TRUE
# For mdb-1563, change is_official from TRUE to FALSE. Should change to False.
# Also change is_producer_url_unstable from base TRUE to FALSE: should change to False.
Expand Down
12 changes: 12 additions & 0 deletions api/tests/integration/populate_tests/test_populate.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,3 +321,15 @@ def test_locationless_gtfs_rt_feed_inherits_union_of_static_feed_locations(
("CA", "Ontario", "London"),
("CA", "Ontario", "Barrie"),
}


def test_entity_types_overwrite(client: TestClient):
"""A later catalog row must replace, not add to, GTFS-RT entity types."""
response = client.request(
"GET",
"/v1/gtfs_rt_feeds/mdb-1562",
headers=authHeaders,
)

assert response.status_code == 200
assert response.json()["entity_types"] == ["sa"]
Loading