geocodio-library-python 1.5.0__tar.gz → 1.6.0__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.
- {geocodio_library_python-1.5.0 → geocodio_library_python-1.6.0}/CHANGELOG.md +6 -0
- {geocodio_library_python-1.5.0 → geocodio_library_python-1.6.0}/PKG-INFO +35 -3
- {geocodio_library_python-1.5.0 → geocodio_library_python-1.6.0}/README.md +34 -2
- {geocodio_library_python-1.5.0 → geocodio_library_python-1.6.0}/pyproject.toml +1 -1
- {geocodio_library_python-1.5.0 → geocodio_library_python-1.6.0}/src/geocodio/__init__.py +5 -0
- {geocodio_library_python-1.5.0 → geocodio_library_python-1.6.0}/src/geocodio/_version.py +1 -1
- {geocodio_library_python-1.5.0 → geocodio_library_python-1.6.0}/src/geocodio/client.py +14 -0
- {geocodio_library_python-1.5.0 → geocodio_library_python-1.6.0}/src/geocodio/distance.py +10 -0
- {geocodio_library_python-1.5.0 → geocodio_library_python-1.6.0}/src/geocodio/models.py +3 -0
- {geocodio_library_python-1.5.0 → geocodio_library_python-1.6.0}/tests/unit/test_distance.py +85 -0
- {geocodio_library_python-1.5.0 → geocodio_library_python-1.6.0}/uv.lock +1 -1
- {geocodio_library_python-1.5.0 → geocodio_library_python-1.6.0}/.github/workflows/ci.yml +0 -0
- {geocodio_library_python-1.5.0 → geocodio_library_python-1.6.0}/.github/workflows/publish.yml +0 -0
- {geocodio_library_python-1.5.0 → geocodio_library_python-1.6.0}/.github/workflows/test-act-event-ci.json +0 -0
- {geocodio_library_python-1.5.0 → geocodio_library_python-1.6.0}/.github/workflows/test-act-event-publish.json +0 -0
- {geocodio_library_python-1.5.0 → geocodio_library_python-1.6.0}/.gitignore +0 -0
- {geocodio_library_python-1.5.0 → geocodio_library_python-1.6.0}/LICENSE +0 -0
- {geocodio_library_python-1.5.0 → geocodio_library_python-1.6.0}/requirements-dev.txt +0 -0
- {geocodio_library_python-1.5.0 → geocodio_library_python-1.6.0}/setup.cfg +0 -0
- {geocodio_library_python-1.5.0 → geocodio_library_python-1.6.0}/smoke.py +0 -0
- {geocodio_library_python-1.5.0 → geocodio_library_python-1.6.0}/smoke_lists.py +0 -0
- {geocodio_library_python-1.5.0 → geocodio_library_python-1.6.0}/src/geocodio/exceptions.py +0 -0
- {geocodio_library_python-1.5.0 → geocodio_library_python-1.6.0}/test_pypi_release.py +0 -0
- {geocodio_library_python-1.5.0 → geocodio_library_python-1.6.0}/tests/__init__.py +0 -0
- {geocodio_library_python-1.5.0 → geocodio_library_python-1.6.0}/tests/conftest.py +0 -0
- {geocodio_library_python-1.5.0 → geocodio_library_python-1.6.0}/tests/e2e/__init__.py +0 -0
- {geocodio_library_python-1.5.0 → geocodio_library_python-1.6.0}/tests/e2e/test_api.py +0 -0
- {geocodio_library_python-1.5.0 → geocodio_library_python-1.6.0}/tests/e2e/test_batch_reverse.py +0 -0
- {geocodio_library_python-1.5.0 → geocodio_library_python-1.6.0}/tests/e2e/test_distance.py +0 -0
- {geocodio_library_python-1.5.0 → geocodio_library_python-1.6.0}/tests/e2e/test_lists_api.py +0 -0
- {geocodio_library_python-1.5.0 → geocodio_library_python-1.6.0}/tests/test_workflows.py +0 -0
- {geocodio_library_python-1.5.0 → geocodio_library_python-1.6.0}/tests/unit/__init__.py +0 -0
- {geocodio_library_python-1.5.0 → geocodio_library_python-1.6.0}/tests/unit/test_client.py +0 -0
- {geocodio_library_python-1.5.0 → geocodio_library_python-1.6.0}/tests/unit/test_errors.py +0 -0
- {geocodio_library_python-1.5.0 → geocodio_library_python-1.6.0}/tests/unit/test_exceptions.py +0 -0
- {geocodio_library_python-1.5.0 → geocodio_library_python-1.6.0}/tests/unit/test_geocode.py +0 -0
- {geocodio_library_python-1.5.0 → geocodio_library_python-1.6.0}/tests/unit/test_geocoding.py +0 -0
- {geocodio_library_python-1.5.0 → geocodio_library_python-1.6.0}/tests/unit/test_models.py +0 -0
- {geocodio_library_python-1.5.0 → geocodio_library_python-1.6.0}/tests/unit/test_reverse.py +0 -0
- {geocodio_library_python-1.5.0 → geocodio_library_python-1.6.0}/tests/unit/test_warnings.py +0 -0
|
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [1.6.0] - 2026-10-12
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
- `calculation_type` parameter on `distance_matrix()` and `create_distance_matrix_job()`, with new `DISTANCE_CALCULATION_TYPE_MATRIX` and `DISTANCE_CALCULATION_TYPE_PAIRS` constants. `"pairs"` measures origin i against destination i only, instead of every origin against every destination.
|
|
14
|
+
- `DistanceJobResponse.calculation_type`, read from job create, status and list responses (`None` when the API does not send it).
|
|
15
|
+
|
|
10
16
|
## [1.5.0] - 2026-10-06
|
|
11
17
|
|
|
12
18
|
### Added
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: geocodio-library-python
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.6.0
|
|
4
4
|
Summary: A Python client for the Geocodio API
|
|
5
5
|
Project-URL: Homepage, https://www.geocod.io
|
|
6
6
|
Project-URL: Documentation, https://www.geocod.io/docs/?python
|
|
@@ -340,6 +340,8 @@ from geocodio import (
|
|
|
340
340
|
DISTANCE_ORDER_BY_DURATION,
|
|
341
341
|
DISTANCE_SORT_ASC, # Default
|
|
342
342
|
DISTANCE_SORT_DESC,
|
|
343
|
+
DISTANCE_CALCULATION_TYPE_MATRIX, # Default - every origin × every destination (distance matrix only)
|
|
344
|
+
DISTANCE_CALCULATION_TYPE_PAIRS, # Origin i to destination i only (distance matrix only)
|
|
343
345
|
)
|
|
344
346
|
```
|
|
345
347
|
|
|
@@ -466,7 +468,13 @@ response = client.distance(
|
|
|
466
468
|
#### Distance matrix (multiple origins × destinations)
|
|
467
469
|
|
|
468
470
|
```python
|
|
469
|
-
from geocodio import
|
|
471
|
+
from geocodio import (
|
|
472
|
+
Geocodio,
|
|
473
|
+
Coordinate,
|
|
474
|
+
DISTANCE_MODE_DRIVING,
|
|
475
|
+
DISTANCE_UNITS_KM,
|
|
476
|
+
DISTANCE_CALCULATION_TYPE_PAIRS,
|
|
477
|
+
)
|
|
470
478
|
|
|
471
479
|
client = Geocodio("YOUR_API_KEY")
|
|
472
480
|
|
|
@@ -505,8 +513,18 @@ destinations = [
|
|
|
505
513
|
Coordinate(37.7949, -122.3994, "customer_2")
|
|
506
514
|
]
|
|
507
515
|
response = client.distance_matrix(origins=origins, destinations=destinations)
|
|
516
|
+
|
|
517
|
+
# One-to-one pairs: origin i is measured against destination i only,
|
|
518
|
+
# so each result has a single destination
|
|
519
|
+
response = client.distance_matrix(
|
|
520
|
+
origins=["38.8977,-77.0365,home", "38.886672,-77.094735,office"],
|
|
521
|
+
destinations=["38.9072,-77.0369,capitol", "38.8814,-77.0916,pentagon"],
|
|
522
|
+
calculation_type=DISTANCE_CALCULATION_TYPE_PAIRS
|
|
523
|
+
)
|
|
508
524
|
```
|
|
509
525
|
|
|
526
|
+
> **Note:** With `DISTANCE_CALCULATION_TYPE_PAIRS`, `origins` and `destinations` must be the same length, and the `max_results`, `max_distance`, `max_duration`, `min_distance` and `min_duration` filters are not supported. The API returns a 422 error otherwise.
|
|
527
|
+
|
|
510
528
|
#### Nearest mode (find closest destinations)
|
|
511
529
|
|
|
512
530
|
```python
|
|
@@ -557,7 +575,12 @@ response = client.distance_matrix(
|
|
|
557
575
|
For large distance matrix calculations, use async jobs that process in the background.
|
|
558
576
|
|
|
559
577
|
```python
|
|
560
|
-
from geocodio import
|
|
578
|
+
from geocodio import (
|
|
579
|
+
Geocodio,
|
|
580
|
+
DISTANCE_MODE_DRIVING,
|
|
581
|
+
DISTANCE_UNITS_MILES,
|
|
582
|
+
DISTANCE_CALCULATION_TYPE_PAIRS,
|
|
583
|
+
)
|
|
561
584
|
|
|
562
585
|
client = Geocodio("YOUR_API_KEY")
|
|
563
586
|
|
|
@@ -583,6 +606,15 @@ job = client.create_distance_matrix_job(
|
|
|
583
606
|
mode=DISTANCE_MODE_STRAIGHTLINE
|
|
584
607
|
)
|
|
585
608
|
|
|
609
|
+
# One-to-one pairs instead of a full matrix
|
|
610
|
+
job = client.create_distance_matrix_job(
|
|
611
|
+
name="Commutes",
|
|
612
|
+
origins=["38.8977,-77.0365,home", "38.886672,-77.094735,office"],
|
|
613
|
+
destinations=["38.9072,-77.0369,capitol", "38.8814,-77.0916,pentagon"],
|
|
614
|
+
calculation_type=DISTANCE_CALCULATION_TYPE_PAIRS
|
|
615
|
+
)
|
|
616
|
+
print(job.calculation_type) # "pairs"
|
|
617
|
+
|
|
586
618
|
# Check job status
|
|
587
619
|
status = client.distance_matrix_job_status(job.id)
|
|
588
620
|
print(status.status) # "ENQUEUED", "PROCESSING", "COMPLETED", or "FAILED"
|
|
@@ -305,6 +305,8 @@ from geocodio import (
|
|
|
305
305
|
DISTANCE_ORDER_BY_DURATION,
|
|
306
306
|
DISTANCE_SORT_ASC, # Default
|
|
307
307
|
DISTANCE_SORT_DESC,
|
|
308
|
+
DISTANCE_CALCULATION_TYPE_MATRIX, # Default - every origin × every destination (distance matrix only)
|
|
309
|
+
DISTANCE_CALCULATION_TYPE_PAIRS, # Origin i to destination i only (distance matrix only)
|
|
308
310
|
)
|
|
309
311
|
```
|
|
310
312
|
|
|
@@ -431,7 +433,13 @@ response = client.distance(
|
|
|
431
433
|
#### Distance matrix (multiple origins × destinations)
|
|
432
434
|
|
|
433
435
|
```python
|
|
434
|
-
from geocodio import
|
|
436
|
+
from geocodio import (
|
|
437
|
+
Geocodio,
|
|
438
|
+
Coordinate,
|
|
439
|
+
DISTANCE_MODE_DRIVING,
|
|
440
|
+
DISTANCE_UNITS_KM,
|
|
441
|
+
DISTANCE_CALCULATION_TYPE_PAIRS,
|
|
442
|
+
)
|
|
435
443
|
|
|
436
444
|
client = Geocodio("YOUR_API_KEY")
|
|
437
445
|
|
|
@@ -470,8 +478,18 @@ destinations = [
|
|
|
470
478
|
Coordinate(37.7949, -122.3994, "customer_2")
|
|
471
479
|
]
|
|
472
480
|
response = client.distance_matrix(origins=origins, destinations=destinations)
|
|
481
|
+
|
|
482
|
+
# One-to-one pairs: origin i is measured against destination i only,
|
|
483
|
+
# so each result has a single destination
|
|
484
|
+
response = client.distance_matrix(
|
|
485
|
+
origins=["38.8977,-77.0365,home", "38.886672,-77.094735,office"],
|
|
486
|
+
destinations=["38.9072,-77.0369,capitol", "38.8814,-77.0916,pentagon"],
|
|
487
|
+
calculation_type=DISTANCE_CALCULATION_TYPE_PAIRS
|
|
488
|
+
)
|
|
473
489
|
```
|
|
474
490
|
|
|
491
|
+
> **Note:** With `DISTANCE_CALCULATION_TYPE_PAIRS`, `origins` and `destinations` must be the same length, and the `max_results`, `max_distance`, `max_duration`, `min_distance` and `min_duration` filters are not supported. The API returns a 422 error otherwise.
|
|
492
|
+
|
|
475
493
|
#### Nearest mode (find closest destinations)
|
|
476
494
|
|
|
477
495
|
```python
|
|
@@ -522,7 +540,12 @@ response = client.distance_matrix(
|
|
|
522
540
|
For large distance matrix calculations, use async jobs that process in the background.
|
|
523
541
|
|
|
524
542
|
```python
|
|
525
|
-
from geocodio import
|
|
543
|
+
from geocodio import (
|
|
544
|
+
Geocodio,
|
|
545
|
+
DISTANCE_MODE_DRIVING,
|
|
546
|
+
DISTANCE_UNITS_MILES,
|
|
547
|
+
DISTANCE_CALCULATION_TYPE_PAIRS,
|
|
548
|
+
)
|
|
526
549
|
|
|
527
550
|
client = Geocodio("YOUR_API_KEY")
|
|
528
551
|
|
|
@@ -548,6 +571,15 @@ job = client.create_distance_matrix_job(
|
|
|
548
571
|
mode=DISTANCE_MODE_STRAIGHTLINE
|
|
549
572
|
)
|
|
550
573
|
|
|
574
|
+
# One-to-one pairs instead of a full matrix
|
|
575
|
+
job = client.create_distance_matrix_job(
|
|
576
|
+
name="Commutes",
|
|
577
|
+
origins=["38.8977,-77.0365,home", "38.886672,-77.094735,office"],
|
|
578
|
+
destinations=["38.9072,-77.0369,capitol", "38.8814,-77.0916,pentagon"],
|
|
579
|
+
calculation_type=DISTANCE_CALCULATION_TYPE_PAIRS
|
|
580
|
+
)
|
|
581
|
+
print(job.calculation_type) # "pairs"
|
|
582
|
+
|
|
551
583
|
# Check job status
|
|
552
584
|
status = client.distance_matrix_job_status(job.id)
|
|
553
585
|
print(status.status) # "ENQUEUED", "PROCESSING", "COMPLETED", or "FAILED"
|
|
@@ -8,6 +8,8 @@ from .client import Geocodio
|
|
|
8
8
|
|
|
9
9
|
# Distance API exports
|
|
10
10
|
from .distance import (
|
|
11
|
+
DISTANCE_CALCULATION_TYPE_MATRIX,
|
|
12
|
+
DISTANCE_CALCULATION_TYPE_PAIRS,
|
|
11
13
|
DISTANCE_MODE_DRIVING,
|
|
12
14
|
DISTANCE_MODE_HAVERSINE,
|
|
13
15
|
DISTANCE_MODE_STRAIGHTLINE,
|
|
@@ -52,4 +54,7 @@ __all__ = [
|
|
|
52
54
|
# Distance sort constants
|
|
53
55
|
"DISTANCE_SORT_ASC",
|
|
54
56
|
"DISTANCE_SORT_DESC",
|
|
57
|
+
# Distance calculation type constants
|
|
58
|
+
"DISTANCE_CALCULATION_TYPE_MATRIX",
|
|
59
|
+
"DISTANCE_CALCULATION_TYPE_PAIRS",
|
|
55
60
|
]
|
|
@@ -1168,6 +1168,7 @@ class Geocodio:
|
|
|
1168
1168
|
min_duration: Optional[int] = None,
|
|
1169
1169
|
order_by: str = DISTANCE_ORDER_BY_DISTANCE,
|
|
1170
1170
|
sort_order: str = DISTANCE_SORT_ASC,
|
|
1171
|
+
calculation_type: Optional[str] = None,
|
|
1171
1172
|
) -> DistanceMatrixResponse:
|
|
1172
1173
|
"""
|
|
1173
1174
|
Calculate distance matrix (multiple origins × destinations).
|
|
@@ -1186,6 +1187,10 @@ class Geocodio:
|
|
|
1186
1187
|
min_duration: Minimum duration filter (seconds, driving mode only).
|
|
1187
1188
|
order_by: Sort results by 'distance' or 'duration'.
|
|
1188
1189
|
sort_order: Sort direction ('asc' or 'desc').
|
|
1190
|
+
calculation_type: 'matrix' (default, every origin × every destination)
|
|
1191
|
+
or 'pairs' (origin i to destination i only; origins and
|
|
1192
|
+
destinations must be the same length and the max/min filters
|
|
1193
|
+
are not allowed).
|
|
1189
1194
|
|
|
1190
1195
|
Returns:
|
|
1191
1196
|
DistanceMatrixResponse with results for each origin.
|
|
@@ -1234,6 +1239,8 @@ class Geocodio:
|
|
|
1234
1239
|
body["order_by"] = order_by
|
|
1235
1240
|
if sort_order != DISTANCE_SORT_ASC:
|
|
1236
1241
|
body["sort"] = sort_order
|
|
1242
|
+
if calculation_type is not None:
|
|
1243
|
+
body["calculation_type"] = calculation_type
|
|
1237
1244
|
|
|
1238
1245
|
response = self._request(
|
|
1239
1246
|
"POST", endpoint, json=body, timeout=self.batch_timeout
|
|
@@ -1255,6 +1262,7 @@ class Geocodio:
|
|
|
1255
1262
|
min_duration: Optional[int] = None,
|
|
1256
1263
|
order_by: str = DISTANCE_ORDER_BY_DISTANCE,
|
|
1257
1264
|
sort_order: str = DISTANCE_SORT_ASC,
|
|
1265
|
+
calculation_type: Optional[str] = None,
|
|
1258
1266
|
) -> DistanceJobResponse:
|
|
1259
1267
|
"""
|
|
1260
1268
|
Create an async distance matrix job for large calculations.
|
|
@@ -1273,6 +1281,10 @@ class Geocodio:
|
|
|
1273
1281
|
min_duration: Minimum duration filter (seconds, driving mode only).
|
|
1274
1282
|
order_by: Sort results by 'distance' or 'duration'.
|
|
1275
1283
|
sort_order: Sort direction ('asc' or 'desc').
|
|
1284
|
+
calculation_type: 'matrix' (default, every origin × every destination)
|
|
1285
|
+
or 'pairs' (origin i to destination i only; origins and
|
|
1286
|
+
destinations must be the same length and the max/min filters
|
|
1287
|
+
are not allowed).
|
|
1276
1288
|
|
|
1277
1289
|
Returns:
|
|
1278
1290
|
DistanceJobResponse with job ID and status.
|
|
@@ -1331,6 +1343,8 @@ class Geocodio:
|
|
|
1331
1343
|
body["order_by"] = order_by
|
|
1332
1344
|
if sort_order != DISTANCE_SORT_ASC:
|
|
1333
1345
|
body["sort"] = sort_order
|
|
1346
|
+
if calculation_type is not None:
|
|
1347
|
+
body["calculation_type"] = calculation_type
|
|
1334
1348
|
|
|
1335
1349
|
response = self._request("POST", endpoint, json=body, timeout=self.list_timeout)
|
|
1336
1350
|
return DistanceJobResponse.from_api(response.json())
|
|
@@ -37,6 +37,13 @@ DISTANCE_ORDER_BY_DURATION = "duration"
|
|
|
37
37
|
DISTANCE_SORT_ASC = "asc"
|
|
38
38
|
DISTANCE_SORT_DESC = "desc"
|
|
39
39
|
|
|
40
|
+
# ──────────────────────────────────────────────────────────────────────────────
|
|
41
|
+
# Calculation Type Constants (distance matrix and distance matrix jobs only)
|
|
42
|
+
# ──────────────────────────────────────────────────────────────────────────────
|
|
43
|
+
|
|
44
|
+
DISTANCE_CALCULATION_TYPE_MATRIX = "matrix" # Every origin × every destination
|
|
45
|
+
DISTANCE_CALCULATION_TYPE_PAIRS = "pairs" # Origin i to destination i only
|
|
46
|
+
|
|
40
47
|
|
|
41
48
|
# ──────────────────────────────────────────────────────────────────────────────
|
|
42
49
|
# Coordinate Class
|
|
@@ -263,6 +270,9 @@ __all__ = [
|
|
|
263
270
|
# Sort constants
|
|
264
271
|
"DISTANCE_SORT_ASC",
|
|
265
272
|
"DISTANCE_SORT_DESC",
|
|
273
|
+
# Calculation type constants
|
|
274
|
+
"DISTANCE_CALCULATION_TYPE_MATRIX",
|
|
275
|
+
"DISTANCE_CALCULATION_TYPE_PAIRS",
|
|
266
276
|
# Classes
|
|
267
277
|
"Coordinate",
|
|
268
278
|
# Functions
|
|
@@ -749,6 +749,7 @@ class DistanceJobResponse:
|
|
|
749
749
|
download_url: URL to download results (when completed).
|
|
750
750
|
calculations_completed: Number of completed calculations.
|
|
751
751
|
warnings: Non-fatal advisories from the API's ``_warnings`` key.
|
|
752
|
+
calculation_type: 'matrix' or 'pairs' (None if the API did not send it).
|
|
752
753
|
"""
|
|
753
754
|
|
|
754
755
|
id: int
|
|
@@ -763,6 +764,7 @@ class DistanceJobResponse:
|
|
|
763
764
|
calculations_completed: Optional[int] = None
|
|
764
765
|
progress: Optional[int] = None
|
|
765
766
|
warnings: List[str] = field(default_factory=list)
|
|
767
|
+
calculation_type: Optional[str] = None
|
|
766
768
|
|
|
767
769
|
@classmethod
|
|
768
770
|
def from_api(cls, data: Dict[str, Any]) -> "DistanceJobResponse":
|
|
@@ -792,6 +794,7 @@ class DistanceJobResponse:
|
|
|
792
794
|
calculations_completed=data.get("calculations_completed"),
|
|
793
795
|
progress=data.get("progress"),
|
|
794
796
|
warnings=warnings,
|
|
797
|
+
calculation_type=data.get("calculation_type"),
|
|
795
798
|
)
|
|
796
799
|
|
|
797
800
|
|
|
@@ -8,6 +8,7 @@ import httpx
|
|
|
8
8
|
import pytest
|
|
9
9
|
|
|
10
10
|
from geocodio import (
|
|
11
|
+
DISTANCE_CALCULATION_TYPE_PAIRS,
|
|
11
12
|
DISTANCE_MODE_DRIVING,
|
|
12
13
|
DISTANCE_MODE_HAVERSINE,
|
|
13
14
|
DISTANCE_MODE_STRAIGHTLINE,
|
|
@@ -441,6 +442,39 @@ class TestDistanceMatrix:
|
|
|
441
442
|
destinations=[Coordinate(38.8895, -77.0353, "dest1")],
|
|
442
443
|
)
|
|
443
444
|
|
|
445
|
+
def test_distance_matrix_sends_calculation_type(self, client, httpx_mock):
|
|
446
|
+
"""Test that calculation_type is sent in the POST body when given."""
|
|
447
|
+
|
|
448
|
+
def response_callback(request):
|
|
449
|
+
body = json.loads(request.content)
|
|
450
|
+
assert body["calculation_type"] == "pairs"
|
|
451
|
+
return httpx.Response(200, json=sample_distance_matrix_response())
|
|
452
|
+
|
|
453
|
+
httpx_mock.add_callback(callback=response_callback)
|
|
454
|
+
|
|
455
|
+
client.distance_matrix(
|
|
456
|
+
origins=["38.8977,-77.0365,home", "38.886672,-77.094735,office"],
|
|
457
|
+
destinations=["38.9072,-77.0369,capitol", "38.8814,-77.0916,pentagon"],
|
|
458
|
+
calculation_type=DISTANCE_CALCULATION_TYPE_PAIRS,
|
|
459
|
+
)
|
|
460
|
+
|
|
461
|
+
def test_distance_matrix_omits_calculation_type_by_default(
|
|
462
|
+
self, client, httpx_mock
|
|
463
|
+
):
|
|
464
|
+
"""Test that calculation_type is left out when not given."""
|
|
465
|
+
|
|
466
|
+
def response_callback(request):
|
|
467
|
+
body = json.loads(request.content)
|
|
468
|
+
assert "calculation_type" not in body
|
|
469
|
+
return httpx.Response(200, json=sample_distance_matrix_response())
|
|
470
|
+
|
|
471
|
+
httpx_mock.add_callback(callback=response_callback)
|
|
472
|
+
|
|
473
|
+
client.distance_matrix(
|
|
474
|
+
origins=["38.8977,-77.0365"],
|
|
475
|
+
destinations=["38.9072,-77.0369"],
|
|
476
|
+
)
|
|
477
|
+
|
|
444
478
|
|
|
445
479
|
# ──────────────────────────────────────────────────────────────────────────────
|
|
446
480
|
# Distance Job Method Tests
|
|
@@ -572,6 +606,57 @@ class TestDistanceJobs:
|
|
|
572
606
|
callback_url="https://example.com/webhook",
|
|
573
607
|
)
|
|
574
608
|
|
|
609
|
+
def test_create_job_sends_calculation_type(self, client, httpx_mock):
|
|
610
|
+
"""Test creating a job with calculation_type."""
|
|
611
|
+
|
|
612
|
+
def response_callback(request):
|
|
613
|
+
body = json.loads(request.content)
|
|
614
|
+
assert body["calculation_type"] == "pairs"
|
|
615
|
+
return httpx.Response(200, json=sample_job_create_response())
|
|
616
|
+
|
|
617
|
+
httpx_mock.add_callback(callback=response_callback)
|
|
618
|
+
|
|
619
|
+
client.create_distance_matrix_job(
|
|
620
|
+
name="Commutes",
|
|
621
|
+
origins=[(38.8977, -77.0365), (38.886672, -77.094735)],
|
|
622
|
+
destinations=[(38.9072, -77.0369), (38.8814, -77.0916)],
|
|
623
|
+
calculation_type=DISTANCE_CALCULATION_TYPE_PAIRS,
|
|
624
|
+
)
|
|
625
|
+
|
|
626
|
+
def test_create_job_omits_calculation_type_by_default(self, client, httpx_mock):
|
|
627
|
+
"""Test that calculation_type is left out of the job when not given."""
|
|
628
|
+
|
|
629
|
+
def response_callback(request):
|
|
630
|
+
body = json.loads(request.content)
|
|
631
|
+
assert "calculation_type" not in body
|
|
632
|
+
return httpx.Response(200, json=sample_job_create_response())
|
|
633
|
+
|
|
634
|
+
httpx_mock.add_callback(callback=response_callback)
|
|
635
|
+
|
|
636
|
+
client.create_distance_matrix_job(
|
|
637
|
+
name="My Job",
|
|
638
|
+
origins=[(38.8977, -77.0365)],
|
|
639
|
+
destinations=[(38.8895, -77.0353)],
|
|
640
|
+
)
|
|
641
|
+
|
|
642
|
+
def test_job_status_parses_calculation_type(self, client, httpx_mock):
|
|
643
|
+
"""Test that calculation_type is read from the job response."""
|
|
644
|
+
payload = sample_job_status_response()
|
|
645
|
+
payload["data"]["calculation_type"] = "pairs"
|
|
646
|
+
httpx_mock.add_callback(
|
|
647
|
+
callback=lambda request: httpx.Response(200, json=payload)
|
|
648
|
+
)
|
|
649
|
+
|
|
650
|
+
response = client.distance_matrix_job_status(123)
|
|
651
|
+
|
|
652
|
+
assert response.calculation_type == "pairs"
|
|
653
|
+
|
|
654
|
+
def test_job_without_calculation_type_defaults_to_none(self):
|
|
655
|
+
"""Test that responses predating calculation_type still parse."""
|
|
656
|
+
response = DistanceJobResponse.from_api(sample_job_create_response())
|
|
657
|
+
|
|
658
|
+
assert response.calculation_type is None
|
|
659
|
+
|
|
575
660
|
def test_job_status(self, client, httpx_mock):
|
|
576
661
|
"""Test getting job status."""
|
|
577
662
|
httpx_mock.add_callback(
|
|
File without changes
|
{geocodio_library_python-1.5.0 → geocodio_library_python-1.6.0}/.github/workflows/publish.yml
RENAMED
|
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
|
{geocodio_library_python-1.5.0 → geocodio_library_python-1.6.0}/tests/e2e/test_batch_reverse.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{geocodio_library_python-1.5.0 → geocodio_library_python-1.6.0}/tests/unit/test_exceptions.py
RENAMED
|
File without changes
|
|
File without changes
|
{geocodio_library_python-1.5.0 → geocodio_library_python-1.6.0}/tests/unit/test_geocoding.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|