Skip to content

Commit

Permalink
Merge pull request #4302 from hove-io/omit_s_in_odt_informations
Browse files Browse the repository at this point in the history
Use new commit of navitia-proto
  • Loading branch information
kadhikari authored Sep 2, 2024
2 parents 0297709 + e7bbf87 commit 584e6a3
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 21 deletions.
2 changes: 1 addition & 1 deletion docker/debian8/Dockerfile-tyr-worker
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM navitia/master

# Install some binaries from tartare-tools
ENV TARTARE_TOOLS_VERSION="v0.44.0"
ENV TARTARE_TOOLS_VERSION="v0.45.0"
ARG GITHUB_TOKEN
RUN git config --global url."https://x-access-token:${GITHUB_TOKEN}@github.com/hove-io/".insteadOf "ssh://[email protected]/hove-io/"
RUN git clone -b ${TARTARE_TOOLS_VERSION} --depth 1 https://x-access-token:${GITHUB_TOKEN}@github.com/hove-io/tartare-tools
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ class RidesharingInformationSerializer(PbNestedSerializer):
class OdtInformationSerializer(PbNestedSerializer):
name = jsonschema.Field(schema_type=str, display_none=True)
url = jsonschema.Field(schema_type=str, display_none=True)
conditions = jsonschema.Field(schema_type=str, display_none=True)
condition = jsonschema.Field(schema_type=str, display_none=True)
phone = jsonschema.Field(schema_type=str, display_none=True)
deeplink = jsonschema.Field(schema_type=str, display_none=True)
applies_on = EnumListField(attr='applies_on', pb_type=OdtInformation.AppliesOn)
Expand Down Expand Up @@ -431,7 +431,7 @@ def get_ridesharing_journeys(self, obj):
street_informations = StreetInformationSerializer(
attr="street_network.street_information", many=True, display_none=False
)
odt_informations = OdtInformationSerializer(display_none=False)
odt_information = OdtInformationSerializer(display_none=False)


class JourneySerializer(PbNestedSerializer):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ def odt_information_serialization_test():
journey = resp["journeys"][0]
assert len(journey.get("sections", 0)) == 3
section = journey["sections"][1]
odt_information = section.get("odt_informations", None)
odt_information = section.get("odt_information", None)
assert odt_information is not None
assert odt_information["url"] == "odt_url_value"
assert odt_information["name"] == "odt_name_value"
assert odt_information["phone"] == "odt_phone_value"
assert odt_information["conditions"] == "odt_conditions_value"
assert odt_information["condition"] == "odt_conditions_value"
assert odt_information["deeplink"] == "https://toto.com?from=from_value&to=to_value"
assert odt_information["applies_on"] == ["from"]
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ def get_odt_journey(deeplink):
section.origin.uri = 'stop_a'
section.origin.embedded_type = type_pb2.STOP_POINT
section.origin.stop_point.uri = 'stop_a'
section.origin.stop_point.name = 'stop_a_name'
section.origin.stop_point.name = 'stop a name'
section.origin.stop_point.coord.lon = 1.0
section.origin.stop_point.coord.lat = 2.0
section.destination.uri = 'stop_b'
Expand All @@ -661,11 +661,11 @@ def get_odt_journey(deeplink):
section.destination.stop_point.name = 'stop_b_name'
section.destination.stop_point.coord.lon = 3.0
section.destination.stop_point.coord.lat = 4.0
odt_information = section.odt_informations
odt_information = section.odt_information
odt_information.name = "odt_name_value"
odt_information.deeplink = deeplink
odt_information.url = "odt_url_value"
odt_information.conditions = "odt_conditions_value"
odt_information.condition = "odt_conditions_value"
odt_information.phone = "odt_phone_value"
odt_information.applies_on.append(response_pb2.OdtInformation.AppliesOn.FROM)
section = journey.sections.add()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -847,13 +847,13 @@ def journey_with_odt_information_test():
odt_section = journey.sections[1]
assert odt_section.type == response_pb2.ON_DEMAND_TRANSPORT
assert (
odt_section.odt_informations.deeplink
odt_section.odt_information.deeplink
== "https://domaine/search?departure-address={from_name}&destination-address={to_name}&requested-departure-time={departure_datetime}&from_coord_lat={from_coord_lat}&from_coord_lon={from_coord_lon}&not_managed={not_managed}"
)

update_odt_information_deeplink(response_journey_with_odt)
odt_section = response_journey_with_odt.journeys[0].sections[1]
assert (
odt_section.odt_informations.deeplink
== "https://domaine/search?departure-address=stop_a_name&destination-address=stop_b_name&requested-departure-time=1722924300&from_coord_lat=2.0&from_coord_lon=1.0&not_managed=N/A"
odt_section.odt_information.deeplink
== "https://domaine/search?departure-address=stop%20a%20name&destination-address=stop_b_name&requested-departure-time=1722924300&from_coord_lat=2.0&from_coord_lon=1.0&not_managed=N/A"
)
14 changes: 7 additions & 7 deletions source/jormungandr/jormungandr/scenarios/tests/utils_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,19 +115,19 @@ def journey_with_deeplink_in_odt_information_test():
assert len(journey.sections) == 3
odt_section = journey.sections[1]
assert odt_section.type == response_pb2.ON_DEMAND_TRANSPORT
odt_information = odt_section.odt_informations
odt_information = odt_section.odt_information
assert odt_information.name == "odt_name_value"
assert (
odt_information.deeplink
== "https://domaine/search?departure-address={from_name}&destination-address={to_name}&requested-departure-time={departure_datetime}&from_coord_lat={from_coord_lat}&from_coord_lon={from_coord_lon}&to_coord_lat={to_coord_lat}&to_coord_lon={to_coord_lon}"
)
assert odt_information.url == "odt_url_value"
assert odt_information.conditions == "odt_conditions_value"
assert odt_information.condition == "odt_conditions_value"
assert odt_information.phone == "odt_phone_value"
update_odt_information_deeplink_in_section(odt_section)
assert (
odt_information.deeplink
== "https://domaine/search?departure-address=stop_a_name&destination-address=stop_b_name&requested-departure-time=1722924300&from_coord_lat=2.0&from_coord_lon=1.0&to_coord_lat=4.0&to_coord_lon=3.0"
== "https://domaine/search?departure-address=stop%20a%20name&destination-address=stop_b_name&requested-departure-time=1722924300&from_coord_lat=2.0&from_coord_lon=1.0&to_coord_lat=4.0&to_coord_lon=3.0"
)

# Use a deeplink with fewer placeholders
Expand All @@ -139,8 +139,8 @@ def journey_with_deeplink_in_odt_information_test():
odt_section = response_journey_with_odt.journeys[0].sections[1]
update_odt_information_deeplink_in_section(odt_section)
assert (
odt_section.odt_informations.deeplink
== "https://domaine/search?departure-address=stop_a_name&destination-address=stop_b_name&requested-departure-time=1722924300&from_coord_lat=2.0&from_coord_lon=1.0"
odt_section.odt_information.deeplink
== "https://domaine/search?departure-address=stop%20a%20name&destination-address=stop_b_name&requested-departure-time=1722924300&from_coord_lat=2.0&from_coord_lon=1.0"
)

# Add a placeholder which is not predefined in the function to update deeplink
Expand All @@ -154,6 +154,6 @@ def journey_with_deeplink_in_odt_information_test():
odt_section = response_journey_with_odt.journeys[0].sections[1]
update_odt_information_deeplink_in_section(odt_section)
assert (
odt_section.odt_informations.deeplink
== "https://domaine/search?departure-address=stop_a_name&destination-address=stop_b_name&requested-departure-time=1722924300&from_coord_lat=2.0&from_coord_lon=1.0&toto=N/A"
odt_section.odt_information.deeplink
== "https://domaine/search?departure-address=stop%20a%20name&destination-address=stop_b_name&requested-departure-time=1722924300&from_coord_lat=2.0&from_coord_lon=1.0&toto=N/A"
)
5 changes: 3 additions & 2 deletions source/jormungandr/jormungandr/scenarios/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import navitiacommon.request_pb2 as request_pb2
from future.moves.itertools import zip_longest
from jormungandr.fallback_modes import FallbackModes
import requests as requests
import re
from collections import defaultdict
from string import Formatter
Expand Down Expand Up @@ -560,7 +561,7 @@ def update_odt_information_deeplink_in_section(section):
if section.type != response_pb2.ON_DEMAND_TRANSPORT:
return

deeplink = section.odt_informations.deeplink
deeplink = section.odt_information.deeplink
if not deeplink:
return

Expand Down Expand Up @@ -595,4 +596,4 @@ def update_odt_information_deeplink_in_section(section):
elif p == "to_coord_lon":
placeholder_dict[p] = to_coord_lon

section.odt_informations.deeplink = fmtr.vformat(deeplink, (), placeholder_dict)
section.odt_information.deeplink = requests.utils.requote_uri(fmtr.vformat(deeplink, (), placeholder_dict))
2 changes: 1 addition & 1 deletion source/navitia-proto
Submodule navitia-proto updated 1 files
+2 −2 response.proto

0 comments on commit 584e6a3

Please sign in to comment.