herepy 3.6.4__tar.gz → 3.6.5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. {herepy-3.6.4 → herepy-3.6.5}/PKG-INFO +1 -1
  2. {herepy-3.6.4 → herepy-3.6.5}/herepy/__init__.py +1 -1
  3. {herepy-3.6.4 → herepy-3.6.5}/herepy/routing_api.py +17 -3
  4. {herepy-3.6.4 → herepy-3.6.5}/herepy.egg-info/PKG-INFO +1 -1
  5. {herepy-3.6.4 → herepy-3.6.5}/tests/test_routing_api.py +45 -5
  6. {herepy-3.6.4 → herepy-3.6.5}/COPYING +0 -0
  7. {herepy-3.6.4 → herepy-3.6.5}/LICENSE +0 -0
  8. {herepy-3.6.4 → herepy-3.6.5}/MANIFEST.in +0 -0
  9. {herepy-3.6.4 → herepy-3.6.5}/NOTICE +0 -0
  10. {herepy-3.6.4 → herepy-3.6.5}/README.rst +0 -0
  11. {herepy-3.6.4 → herepy-3.6.5}/herepy/destination_weather_api.py +0 -0
  12. {herepy-3.6.4 → herepy-3.6.5}/herepy/error.py +0 -0
  13. {herepy-3.6.4 → herepy-3.6.5}/herepy/ev_charging_stations_api.py +0 -0
  14. {herepy-3.6.4 → herepy-3.6.5}/herepy/fleet_telematics_api.py +0 -0
  15. {herepy-3.6.4 → herepy-3.6.5}/herepy/geocoder_api.py +0 -0
  16. {herepy-3.6.4 → herepy-3.6.5}/herepy/geocoder_autocomplete_api.py +0 -0
  17. {herepy-3.6.4 → herepy-3.6.5}/herepy/geocoder_reverse_api.py +0 -0
  18. {herepy-3.6.4 → herepy-3.6.5}/herepy/here_api.py +0 -0
  19. {herepy-3.6.4 → herepy-3.6.5}/herepy/here_enum.py +0 -0
  20. {herepy-3.6.4 → herepy-3.6.5}/herepy/isoline_routing_api.py +0 -0
  21. {herepy-3.6.4 → herepy-3.6.5}/herepy/map_image_api.py +0 -0
  22. {herepy-3.6.4 → herepy-3.6.5}/herepy/map_tile_api.py +0 -0
  23. {herepy-3.6.4 → herepy-3.6.5}/herepy/mercator_projection.py +0 -0
  24. {herepy-3.6.4 → herepy-3.6.5}/herepy/models.py +0 -0
  25. {herepy-3.6.4 → herepy-3.6.5}/herepy/objects.py +0 -0
  26. {herepy-3.6.4 → herepy-3.6.5}/herepy/places_api.py +0 -0
  27. {herepy-3.6.4 → herepy-3.6.5}/herepy/platform/__init__.py +0 -0
  28. {herepy-3.6.4 → herepy-3.6.5}/herepy/platform/tour_planning_api.py +0 -0
  29. {herepy-3.6.4 → herepy-3.6.5}/herepy/polling.py +0 -0
  30. {herepy-3.6.4 → herepy-3.6.5}/herepy/public_transit_api.py +0 -0
  31. {herepy-3.6.4 → herepy-3.6.5}/herepy/py.typed +0 -0
  32. {herepy-3.6.4 → herepy-3.6.5}/herepy/rme_api.py +0 -0
  33. {herepy-3.6.4 → herepy-3.6.5}/herepy/traffic_api.py +0 -0
  34. {herepy-3.6.4 → herepy-3.6.5}/herepy/utils.py +0 -0
  35. {herepy-3.6.4 → herepy-3.6.5}/herepy/vector_tile_api.py +0 -0
  36. {herepy-3.6.4 → herepy-3.6.5}/herepy.egg-info/SOURCES.txt +0 -0
  37. {herepy-3.6.4 → herepy-3.6.5}/herepy.egg-info/dependency_links.txt +0 -0
  38. {herepy-3.6.4 → herepy-3.6.5}/herepy.egg-info/requires.txt +0 -0
  39. {herepy-3.6.4 → herepy-3.6.5}/herepy.egg-info/top_level.txt +0 -0
  40. {herepy-3.6.4 → herepy-3.6.5}/requirements.txt +0 -0
  41. {herepy-3.6.4 → herepy-3.6.5}/setup.cfg +0 -0
  42. {herepy-3.6.4 → herepy-3.6.5}/setup.py +0 -0
  43. {herepy-3.6.4 → herepy-3.6.5}/tests/test_destination_weather_api.py +0 -0
  44. {herepy-3.6.4 → herepy-3.6.5}/tests/test_enum.py +0 -0
  45. {herepy-3.6.4 → herepy-3.6.5}/tests/test_ev_charging_stations_api.py +0 -0
  46. {herepy-3.6.4 → herepy-3.6.5}/tests/test_fleet_telematics_api.py +0 -0
  47. {herepy-3.6.4 → herepy-3.6.5}/tests/test_geocoder_api.py +0 -0
  48. {herepy-3.6.4 → herepy-3.6.5}/tests/test_geocoder_autocomplete_api.py +0 -0
  49. {herepy-3.6.4 → herepy-3.6.5}/tests/test_geocoder_reverse_api.py +0 -0
  50. {herepy-3.6.4 → herepy-3.6.5}/tests/test_isoline_routing_api.py +0 -0
  51. {herepy-3.6.4 → herepy-3.6.5}/tests/test_map_image_api.py +0 -0
  52. {herepy-3.6.4 → herepy-3.6.5}/tests/test_map_tile_api.py +0 -0
  53. {herepy-3.6.4 → herepy-3.6.5}/tests/test_mercator_projection.py +0 -0
  54. {herepy-3.6.4 → herepy-3.6.5}/tests/test_models.py +0 -0
  55. {herepy-3.6.4 → herepy-3.6.5}/tests/test_places_api.py +0 -0
  56. {herepy-3.6.4 → herepy-3.6.5}/tests/test_publictransit_api.py +0 -0
  57. {herepy-3.6.4 → herepy-3.6.5}/tests/test_rme_api.py +0 -0
  58. {herepy-3.6.4 → herepy-3.6.5}/tests/test_traffic_api.py +0 -0
  59. {herepy-3.6.4 → herepy-3.6.5}/tests/test_utils.py +0 -0
  60. {herepy-3.6.4 → herepy-3.6.5}/tests/test_vector_tile_api.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: herepy
3
- Version: 3.6.4
3
+ Version: 3.6.5
4
4
  Summary: A library that provides a Python interface to the HERE APIs
5
5
  Home-page: https://github.com/abdullahselek/HerePy
6
6
  Download-URL: https://pypi.org/pypi/herepy
@@ -6,7 +6,7 @@ __author__ = "Abdullah Selek"
6
6
  __email__ = "abdullahselek.os@gmail.com"
7
7
  __copyright__ = "Copyright (c) 2017 Abdullah Selek"
8
8
  __license__ = "MIT License"
9
- __version__ = "3.6.4"
9
+ __version__ = "3.6.5"
10
10
  __url__ = "https://github.com/abdullahselek/HerePy"
11
11
  __download_url__ = "https://pypi.org/pypi/herepy"
12
12
  __description__ = "A library that provides a Python interface to the HERE APIs"
@@ -5,6 +5,7 @@ import json
5
5
  import os
6
6
  import sys
7
7
  from typing import Dict, List, Optional, Union
8
+ from warnings import warn
8
9
 
9
10
  import requests
10
11
 
@@ -49,12 +50,13 @@ class RoutingApi(HEREApi):
49
50
  response_cls,
50
51
  manipulation_key: str = None,
51
52
  keys_for_manipulation: List = None,
53
+ headers: Optional[Dict[str, str]] = None,
52
54
  ):
53
55
  url = Utils.build_url(base_url, extra_params=data)
54
56
  if manipulation_key and keys_for_manipulation:
55
57
  for k in keys_for_manipulation:
56
58
  url = url.replace(k, manipulation_key)
57
- response = requests.get(url, timeout=self._timeout)
59
+ response = requests.get(url, timeout=self._timeout, headers=headers)
58
60
  json_data = json.loads(response.content.decode("utf8"))
59
61
  if response.status_code == requests.codes.OK:
60
62
  return response_cls.new_from_jsondict(json_data)
@@ -370,6 +372,7 @@ class RoutingApi(HEREApi):
370
372
  return_fields: List[RoutingApiReturnField] = [RoutingApiReturnField.polyline],
371
373
  span_fields: Optional[List[RoutingApiSpanField]] = None,
372
374
  truck: Optional[Dict[str, List[str]]] = None,
375
+ vehicle: Optional[Dict[str, List[str]]] = None,
373
376
  scooter: Optional[Dict[str, str]] = None,
374
377
  headers: Optional[dict] = None,
375
378
  ) -> Optional[RoutingResponseV8]:
@@ -417,7 +420,9 @@ class RoutingApi(HEREApi):
417
420
  For example, attributes,length will enable the fields attributes and length in the route response.
418
421
  This parameter also requires that the polyline option is set within the return parameter.
419
422
  truck (Optional[Dict[str, List[str]]]):
420
- Comma-separated list of shipped hazardous goods in the vehicle.
423
+ Deprecated. Use `vehicle` parameter.
424
+ vehicle (Optional[Dict[str, List[str]]]):
425
+ Comma-separated list of vehicle-specific parameters.
421
426
  Sample use of parameter: `{"shippedHazardousGoods": [explosive, gas, flammable]}`
422
427
  scooter (Optional[Dict[str, str]]):
423
428
  Scooter specific parameters.
@@ -469,7 +474,15 @@ class RoutingApi(HEREApi):
469
474
  if span_fields:
470
475
  data["spans"] = ",".join([field.__str__() for field in span_fields])
471
476
  if truck:
472
- data["truck"] = {key: ",".join(vals) for key, vals in truck.items()}
477
+ warn(
478
+ "'truck' parameter is deprecated in Routing API. Use 'vehicle' parameter instead.",
479
+ DeprecationWarning,
480
+ stacklevel=2,
481
+ )
482
+ if vehicle is None:
483
+ vehicle = truck
484
+ if vehicle:
485
+ data["vehicle"] = {key: ",".join(vals) for key, vals in vehicle.items()}
473
486
  if scooter:
474
487
  data["scooter"] = scooter
475
488
 
@@ -480,6 +493,7 @@ class RoutingApi(HEREApi):
480
493
  RoutingResponseV8,
481
494
  manipulation_key="via",
482
495
  keys_for_manipulation=via_keys,
496
+ headers=headers
483
497
  )
484
498
  return response
485
499
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: herepy
3
- Version: 3.6.4
3
+ Version: 3.6.5
4
4
  Summary: A library that provides a Python interface to the HERE APIs
5
5
  Home-page: https://github.com/abdullahselek/HerePy
6
6
  Download-URL: https://pypi.org/pypi/herepy
@@ -3,6 +3,7 @@
3
3
  import codecs
4
4
  import datetime
5
5
  import unittest
6
+ import pytest
6
7
 
7
8
  import responses
8
9
 
@@ -1095,7 +1096,7 @@ class RoutingApiTest(unittest.TestCase):
1095
1096
  lang="tr-TR",
1096
1097
  return_fields=[herepy.RoutingApiReturnField.polyline],
1097
1098
  span_fields=[herepy.RoutingApiSpanField.walkAttributes],
1098
- truck={"shippedHazardousGoods": ["explosive", "gas"]},
1099
+ vehicle={"shippedHazardousGoods": ["explosive", "gas"]},
1099
1100
  scooter={"allowHighway": "true"},
1100
1101
  )
1101
1102
  self.assertTrue(response)
@@ -1129,7 +1130,7 @@ class RoutingApiTest(unittest.TestCase):
1129
1130
  lang="tr-TR",
1130
1131
  return_fields=[herepy.RoutingApiReturnField.polyline],
1131
1132
  span_fields=[herepy.RoutingApiSpanField.walkAttributes],
1132
- truck={"shippedHazardousGoods": ["explosive", "gas"]},
1133
+ vehicle={"shippedHazardousGoods": ["explosive", "gas"]},
1133
1134
  scooter={"allowHighway": "true"},
1134
1135
  )
1135
1136
 
@@ -1190,7 +1191,7 @@ class RoutingApiTest(unittest.TestCase):
1190
1191
  lang="tr-TR",
1191
1192
  return_fields=[herepy.RoutingApiReturnField.polyline],
1192
1193
  span_fields=[herepy.RoutingApiSpanField.walkAttributes],
1193
- truck={"shippedHazardousGoods": ["explosive", "gas"]},
1194
+ vehicle={"shippedHazardousGoods": ["explosive", "gas"]},
1194
1195
  scooter={"allowHighway": "true"},
1195
1196
  )
1196
1197
 
@@ -1225,12 +1226,51 @@ class RoutingApiTest(unittest.TestCase):
1225
1226
  status=200,
1226
1227
  match=[
1227
1228
  responses.matchers.query_param_matcher(
1228
- {"truck[height]": "15000", "truck[width]": "3000"}, strict_match=False
1229
+ {"vehicle[height]": "15000", "vehicle[width]": "3000"}, strict_match=False
1229
1230
  )
1230
1231
  ],
1231
1232
  )
1232
1233
  self._api.route_v8(transport_mode=herepy.RoutingTransportMode.truck,
1233
1234
  origin=[41.9798, -87.8801],
1234
1235
  destination=[41.9043, -87.9216],
1235
- truck={"height": ["15000"], "width": ["3000"]}
1236
+ vehicle={"height": ["15000"], "width": ["3000"]}
1236
1237
  )
1238
+
1239
+ @responses.activate
1240
+ @pytest.mark.filterwarnings("ignore:'truck' parameter is deprecated")
1241
+ def test_route_v8_truck_parameter_deprecated(self):
1242
+ responses.add(
1243
+ responses.GET,
1244
+ "https://router.hereapi.com/v8/routes",
1245
+ "{}",
1246
+ status=200,
1247
+ match=[
1248
+ responses.matchers.query_param_matcher(
1249
+ {"vehicle[height]": "15000", "vehicle[width]": "3000"},
1250
+ strict_match=False,
1251
+ )
1252
+ ],
1253
+ )
1254
+ self._api.route_v8(
1255
+ transport_mode=herepy.RoutingTransportMode.truck,
1256
+ origin=[41.9798, -87.8801],
1257
+ destination=[41.9043, -87.9216],
1258
+ truck={"height": ["15000"], "width": ["3000"]},
1259
+ )
1260
+
1261
+ @responses.activate
1262
+ def test_route_v8_headers_in_request(self):
1263
+ resp = responses.add(
1264
+ responses.GET,
1265
+ "https://router.hereapi.com/v8/routes",
1266
+ "{}",
1267
+ status=200,
1268
+ )
1269
+ self._api.route_v8(
1270
+ transport_mode=herepy.RoutingTransportMode.truck,
1271
+ origin=[41.9798, -87.8801],
1272
+ destination=[41.9043, -87.9216],
1273
+ headers={"X-BIP": "BOP"},
1274
+ )
1275
+ original_request = resp.calls[0].request
1276
+ self.assertEqual(original_request.headers.get("X-BIP"), "BOP")
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes