geocodio-library-python 0.1.0__tar.gz → 0.2.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-0.1.0 → geocodio_library_python-0.2.0}/CHANGELOG.md +9 -1
- {geocodio_library_python-0.1.0 → geocodio_library_python-0.2.0}/PKG-INFO +31 -31
- {geocodio_library_python-0.1.0 → geocodio_library_python-0.2.0}/README.md +30 -30
- {geocodio_library_python-0.1.0 → geocodio_library_python-0.2.0}/pyproject.toml +1 -1
- {geocodio_library_python-0.1.0 → geocodio_library_python-0.2.0}/smoke.py +2 -2
- {geocodio_library_python-0.1.0 → geocodio_library_python-0.2.0}/smoke_lists.py +2 -2
- {geocodio_library_python-0.1.0 → geocodio_library_python-0.2.0}/src/geocodio/__init__.py +2 -2
- {geocodio_library_python-0.1.0 → geocodio_library_python-0.2.0}/src/geocodio/_version.py +1 -1
- {geocodio_library_python-0.1.0 → geocodio_library_python-0.2.0}/src/geocodio/client.py +1 -1
- {geocodio_library_python-0.1.0 → geocodio_library_python-0.2.0}/tests/conftest.py +4 -4
- {geocodio_library_python-0.1.0 → geocodio_library_python-0.2.0}/tests/e2e/test_api.py +2 -2
- {geocodio_library_python-0.1.0 → geocodio_library_python-0.2.0}/tests/e2e/test_batch_reverse.py +1 -1
- {geocodio_library_python-0.1.0 → geocodio_library_python-0.2.0}/tests/e2e/test_lists_api.py +6 -6
- {geocodio_library_python-0.1.0 → geocodio_library_python-0.2.0}/tests/unit/test_client.py +15 -15
- {geocodio_library_python-0.1.0 → geocodio_library_python-0.2.0}/tests/unit/test_geocoding.py +9 -9
- {geocodio_library_python-0.1.0 → geocodio_library_python-0.2.0}/uv.lock +1 -1
- {geocodio_library_python-0.1.0 → geocodio_library_python-0.2.0}/.github/workflows/ci.yml +0 -0
- {geocodio_library_python-0.1.0 → geocodio_library_python-0.2.0}/.github/workflows/publish.yml +0 -0
- {geocodio_library_python-0.1.0 → geocodio_library_python-0.2.0}/.github/workflows/test-act-event-ci.json +0 -0
- {geocodio_library_python-0.1.0 → geocodio_library_python-0.2.0}/.github/workflows/test-act-event-publish.json +0 -0
- {geocodio_library_python-0.1.0 → geocodio_library_python-0.2.0}/.gitignore +0 -0
- {geocodio_library_python-0.1.0 → geocodio_library_python-0.2.0}/LICENSE +0 -0
- {geocodio_library_python-0.1.0 → geocodio_library_python-0.2.0}/requirements-dev.txt +0 -0
- {geocodio_library_python-0.1.0 → geocodio_library_python-0.2.0}/setup.cfg +0 -0
- {geocodio_library_python-0.1.0 → geocodio_library_python-0.2.0}/src/geocodio/exceptions.py +0 -0
- {geocodio_library_python-0.1.0 → geocodio_library_python-0.2.0}/src/geocodio/models.py +0 -0
- {geocodio_library_python-0.1.0 → geocodio_library_python-0.2.0}/test_pypi_release.py +0 -0
- {geocodio_library_python-0.1.0 → geocodio_library_python-0.2.0}/tests/__init__.py +0 -0
- {geocodio_library_python-0.1.0 → geocodio_library_python-0.2.0}/tests/test_workflows.py +0 -0
- {geocodio_library_python-0.1.0 → geocodio_library_python-0.2.0}/tests/unit/test_errors.py +0 -0
- {geocodio_library_python-0.1.0 → geocodio_library_python-0.2.0}/tests/unit/test_exceptions.py +0 -0
- {geocodio_library_python-0.1.0 → geocodio_library_python-0.2.0}/tests/unit/test_geocode.py +0 -0
- {geocodio_library_python-0.1.0 → geocodio_library_python-0.2.0}/tests/unit/test_models.py +0 -0
- {geocodio_library_python-0.1.0 → geocodio_library_python-0.2.0}/tests/unit/test_reverse.py +0 -0
|
@@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.2.0] - 2025-08-08
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
- **BREAKING**: Renamed main client class from `GeocodioClient` to `Geocodio` for simplicity and consistency with other SDKs
|
|
14
|
+
- Migration: Change imports from `from geocodio import GeocodioClient` to `from geocodio import Geocodio`
|
|
15
|
+
- Migration: Update instantiation from `client = GeocodioClient(...)` to `client = Geocodio(...)`
|
|
16
|
+
|
|
10
17
|
## [0.1.0] - 2025-08-08
|
|
11
18
|
|
|
12
19
|
### Added
|
|
@@ -32,5 +39,6 @@ When ready to release:
|
|
|
32
39
|
5. Push tags: `git push --tags`
|
|
33
40
|
6. GitHub Actions will automatically publish to PyPI
|
|
34
41
|
|
|
35
|
-
[Unreleased]: https://github.com/Geocodio/geocodio-library-python/compare/v0.
|
|
42
|
+
[Unreleased]: https://github.com/Geocodio/geocodio-library-python/compare/v0.2.0...HEAD
|
|
43
|
+
[0.2.0]: https://github.com/Geocodio/geocodio-library-python/compare/v0.1.0...v0.2.0
|
|
36
44
|
[0.1.0]: https://github.com/Geocodio/geocodio-library-python/releases/tag/v0.1.0
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: geocodio-library-python
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2.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
|
|
@@ -53,37 +53,16 @@ Install via pip:
|
|
|
53
53
|
|
|
54
54
|
pip install geocodio-library-python
|
|
55
55
|
|
|
56
|
-
Development Installation
|
|
57
|
-
-----------------------
|
|
58
|
-
|
|
59
|
-
1. Clone the repository:
|
|
60
|
-
```bash
|
|
61
|
-
git clone https://github.com/geocodio/geocodio-library-python.git
|
|
62
|
-
cd geocodio-library-python
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
2. Create and activate a virtual environment:
|
|
66
|
-
```bash
|
|
67
|
-
python -m venv venv
|
|
68
|
-
source venv/bin/activate # On Windows: venv\Scripts\activate
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
3. Install development dependencies:
|
|
72
|
-
```bash
|
|
73
|
-
pip install -e .
|
|
74
|
-
pip install -r requirements-dev.txt
|
|
75
|
-
```
|
|
76
|
-
|
|
77
56
|
Usage
|
|
78
57
|
-----
|
|
79
58
|
|
|
80
59
|
### Geocoding
|
|
81
60
|
|
|
82
61
|
```python
|
|
83
|
-
from geocodio import
|
|
62
|
+
from geocodio import Geocodio
|
|
84
63
|
|
|
85
64
|
# Initialize the client with your API key
|
|
86
|
-
client =
|
|
65
|
+
client = Geocodio("YOUR_API_KEY")
|
|
87
66
|
|
|
88
67
|
# Single forward geocode
|
|
89
68
|
response = client.geocode("1600 Pennsylvania Ave, Washington, DC")
|
|
@@ -115,10 +94,10 @@ print(data.results[0].fields.timezone.name if data.results[0].fields.timezone el
|
|
|
115
94
|
The List API allows you to manage lists of addresses or coordinates for batch processing.
|
|
116
95
|
|
|
117
96
|
```python
|
|
118
|
-
from geocodio import
|
|
97
|
+
from geocodio import Geocodio
|
|
119
98
|
|
|
120
99
|
# Initialize the client with your API key
|
|
121
|
-
client =
|
|
100
|
+
client = Geocodio("YOUR_API_KEY")
|
|
122
101
|
|
|
123
102
|
# Get all lists
|
|
124
103
|
lists = client.get_lists()
|
|
@@ -150,17 +129,17 @@ Error Handling
|
|
|
150
129
|
--------------
|
|
151
130
|
|
|
152
131
|
```python
|
|
153
|
-
from geocodio import
|
|
132
|
+
from geocodio import Geocodio
|
|
154
133
|
from geocodio.exceptions import AuthenticationError, InvalidRequestError
|
|
155
134
|
|
|
156
135
|
try:
|
|
157
|
-
client =
|
|
136
|
+
client = Geocodio("INVALID_API_KEY")
|
|
158
137
|
response = client.geocode("1600 Pennsylvania Ave, Washington, DC")
|
|
159
138
|
except AuthenticationError as e:
|
|
160
139
|
print(f"Authentication failed: {e}")
|
|
161
140
|
|
|
162
141
|
try:
|
|
163
|
-
client =
|
|
142
|
+
client = Geocodio("YOUR_API_KEY")
|
|
164
143
|
response = client.geocode("") # Empty address
|
|
165
144
|
except InvalidRequestError as e:
|
|
166
145
|
print(f"Invalid request: {e}")
|
|
@@ -172,10 +151,10 @@ Geocodio Enterprise
|
|
|
172
151
|
To use this library with Geocodio Enterprise, pass `api.enterprise.geocod.io` as the `hostname` parameter when initializing the client:
|
|
173
152
|
|
|
174
153
|
```python
|
|
175
|
-
from geocodio import
|
|
154
|
+
from geocodio import Geocodio
|
|
176
155
|
|
|
177
156
|
# Initialize client for Geocodio Enterprise
|
|
178
|
-
client =
|
|
157
|
+
client = Geocodio(
|
|
179
158
|
"YOUR_API_KEY",
|
|
180
159
|
hostname="api.enterprise.geocod.io"
|
|
181
160
|
)
|
|
@@ -202,6 +181,27 @@ License
|
|
|
202
181
|
|
|
203
182
|
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
|
|
204
183
|
|
|
184
|
+
Development Installation
|
|
185
|
+
-----------------------
|
|
186
|
+
|
|
187
|
+
1. Clone the repository:
|
|
188
|
+
```bash
|
|
189
|
+
git clone https://github.com/geocodio/geocodio-library-python.git
|
|
190
|
+
cd geocodio-library-python
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
2. Create and activate a virtual environment:
|
|
194
|
+
```bash
|
|
195
|
+
python -m venv venv
|
|
196
|
+
source venv/bin/activate # On Windows: venv\Scripts\activate
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
3. Install development dependencies:
|
|
200
|
+
```bash
|
|
201
|
+
pip install -e .
|
|
202
|
+
pip install -r requirements-dev.txt
|
|
203
|
+
```
|
|
204
|
+
|
|
205
205
|
CI & Publishing
|
|
206
206
|
---------------
|
|
207
207
|
|
|
@@ -18,37 +18,16 @@ Install via pip:
|
|
|
18
18
|
|
|
19
19
|
pip install geocodio-library-python
|
|
20
20
|
|
|
21
|
-
Development Installation
|
|
22
|
-
-----------------------
|
|
23
|
-
|
|
24
|
-
1. Clone the repository:
|
|
25
|
-
```bash
|
|
26
|
-
git clone https://github.com/geocodio/geocodio-library-python.git
|
|
27
|
-
cd geocodio-library-python
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
2. Create and activate a virtual environment:
|
|
31
|
-
```bash
|
|
32
|
-
python -m venv venv
|
|
33
|
-
source venv/bin/activate # On Windows: venv\Scripts\activate
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
3. Install development dependencies:
|
|
37
|
-
```bash
|
|
38
|
-
pip install -e .
|
|
39
|
-
pip install -r requirements-dev.txt
|
|
40
|
-
```
|
|
41
|
-
|
|
42
21
|
Usage
|
|
43
22
|
-----
|
|
44
23
|
|
|
45
24
|
### Geocoding
|
|
46
25
|
|
|
47
26
|
```python
|
|
48
|
-
from geocodio import
|
|
27
|
+
from geocodio import Geocodio
|
|
49
28
|
|
|
50
29
|
# Initialize the client with your API key
|
|
51
|
-
client =
|
|
30
|
+
client = Geocodio("YOUR_API_KEY")
|
|
52
31
|
|
|
53
32
|
# Single forward geocode
|
|
54
33
|
response = client.geocode("1600 Pennsylvania Ave, Washington, DC")
|
|
@@ -80,10 +59,10 @@ print(data.results[0].fields.timezone.name if data.results[0].fields.timezone el
|
|
|
80
59
|
The List API allows you to manage lists of addresses or coordinates for batch processing.
|
|
81
60
|
|
|
82
61
|
```python
|
|
83
|
-
from geocodio import
|
|
62
|
+
from geocodio import Geocodio
|
|
84
63
|
|
|
85
64
|
# Initialize the client with your API key
|
|
86
|
-
client =
|
|
65
|
+
client = Geocodio("YOUR_API_KEY")
|
|
87
66
|
|
|
88
67
|
# Get all lists
|
|
89
68
|
lists = client.get_lists()
|
|
@@ -115,17 +94,17 @@ Error Handling
|
|
|
115
94
|
--------------
|
|
116
95
|
|
|
117
96
|
```python
|
|
118
|
-
from geocodio import
|
|
97
|
+
from geocodio import Geocodio
|
|
119
98
|
from geocodio.exceptions import AuthenticationError, InvalidRequestError
|
|
120
99
|
|
|
121
100
|
try:
|
|
122
|
-
client =
|
|
101
|
+
client = Geocodio("INVALID_API_KEY")
|
|
123
102
|
response = client.geocode("1600 Pennsylvania Ave, Washington, DC")
|
|
124
103
|
except AuthenticationError as e:
|
|
125
104
|
print(f"Authentication failed: {e}")
|
|
126
105
|
|
|
127
106
|
try:
|
|
128
|
-
client =
|
|
107
|
+
client = Geocodio("YOUR_API_KEY")
|
|
129
108
|
response = client.geocode("") # Empty address
|
|
130
109
|
except InvalidRequestError as e:
|
|
131
110
|
print(f"Invalid request: {e}")
|
|
@@ -137,10 +116,10 @@ Geocodio Enterprise
|
|
|
137
116
|
To use this library with Geocodio Enterprise, pass `api.enterprise.geocod.io` as the `hostname` parameter when initializing the client:
|
|
138
117
|
|
|
139
118
|
```python
|
|
140
|
-
from geocodio import
|
|
119
|
+
from geocodio import Geocodio
|
|
141
120
|
|
|
142
121
|
# Initialize client for Geocodio Enterprise
|
|
143
|
-
client =
|
|
122
|
+
client = Geocodio(
|
|
144
123
|
"YOUR_API_KEY",
|
|
145
124
|
hostname="api.enterprise.geocod.io"
|
|
146
125
|
)
|
|
@@ -167,6 +146,27 @@ License
|
|
|
167
146
|
|
|
168
147
|
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
|
|
169
148
|
|
|
149
|
+
Development Installation
|
|
150
|
+
-----------------------
|
|
151
|
+
|
|
152
|
+
1. Clone the repository:
|
|
153
|
+
```bash
|
|
154
|
+
git clone https://github.com/geocodio/geocodio-library-python.git
|
|
155
|
+
cd geocodio-library-python
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
2. Create and activate a virtual environment:
|
|
159
|
+
```bash
|
|
160
|
+
python -m venv venv
|
|
161
|
+
source venv/bin/activate # On Windows: venv\Scripts\activate
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
3. Install development dependencies:
|
|
165
|
+
```bash
|
|
166
|
+
pip install -e .
|
|
167
|
+
pip install -r requirements-dev.txt
|
|
168
|
+
```
|
|
169
|
+
|
|
170
170
|
CI & Publishing
|
|
171
171
|
---------------
|
|
172
172
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
2
|
|
|
3
|
-
from geocodio import
|
|
3
|
+
from geocodio import Geocodio
|
|
4
4
|
from dotenv import load_dotenv
|
|
5
5
|
import os
|
|
6
6
|
import json
|
|
@@ -10,7 +10,7 @@ from dataclasses import asdict
|
|
|
10
10
|
load_dotenv()
|
|
11
11
|
|
|
12
12
|
# Initialize the client with your API key
|
|
13
|
-
client =
|
|
13
|
+
client = Geocodio(os.getenv("GEOCODIO_API_KEY"))
|
|
14
14
|
|
|
15
15
|
# Single forward geocode
|
|
16
16
|
print("\nSingle forward geocode:")
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import os
|
|
4
4
|
import time
|
|
5
5
|
import logging
|
|
6
|
-
from geocodio import
|
|
6
|
+
from geocodio import Geocodio
|
|
7
7
|
from geocodio.models import ListProcessingState
|
|
8
8
|
from dotenv import load_dotenv
|
|
9
9
|
|
|
@@ -51,7 +51,7 @@ def main():
|
|
|
51
51
|
logger.error("GEOCODIO_API_KEY not set in environment.")
|
|
52
52
|
exit(1)
|
|
53
53
|
|
|
54
|
-
client =
|
|
54
|
+
client = Geocodio(api_key)
|
|
55
55
|
|
|
56
56
|
# Step 1: Create a list
|
|
57
57
|
logger.info("Creating a new list...")
|
|
@@ -27,7 +27,7 @@ from geocodio.models import (
|
|
|
27
27
|
from geocodio.exceptions import InvalidRequestError, AuthenticationError, GeocodioServerError, BadRequestError
|
|
28
28
|
|
|
29
29
|
|
|
30
|
-
class
|
|
30
|
+
class Geocodio:
|
|
31
31
|
BASE_PATH = "/v1.9" # keep in sync with Geocodio's current version
|
|
32
32
|
DEFAULT_SINGLE_TIMEOUT = 5.0
|
|
33
33
|
DEFAULT_BATCH_TIMEOUT = 1800.0 # 30 minutes
|
|
@@ -6,7 +6,7 @@ import os
|
|
|
6
6
|
import logging
|
|
7
7
|
from dotenv import load_dotenv
|
|
8
8
|
import pytest
|
|
9
|
-
from geocodio import
|
|
9
|
+
from geocodio import Geocodio
|
|
10
10
|
|
|
11
11
|
# Load environment variables from .env file
|
|
12
12
|
load_dotenv()
|
|
@@ -18,7 +18,7 @@ logger = logging.getLogger(__name__)
|
|
|
18
18
|
|
|
19
19
|
@pytest.fixture
|
|
20
20
|
def client(request):
|
|
21
|
-
"""Create a
|
|
21
|
+
"""Create a Geocodio instance with test configuration"""
|
|
22
22
|
# Use TEST_KEY for all tests except e2e tests
|
|
23
23
|
if "e2e" in request.node.fspath.strpath:
|
|
24
24
|
logger.debug("Running e2e tests - using API key from environment")
|
|
@@ -26,7 +26,7 @@ def client(request):
|
|
|
26
26
|
if not api_key:
|
|
27
27
|
logger.warning("GEOCODIO_API_KEY not set - skipping e2e test")
|
|
28
28
|
pytest.skip("GEOCODIO_API_KEY environment variable not set")
|
|
29
|
-
return
|
|
29
|
+
return Geocodio(api_key=api_key)
|
|
30
30
|
else:
|
|
31
31
|
logger.debug("Running unit tests - using TEST_KEY with api.test hostname")
|
|
32
|
-
return
|
|
32
|
+
return Geocodio(api_key="TEST_KEY", hostname="api.test")
|
|
@@ -5,7 +5,7 @@ These tests require a valid GEOCODIO_API_KEY environment variable.
|
|
|
5
5
|
|
|
6
6
|
import os
|
|
7
7
|
import pytest
|
|
8
|
-
from geocodio import
|
|
8
|
+
from geocodio import Geocodio
|
|
9
9
|
from geocodio.exceptions import GeocodioError
|
|
10
10
|
|
|
11
11
|
|
|
@@ -15,7 +15,7 @@ def client():
|
|
|
15
15
|
api_key = os.getenv("GEOCODIO_API_KEY")
|
|
16
16
|
if not api_key:
|
|
17
17
|
pytest.skip("GEOCODIO_API_KEY environment variable not set")
|
|
18
|
-
return
|
|
18
|
+
return Geocodio(api_key)
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
def test_integration_geocode(client):
|
|
@@ -7,7 +7,7 @@ import os
|
|
|
7
7
|
import pytest
|
|
8
8
|
import time
|
|
9
9
|
from unittest.mock import patch
|
|
10
|
-
from geocodio import
|
|
10
|
+
from geocodio import Geocodio
|
|
11
11
|
from geocodio.models import ListResponse, PaginatedResponse, ListProcessingState
|
|
12
12
|
from geocodio.exceptions import GeocodioServerError
|
|
13
13
|
import logging
|
|
@@ -22,7 +22,7 @@ def client():
|
|
|
22
22
|
api_key = os.getenv("GEOCODIO_API_KEY")
|
|
23
23
|
if not api_key:
|
|
24
24
|
pytest.skip("GEOCODIO_API_KEY environment variable not set")
|
|
25
|
-
return
|
|
25
|
+
return Geocodio(api_key)
|
|
26
26
|
|
|
27
27
|
|
|
28
28
|
@pytest.fixture
|
|
@@ -59,8 +59,8 @@ def wait_for_list_processed(client, list_id, timeout=120):
|
|
|
59
59
|
|
|
60
60
|
def test_create_list(client):
|
|
61
61
|
"""
|
|
62
|
-
Test creating a list with
|
|
63
|
-
:param client:
|
|
62
|
+
Test creating a list with Geocodio.create_list()
|
|
63
|
+
:param client: Geocodio instance
|
|
64
64
|
"""
|
|
65
65
|
new_list = client.create_list(file="Zip\n20003\n20001", filename="test_list.csv")
|
|
66
66
|
|
|
@@ -69,8 +69,8 @@ def test_create_list(client):
|
|
|
69
69
|
|
|
70
70
|
def test_get_list_status(client, list_response):
|
|
71
71
|
"""
|
|
72
|
-
Test retrieving the status of a list with
|
|
73
|
-
:param client:
|
|
72
|
+
Test retrieving the status of a list with Geocodio.get_list_status()
|
|
73
|
+
:param client: Geocodio instance
|
|
74
74
|
:param list_response: List object created in the fixture
|
|
75
75
|
"""
|
|
76
76
|
# Get the status of the test list
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
"""
|
|
2
|
-
Tests for the
|
|
2
|
+
Tests for the Geocodio class
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
5
|
import pytest
|
|
6
6
|
import httpx
|
|
7
|
-
from geocodio import
|
|
7
|
+
from geocodio import Geocodio
|
|
8
8
|
from geocodio.exceptions import AuthenticationError
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
@pytest.fixture
|
|
12
12
|
def mock_request(mocker):
|
|
13
13
|
"""Mock the _request method."""
|
|
14
|
-
return mocker.patch('geocodio.client.
|
|
14
|
+
return mocker.patch('geocodio.client.Geocodio._request')
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
def test_client_initialization():
|
|
18
18
|
"""Test that the client can be initialized with an API key"""
|
|
19
|
-
client =
|
|
19
|
+
client = Geocodio(api_key="test-key")
|
|
20
20
|
assert client.api_key == "test-key"
|
|
21
21
|
assert client.hostname == "api.geocod.io"
|
|
22
22
|
|
|
@@ -24,7 +24,7 @@ def test_client_initialization():
|
|
|
24
24
|
def test_client_initialization_with_env_var(monkeypatch):
|
|
25
25
|
"""Test that the client can be initialized with an environment variable"""
|
|
26
26
|
monkeypatch.setenv("GEOCODIO_API_KEY", "env-key")
|
|
27
|
-
client =
|
|
27
|
+
client = Geocodio()
|
|
28
28
|
assert client.api_key == "env-key"
|
|
29
29
|
|
|
30
30
|
|
|
@@ -33,7 +33,7 @@ def test_client_initialization_no_key(monkeypatch):
|
|
|
33
33
|
# Ensure environment variable is not set
|
|
34
34
|
monkeypatch.delenv("GEOCODIO_API_KEY", raising=False)
|
|
35
35
|
with pytest.raises(AuthenticationError, match="No API key supplied and GEOCODIO_API_KEY is not set"):
|
|
36
|
-
|
|
36
|
+
Geocodio()
|
|
37
37
|
|
|
38
38
|
|
|
39
39
|
def test_geocode_with_census_data(mock_request):
|
|
@@ -64,7 +64,7 @@ def test_geocode_with_census_data(mock_request):
|
|
|
64
64
|
}]
|
|
65
65
|
})
|
|
66
66
|
|
|
67
|
-
client =
|
|
67
|
+
client = Geocodio("fake-key")
|
|
68
68
|
response = client.geocode(
|
|
69
69
|
{"street": "1109 N Highland St", "city": "Arlington", "state": "VA"},
|
|
70
70
|
fields=["census2010"]
|
|
@@ -102,7 +102,7 @@ def test_geocode_with_acs_data(mock_request):
|
|
|
102
102
|
}]
|
|
103
103
|
})
|
|
104
104
|
|
|
105
|
-
client =
|
|
105
|
+
client = Geocodio("fake-key")
|
|
106
106
|
response = client.geocode(
|
|
107
107
|
{"street": "1109 N Highland St", "city": "Arlington", "state": "VA"},
|
|
108
108
|
fields=["acs"]
|
|
@@ -154,7 +154,7 @@ def test_geocode_batch_with_custom_keys(mock_request):
|
|
|
154
154
|
]
|
|
155
155
|
})
|
|
156
156
|
|
|
157
|
-
client =
|
|
157
|
+
client = Geocodio("fake-key")
|
|
158
158
|
response = client.geocode({
|
|
159
159
|
"address1": "1109 N Highland St, Arlington, VA",
|
|
160
160
|
"address2": "525 University Ave, Toronto, ON, Canada"
|
|
@@ -193,7 +193,7 @@ def test_geocode_with_congressional_districts(mock_request):
|
|
|
193
193
|
}]
|
|
194
194
|
})
|
|
195
195
|
|
|
196
|
-
client =
|
|
196
|
+
client = Geocodio("fake-key")
|
|
197
197
|
response = client.geocode(
|
|
198
198
|
{"street": "1109 N Highland St", "city": "Arlington", "state": "VA"},
|
|
199
199
|
fields=["cd"]
|
|
@@ -229,7 +229,7 @@ def test_user_agent_header_in_request(mocker):
|
|
|
229
229
|
}]
|
|
230
230
|
})
|
|
231
231
|
|
|
232
|
-
client =
|
|
232
|
+
client = Geocodio("test-api-key")
|
|
233
233
|
client.geocode("1109 N Highland St, Arlington, VA")
|
|
234
234
|
|
|
235
235
|
# Verify request was made with correct headers
|
|
@@ -247,7 +247,7 @@ def test_user_agent_header_format():
|
|
|
247
247
|
"""Test that the User-Agent header has the correct format."""
|
|
248
248
|
from geocodio import __version__
|
|
249
249
|
|
|
250
|
-
client =
|
|
250
|
+
client = Geocodio("test-api-key")
|
|
251
251
|
expected_user_agent = f"geocodio-library-python/{__version__}"
|
|
252
252
|
assert client.USER_AGENT == expected_user_agent
|
|
253
253
|
|
|
@@ -262,7 +262,7 @@ def test_user_agent_header_in_batch_request(mocker):
|
|
|
262
262
|
"results": []
|
|
263
263
|
})
|
|
264
264
|
|
|
265
|
-
client =
|
|
265
|
+
client = Geocodio("test-api-key")
|
|
266
266
|
client.geocode(["Address 1", "Address 2"])
|
|
267
267
|
|
|
268
268
|
# Verify headers in batch request
|
|
@@ -295,7 +295,7 @@ def test_user_agent_header_in_reverse_geocode(mocker):
|
|
|
295
295
|
}]
|
|
296
296
|
})
|
|
297
297
|
|
|
298
|
-
client =
|
|
298
|
+
client = Geocodio("test-api-key")
|
|
299
299
|
client.reverse("38.886665,-77.094733")
|
|
300
300
|
|
|
301
301
|
# Verify headers in reverse geocode request
|
|
@@ -321,7 +321,7 @@ def test_user_agent_header_in_list_api(mocker):
|
|
|
321
321
|
"per_page": 10
|
|
322
322
|
})
|
|
323
323
|
|
|
324
|
-
client =
|
|
324
|
+
client = Geocodio("test-api-key")
|
|
325
325
|
client.get_lists()
|
|
326
326
|
|
|
327
327
|
# Verify headers in list API request
|
{geocodio_library_python-0.1.0 → geocodio_library_python-0.2.0}/tests/unit/test_geocoding.py
RENAMED
|
@@ -7,19 +7,19 @@ from typing import List
|
|
|
7
7
|
import pytest
|
|
8
8
|
from dotenv import load_dotenv
|
|
9
9
|
|
|
10
|
-
from geocodio import
|
|
10
|
+
from geocodio import Geocodio
|
|
11
11
|
from geocodio.exceptions import AuthenticationError
|
|
12
12
|
|
|
13
13
|
# Load environment variables from .env file
|
|
14
14
|
load_dotenv()
|
|
15
15
|
|
|
16
16
|
@pytest.fixture
|
|
17
|
-
def client() ->
|
|
18
|
-
"""Create a
|
|
17
|
+
def client() -> Geocodio:
|
|
18
|
+
"""Create a Geocodio instance for testing."""
|
|
19
19
|
api_key = os.getenv("GEOCODIO_API_KEY")
|
|
20
20
|
if not api_key:
|
|
21
21
|
pytest.skip("GEOCODIO_API_KEY environment variable not set")
|
|
22
|
-
return
|
|
22
|
+
return Geocodio(api_key)
|
|
23
23
|
|
|
24
24
|
def test_client_requires_api_key():
|
|
25
25
|
"""Test that client raises AuthenticationError when no API key is provided."""
|
|
@@ -30,13 +30,13 @@ def test_client_requires_api_key():
|
|
|
30
30
|
|
|
31
31
|
try:
|
|
32
32
|
with pytest.raises(AuthenticationError):
|
|
33
|
-
|
|
33
|
+
Geocodio("")
|
|
34
34
|
finally:
|
|
35
35
|
# Restore the environment variable
|
|
36
36
|
if original_key:
|
|
37
37
|
os.environ["GEOCODIO_API_KEY"] = original_key
|
|
38
38
|
|
|
39
|
-
def test_single_forward_geocode(client:
|
|
39
|
+
def test_single_forward_geocode(client: Geocodio):
|
|
40
40
|
"""Test forward geocoding of a single address."""
|
|
41
41
|
response = client.geocode("3730 N Clark St, Chicago, IL")
|
|
42
42
|
|
|
@@ -63,7 +63,7 @@ def test_single_forward_geocode(client: GeocodioClient):
|
|
|
63
63
|
assert components.state == "IL"
|
|
64
64
|
assert components.zip == "60613"
|
|
65
65
|
|
|
66
|
-
def test_batch_forward_geocode(client:
|
|
66
|
+
def test_batch_forward_geocode(client: Geocodio):
|
|
67
67
|
"""Test forward geocoding of multiple addresses."""
|
|
68
68
|
addresses: List[str] = [
|
|
69
69
|
"3730 N Clark St, Chicago, IL",
|
|
@@ -85,7 +85,7 @@ def test_batch_forward_geocode(client: GeocodioClient):
|
|
|
85
85
|
assert denver.accuracy > 0.9
|
|
86
86
|
assert denver.accuracy_type == "rooftop"
|
|
87
87
|
|
|
88
|
-
def test_single_reverse_geocode(client:
|
|
88
|
+
def test_single_reverse_geocode(client: Geocodio):
|
|
89
89
|
"""Test reverse geocoding of coordinates."""
|
|
90
90
|
response = client.reverse("38.9002898,-76.9990361")
|
|
91
91
|
|
|
@@ -102,7 +102,7 @@ def test_single_reverse_geocode(client: GeocodioClient):
|
|
|
102
102
|
assert 38.89 < result.location.lat < 38.91
|
|
103
103
|
assert -77.00 < result.location.lng < -76.99
|
|
104
104
|
|
|
105
|
-
def test_geocode_with_fields(client:
|
|
105
|
+
def test_geocode_with_fields(client: Geocodio):
|
|
106
106
|
"""Test geocoding with additional data fields."""
|
|
107
107
|
response = client.geocode(
|
|
108
108
|
"3730 N Clark St, Chicago, IL",
|
|
File without changes
|
{geocodio_library_python-0.1.0 → geocodio_library_python-0.2.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
|
{geocodio_library_python-0.1.0 → geocodio_library_python-0.2.0}/tests/unit/test_exceptions.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|