-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4487 from geoadmin/feat_PB-974_migration_from_tri…
…as_to_ojp_for_transport_stop_requests PB-974: Migration from trias to ojp for transport stop requests
- Loading branch information
Showing
10 changed files
with
1,545 additions
and
1,006 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
def generate_mock_response(departures, now): | ||
"""Generate a dynamic mock OJP response with correct structure.""" | ||
departure_events = "".join( | ||
f""" | ||
<StopEventResult> | ||
<StopEvent> | ||
<ThisCall> | ||
<CallAtStop> | ||
<siri:StopPointRef>{dep['id']}</siri:StopPointRef> | ||
<StopPointName> | ||
<Text>{dep['label']}</Text> | ||
</StopPointName> | ||
<ServiceDeparture> | ||
<TimetabledTime>{dep['departureDate']}</TimetabledTime> | ||
<EstimatedTime>{dep.get('estimatedDate', dep['departureDate'])}</EstimatedTime> | ||
</ServiceDeparture> | ||
</CallAtStop> | ||
</ThisCall> | ||
<Service> | ||
<PublishedServiceName> | ||
<Text>{dep['label']}</Text> | ||
</PublishedServiceName> | ||
<DestinationText> | ||
<Text>{dep['destinationName']}</Text> | ||
</DestinationText> | ||
<DestinationStopPointRef>{dep['destinationId']}</DestinationStopPointRef> | ||
</Service> | ||
</StopEvent> | ||
</StopEventResult> | ||
""" | ||
for dep in departures | ||
) | ||
|
||
mock_response = f"""<?xml version="1.0" ?> | ||
<OJP xmlns:siri="http://www.siri.org.uk/siri" xmlns="http://www.vdv.de/ojp" version="2.0"> | ||
<OJPResponse> | ||
<siri:ServiceDelivery> | ||
<siri:ResponseTimestamp>{now}</siri:ResponseTimestamp> | ||
<OJPStopEventDelivery> | ||
<siri:ResponseTimestamp>{now}</siri:ResponseTimestamp> | ||
{departure_events} | ||
</OJPStopEventDelivery> | ||
</siri:ServiceDelivery> | ||
</OJPResponse> | ||
</OJP>""" | ||
|
||
return mock_response | ||
|
||
|
||
def generate_mock_empty_response(now): | ||
# This mocked response will contain just enough for parsing, but will | ||
# lead to no detected station, i.e.: station not existing case | ||
mock_response = f"""<?xml version="1.0" ?> | ||
<OJP xmlns:siri="http://www.siri.org.uk/siri" xmlns="http://www.vdv.de/ojp" version="2.0"> | ||
<OJPResponse> | ||
<siri:ServiceDelivery> | ||
<siri:ResponseTimestamp>{now}</siri:ResponseTimestamp> | ||
<OJPStopEventDelivery> | ||
<siri:ResponseTimestamp>{now}</siri:ResponseTimestamp> | ||
<!-- No StopEventResult entries --> | ||
</OJPStopEventDelivery> | ||
</siri:ServiceDelivery> | ||
</OJPResponse> | ||
</OJP>""" | ||
|
||
return mock_response |
Oops, something went wrong.