Skip to content

Commit c109375

Browse files
committed
Two attributes added with tests
1 parent 2b3f668 commit c109375

File tree

7 files changed

+97
-45
lines changed

7 files changed

+97
-45
lines changed

source/jormungandr/jormungandr/interfaces/v1/serializer/status.py

+2
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@ class TravelerProfilesSerializer(serpy.Serializer):
149149
max_bss_direct_path_duration = Field(schema_type=int)
150150
max_car_direct_path_duration = Field(schema_type=int)
151151
max_ridesharing_direct_path_duration = Field(schema_type=int)
152+
max_taxi_direct_path_duration = Field(schema_type=int)
153+
max_car_no_park_direct_path_duration = Field(schema_type=int)
152154

153155

154156
class AutocompleteSerializer(serpy.DictSerializer):

source/jormungandr/jormungandr/travelers_profile.py

+13-5
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,13 @@ def __init__(
5959
max_car_duration_to_pt=15 * 60, # type: int
6060
walking_step_penalty=30.0, # type: float
6161
walking_use_hills=0.5, # type: float
62-
max_walking_direct_path_duration=24 * 60 * 60, # type: int
63-
max_bike_direct_path_duration=24 * 60 * 60, # type: int
64-
max_bss_direct_path_duration=24 * 60 * 60, # type: int
65-
max_car_direct_path_duration=24 * 60 * 60, # type: int
66-
max_ridesharing_direct_path_duration=24 * 60 * 60, # type: int
62+
max_walking_direct_path_duration=60 * 60, # type: int
63+
max_bike_direct_path_duration=60 * 60, # type: int
64+
max_bss_direct_path_duration=60 * 60, # type: int
65+
max_car_direct_path_duration=40 * 60, # type: int
66+
max_ridesharing_direct_path_duration=60 * 60, # type: int
67+
max_taxi_direct_path_duration=60 * 60, # type: int
68+
max_car_no_park_direct_path_duration=30 * 60, # type: int
6769
traveler_type='', # type: Text
6870
is_from_db=False, # type: bool
6971
):
@@ -101,6 +103,8 @@ def __init__(
101103
self.max_bss_direct_path_duration = max_bss_direct_path_duration
102104
self.max_car_direct_path_duration = max_car_direct_path_duration
103105
self.max_ridesharing_direct_path_duration = max_ridesharing_direct_path_duration
106+
self.max_taxi_direct_path_duration = max_taxi_direct_path_duration
107+
self.max_car_no_park_direct_path_duration = max_car_no_park_direct_path_duration
104108

105109
self.wheelchair = wheelchair
106110

@@ -127,6 +131,8 @@ def override_params(self, args):
127131
('max_bss_direct_path_duration', self.max_bss_direct_path_duration),
128132
('max_car_direct_path_duration', self.max_car_direct_path_duration),
129133
('max_ridesharing_direct_path_duration', self.max_ridesharing_direct_path_duration),
134+
('max_taxi_direct_path_duration', self.max_taxi_direct_path_duration),
135+
('max_car_no_park_direct_path_duration', self.max_car_no_park_direct_path_duration),
130136
)
131137

132138
def override(pair):
@@ -181,6 +187,8 @@ def make_traveler_profile(cls, coverage, traveler_type):
181187
max_bss_direct_path_duration=model.max_bss_direct_path_duration,
182188
max_car_direct_path_duration=model.max_car_direct_path_duration,
183189
max_ridesharing_direct_path_duration=model.max_ridesharing_direct_path_duration,
190+
max_taxi_direct_path_duration=model.max_taxi_direct_path_duration,
191+
max_car_no_park_direct_path_duration=model.max_car_no_park_direct_path_duration,
184192
is_from_db=True,
185193
)
186194

source/navitiacommon/navitiacommon/default_traveler_profile_params.py

+49-35
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,13 @@
4343
'last_section_mode': ['walking', 'bss', 'bike'],
4444
'walking_step_penalty': 30.0,
4545
'walking_use_hills': 0.5,
46-
'max_walking_direct_path_duration': 24 * 60 * 60,
47-
'max_bike_direct_path_duration': 24 * 60 * 60,
48-
'max_bss_direct_path_duration': 24 * 60 * 60,
49-
'max_car_direct_path_duration': 24 * 60 * 60,
50-
'max_ridesharing_direct_path_duration': 24 * 60 * 60,
46+
'max_walking_direct_path_duration': 60 * 60,
47+
'max_bike_direct_path_duration': 60 * 60,
48+
'max_bss_direct_path_duration': 60 * 60,
49+
'max_car_direct_path_duration': 40 * 60,
50+
'max_ridesharing_direct_path_duration': 60 * 60,
51+
'max_taxi_direct_path_duration': 60 * 60,
52+
'max_car_no_park_direct_path_duration': 30 * 60,
5153
},
5254
'slow_walker': {
5355
'traveler_type': 'slow_walker',
@@ -63,11 +65,13 @@
6365
'last_section_mode': ['walking', 'bss', 'bike'],
6466
'walking_step_penalty': 30.0,
6567
'walking_use_hills': 0.5,
66-
'max_walking_direct_path_duration': 24 * 60 * 60,
67-
'max_bike_direct_path_duration': 24 * 60 * 60,
68-
'max_bss_direct_path_duration': 24 * 60 * 60,
69-
'max_car_direct_path_duration': 24 * 60 * 60,
70-
'max_ridesharing_direct_path_duration': 24 * 60 * 60,
68+
'max_walking_direct_path_duration': 60 * 60,
69+
'max_bike_direct_path_duration': 60 * 60,
70+
'max_bss_direct_path_duration': 60 * 60,
71+
'max_car_direct_path_duration': 40 * 60,
72+
'max_ridesharing_direct_path_duration': 60 * 60,
73+
'max_taxi_direct_path_duration': 60 * 60,
74+
'max_car_no_park_direct_path_duration': 30 * 60,
7175
},
7276
'fast_walker': {
7377
'traveler_type': 'fast_walker',
@@ -83,11 +87,13 @@
8387
'last_section_mode': ['walking', 'bss', 'bike'],
8488
'walking_step_penalty': 30.0,
8589
'walking_use_hills': 0.5,
86-
'max_walking_direct_path_duration': 24 * 60 * 60,
87-
'max_bike_direct_path_duration': 24 * 60 * 60,
88-
'max_bss_direct_path_duration': 24 * 60 * 60,
89-
'max_car_direct_path_duration': 24 * 60 * 60,
90-
'max_ridesharing_direct_path_duration': 24 * 60 * 60,
90+
'max_walking_direct_path_duration': 60 * 60,
91+
'max_bike_direct_path_duration': 60 * 60,
92+
'max_bss_direct_path_duration': 60 * 60,
93+
'max_car_direct_path_duration': 40 * 60,
94+
'max_ridesharing_direct_path_duration': 60 * 60,
95+
'max_taxi_direct_path_duration': 60 * 60,
96+
'max_car_no_park_direct_path_duration': 30 * 60,
9197
},
9298
'luggage': {
9399
'traveler_type': 'luggage',
@@ -104,11 +110,13 @@
104110
'wheelchair': True,
105111
'walking_step_penalty': 3600.0,
106112
'walking_use_hills': 0,
107-
'max_walking_direct_path_duration': 24 * 60 * 60,
108-
'max_bike_direct_path_duration': 24 * 60 * 60,
109-
'max_bss_direct_path_duration': 24 * 60 * 60,
110-
'max_car_direct_path_duration': 24 * 60 * 60,
111-
'max_ridesharing_direct_path_duration': 24 * 60 * 60,
113+
'max_walking_direct_path_duration': 60 * 60,
114+
'max_bike_direct_path_duration': 60 * 60,
115+
'max_bss_direct_path_duration': 60 * 60,
116+
'max_car_direct_path_duration': 40 * 60,
117+
'max_ridesharing_direct_path_duration': 60 * 60,
118+
'max_taxi_direct_path_duration': 60 * 60,
119+
'max_car_no_park_direct_path_duration': 30 * 60,
112120
},
113121
'wheelchair': {
114122
'traveler_type': 'wheelchair',
@@ -125,11 +133,13 @@
125133
'wheelchair': True,
126134
'walking_step_penalty': 3600.0,
127135
'walking_use_hills': 0,
128-
'max_walking_direct_path_duration': 24 * 60 * 60,
129-
'max_bike_direct_path_duration': 24 * 60 * 60,
130-
'max_bss_direct_path_duration': 24 * 60 * 60,
131-
'max_car_direct_path_duration': 24 * 60 * 60,
132-
'max_ridesharing_direct_path_duration': 24 * 60 * 60,
136+
'max_walking_direct_path_duration': 60 * 60,
137+
'max_bike_direct_path_duration': 60 * 60,
138+
'max_bss_direct_path_duration': 60 * 60,
139+
'max_car_direct_path_duration': 40 * 60,
140+
'max_ridesharing_direct_path_duration': 60 * 60,
141+
'max_taxi_direct_path_duration': 60 * 60,
142+
'max_car_no_park_direct_path_duration': 30 * 60,
133143
},
134144
# Temporary Profile
135145
'cyclist': {
@@ -146,11 +156,13 @@
146156
'last_section_mode': ['walking', 'bss'],
147157
'walking_step_penalty': 30.0,
148158
'walking_use_hills': 0.5,
149-
'max_walking_direct_path_duration': 24 * 60 * 60,
150-
'max_bike_direct_path_duration': 24 * 60 * 60,
151-
'max_bss_direct_path_duration': 24 * 60 * 60,
152-
'max_car_direct_path_duration': 24 * 60 * 60,
153-
'max_ridesharing_direct_path_duration': 24 * 60 * 60,
159+
'max_walking_direct_path_duration': 60 * 60,
160+
'max_bike_direct_path_duration': 60 * 60,
161+
'max_bss_direct_path_duration': 60 * 60,
162+
'max_car_direct_path_duration': 40 * 60,
163+
'max_ridesharing_direct_path_duration': 60 * 60,
164+
'max_taxi_direct_path_duration': 60 * 60,
165+
'max_car_no_park_direct_path_duration': 30 * 60,
154166
},
155167
# Temporary Profile
156168
'motorist': {
@@ -167,11 +179,13 @@
167179
'last_section_mode': ['walking'],
168180
'walking_step_penalty': 30.0,
169181
'walking_use_hills': 0.5,
170-
'max_walking_direct_path_duration': 24 * 60 * 60,
171-
'max_bike_direct_path_duration': 24 * 60 * 60,
172-
'max_bss_direct_path_duration': 24 * 60 * 60,
173-
'max_car_direct_path_duration': 24 * 60 * 60,
174-
'max_ridesharing_direct_path_duration': 24 * 60 * 60,
182+
'max_walking_direct_path_duration': 60 * 60,
183+
'max_bike_direct_path_duration': 60 * 60,
184+
'max_bss_direct_path_duration': 60 * 60,
185+
'max_car_direct_path_duration': 40 * 60,
186+
'max_ridesharing_direct_path_duration': 60 * 60,
187+
'max_taxi_direct_path_duration': 60 * 60,
188+
'max_car_no_park_direct_path_duration': 30 * 60,
175189
},
176190
}
177191

source/navitiacommon/navitiacommon/models/__init__.py

+14
Original file line numberDiff line numberDiff line change
@@ -1209,6 +1209,20 @@ class TravelerProfile(db.Model): # type: ignore
12091209
server_default=str(default_values.max_ridesharing_direct_path_duration),
12101210
)
12111211

1212+
max_taxi_direct_path_duration = db.Column(
1213+
db.Integer,
1214+
default=default_values.max_taxi_direct_path_duration,
1215+
nullable=False,
1216+
server_default=str(default_values.max_taxi_direct_path_duration),
1217+
)
1218+
1219+
max_car_no_park_direct_path_duration = db.Column(
1220+
db.Integer,
1221+
default=default_values.max_car_no_park_direct_path_duration,
1222+
nullable=False,
1223+
server_default=str(default_values.max_car_no_park_direct_path_duration),
1224+
)
1225+
12121226
@classmethod
12131227
def get_by_coverage_and_type(cls, coverage, traveler_type):
12141228
model = (

source/tyr/migrations/versions/79bd4783fd9e_add_walking_and_bike_params.py

+10
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,14 @@ def upgrade():
101101
'traveler_profile',
102102
sa.Column('max_ridesharing_direct_path_duration', sa.Integer(), server_default='86400', nullable=False),
103103
)
104+
op.add_column(
105+
'traveler_profile',
106+
sa.Column('max_taxi_direct_path_duration', sa.Integer(), server_default='86400', nullable=False),
107+
)
108+
op.add_column(
109+
'traveler_profile',
110+
sa.Column('max_car_no_park_direct_path_duration', sa.Integer(), server_default='86400', nullable=False),
111+
)
104112

105113

106114
def downgrade():
@@ -138,3 +146,5 @@ def downgrade():
138146
op.drop_column('traveler_profile', 'max_bss_direct_path_duration')
139147
op.drop_column('traveler_profile', 'max_car_direct_path_duration')
140148
op.drop_column('traveler_profile', 'max_ridesharing_direct_path_duration')
149+
op.drop_column('traveler_profile', 'max_taxi_direct_path_duration')
150+
op.drop_column('traveler_profile', 'max_car_no_park_direct_path_duration')

source/tyr/tests/integration/instance_test.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -393,9 +393,11 @@ def test_create_traveler_profile(create_instance, traveler_profile_params):
393393
check_traveler_profile(resp[0], traveler_profile_params)
394394

395395
# Let's check some attributes absent in traveler_profile_params
396-
# They should have default value of database
397-
assert resp[0]['max_car_direct_path_duration'] == 24 * 60 * 60
398-
assert resp[0]['max_ridesharing_direct_path_duration'] == 24 * 60 * 60
396+
# They should have default value of default_traveler_profile_params
397+
assert resp[0]['max_car_direct_path_duration'] == 40 * 60
398+
assert resp[0]['max_ridesharing_direct_path_duration'] == 60 * 60
399+
assert resp[0]['max_taxi_direct_path_duration'] == 60 * 60
400+
assert resp[0]['max_car_no_park_direct_path_duration'] == 30 * 60
399401

400402
# Those present in traveler_profile_params should have values as declared
401403
assert resp[0]['walking_use_hills'] == 0.5
@@ -422,8 +424,8 @@ def test_update_traveler_profile(create_instance, traveler_profile_params):
422424

423425
# Let's check some attributes absent in traveler_profile_params
424426
# They should have default value of database
425-
assert resp[0]['max_car_direct_path_duration'] == 24 * 60 * 60
426-
assert resp[0]['max_ridesharing_direct_path_duration'] == 24 * 60 * 60
427+
assert resp[0]['max_car_direct_path_duration'] == 40 * 60
428+
assert resp[0]['max_ridesharing_direct_path_duration'] == 60 * 60
427429

428430
# Those present in traveler_profile_params should have values as declared
429431
assert resp[0]['walking_use_hills'] == 0.5

source/tyr/tyr/fields.py

+2
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ def format(self, value):
145145
'max_bss_direct_path_duration': fields.Raw,
146146
'max_car_direct_path_duration': fields.Raw,
147147
'max_ridesharing_direct_path_duration': fields.Raw,
148+
'max_taxi_direct_path_duration': fields.Raw,
149+
'max_car_no_park_direct_path_duration': fields.Raw,
148150
'error': fields.String,
149151
}
150152

0 commit comments

Comments
 (0)