Skip to content

Commit 0a7473a

Browse files
committed
add autodiscovery url if not listed as a endpoint
1 parent 88940c8 commit 0a7473a

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

functions-python/gbfs_validator/src/gbfs_data_processor.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,13 @@ def extract_gbfs_endpoints(
114114
language = None
115115
print(language)
116116
endpoints += GBFSEndpoint.from_dict(feed_match.value, language)
117+
118+
# If the autodiscovery endpoint is not listed then add it
119+
if not any(endpoint.name == "gbfs" for endpoint in endpoints):
120+
endpoints += GBFSEndpoint.from_dict(
121+
[{"name": "gbfs", "url": gbfs_json_url}], None
122+
)
123+
117124
unique_endpoints = list(
118125
{
119126
f"{endpoint.name}, {endpoint.language or ''}": endpoint

functions-python/gbfs_validator/tests/test_gbfs_data_processor.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,5 +235,10 @@ def test_fetch_gbfs_files(
235235
# Validate versions
236236
self.assertEqual(len(gbfs_feed.gbfsversions), 2)
237237
versions = [version.version for version in gbfs_feed.gbfsversions]
238+
# Validate that autodiscovery url endpoint is added to all versions
239+
for gbfs_version in gbfs_feed.gbfsversions:
240+
assert any(
241+
endpoint.name == "gbfs" for endpoint in gbfs_version.gbfsendpoints
242+
)
238243
self.assertIn("2.2", versions)
239244
self.assertIn("2.1", versions)

liquibase/changelog.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,5 @@
5353
<!-- Materialized view updated. Used Feed.official field as official status. -->
5454
<include file="changes/feat_1083.sql" relativeToChangelogFile="true"/>
5555
<include file="changes/feat_1132.sql" relativeToChangelogFile="true"/>
56+
<include file="changes/feat_1124.sql" relativeToChangelogFile="true"/>
5657
</databaseChangeLog>

0 commit comments

Comments
 (0)