Skip to content

Commit e2a981f

Browse files
Merge pull request #11 from Geocodio/refactor/rename-client-to-geocodio
refactor!: Rename GeocodioClient to Geocodio
2 parents 4713a68 + 4ca2d4b commit e2a981f

File tree

12 files changed

+222
-222
lines changed

12 files changed

+222
-222
lines changed

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ Usage
2424
### Geocoding
2525

2626
```python
27-
from geocodio import GeocodioClient
27+
from geocodio import Geocodio
2828

2929
# Initialize the client with your API key
30-
client = GeocodioClient("YOUR_API_KEY")
30+
client = Geocodio("YOUR_API_KEY")
3131

3232
# Single forward geocode
3333
response = client.geocode("1600 Pennsylvania Ave, Washington, DC")
@@ -59,10 +59,10 @@ print(data.results[0].fields.timezone.name if data.results[0].fields.timezone el
5959
The List API allows you to manage lists of addresses or coordinates for batch processing.
6060

6161
```python
62-
from geocodio import GeocodioClient
62+
from geocodio import Geocodio
6363

6464
# Initialize the client with your API key
65-
client = GeocodioClient("YOUR_API_KEY")
65+
client = Geocodio("YOUR_API_KEY")
6666

6767
# Get all lists
6868
lists = client.get_lists()
@@ -94,17 +94,17 @@ Error Handling
9494
--------------
9595

9696
```python
97-
from geocodio import GeocodioClient
97+
from geocodio import Geocodio
9898
from geocodio.exceptions import AuthenticationError, InvalidRequestError
9999

100100
try:
101-
client = GeocodioClient("INVALID_API_KEY")
101+
client = Geocodio("INVALID_API_KEY")
102102
response = client.geocode("1600 Pennsylvania Ave, Washington, DC")
103103
except AuthenticationError as e:
104104
print(f"Authentication failed: {e}")
105105

106106
try:
107-
client = GeocodioClient("YOUR_API_KEY")
107+
client = Geocodio("YOUR_API_KEY")
108108
response = client.geocode("") # Empty address
109109
except InvalidRequestError as e:
110110
print(f"Invalid request: {e}")
@@ -116,10 +116,10 @@ Geocodio Enterprise
116116
To use this library with Geocodio Enterprise, pass `api.enterprise.geocod.io` as the `hostname` parameter when initializing the client:
117117

118118
```python
119-
from geocodio import GeocodioClient
119+
from geocodio import Geocodio
120120

121121
# Initialize client for Geocodio Enterprise
122-
client = GeocodioClient(
122+
client = Geocodio(
123123
"YOUR_API_KEY",
124124
hostname="api.enterprise.geocod.io"
125125
)

smoke.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python3
22

3-
from geocodio import GeocodioClient
3+
from geocodio import Geocodio
44
from dotenv import load_dotenv
55
import os
66
import json
@@ -10,7 +10,7 @@
1010
load_dotenv()
1111

1212
# Initialize the client with your API key
13-
client = GeocodioClient(os.getenv("GEOCODIO_API_KEY"))
13+
client = Geocodio(os.getenv("GEOCODIO_API_KEY"))
1414

1515
# Single forward geocode
1616
print("\nSingle forward geocode:")

smoke_lists.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import os
44
import time
55
import logging
6-
from geocodio import GeocodioClient
6+
from geocodio import Geocodio
77
from geocodio.models import ListProcessingState
88
from dotenv import load_dotenv
99

@@ -51,7 +51,7 @@ def main():
5151
logger.error("GEOCODIO_API_KEY not set in environment.")
5252
exit(1)
5353

54-
client = GeocodioClient(api_key)
54+
client = Geocodio(api_key)
5555

5656
# Step 1: Create a list
5757
logger.info("Creating a new list...")

src/geocodio/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
"""
55

66
from ._version import __version__
7-
from .client import GeocodioClient
7+
from .client import Geocodio
88

9-
__all__ = ["GeocodioClient", "__version__"]
9+
__all__ = ["Geocodio", "__version__"]

src/geocodio/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
from geocodio.exceptions import InvalidRequestError, AuthenticationError, GeocodioServerError, BadRequestError
2828

2929

30-
class GeocodioClient:
30+
class Geocodio:
3131
BASE_PATH = "/v1.9" # keep in sync with Geocodio's current version
3232
DEFAULT_SINGLE_TIMEOUT = 5.0
3333
DEFAULT_BATCH_TIMEOUT = 1800.0 # 30 minutes

tests/conftest.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import logging
77
from dotenv import load_dotenv
88
import pytest
9-
from geocodio import GeocodioClient
9+
from geocodio import Geocodio
1010

1111
# Load environment variables from .env file
1212
load_dotenv()
@@ -18,15 +18,15 @@
1818

1919
@pytest.fixture
2020
def client(request):
21-
"""Create a GeocodioClient instance with test configuration"""
21+
"""Create a Geocodio instance with test configuration"""
2222
# Use TEST_KEY for all tests except e2e tests
2323
if "e2e" in request.node.fspath.strpath:
2424
logger.debug("Running e2e tests - using API key from environment")
2525
api_key = os.getenv("GEOCODIO_API_KEY")
2626
if not api_key:
2727
logger.warning("GEOCODIO_API_KEY not set - skipping e2e test")
2828
pytest.skip("GEOCODIO_API_KEY environment variable not set")
29-
return GeocodioClient(api_key=api_key)
29+
return Geocodio(api_key=api_key)
3030
else:
3131
logger.debug("Running unit tests - using TEST_KEY with api.test hostname")
32-
return GeocodioClient(api_key="TEST_KEY", hostname="api.test")
32+
return Geocodio(api_key="TEST_KEY", hostname="api.test")

tests/e2e/test_api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import os
77
import pytest
8-
from geocodio import GeocodioClient
8+
from geocodio import Geocodio
99
from geocodio.exceptions import GeocodioError
1010

1111

@@ -15,7 +15,7 @@ def client():
1515
api_key = os.getenv("GEOCODIO_API_KEY")
1616
if not api_key:
1717
pytest.skip("GEOCODIO_API_KEY environment variable not set")
18-
return GeocodioClient(api_key)
18+
return Geocodio(api_key)
1919

2020

2121
def test_integration_geocode(client):

tests/e2e/test_batch_reverse.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"""
44

55
import pytest
6-
from geocodio import GeocodioClient
6+
from geocodio import Geocodio
77

88

99
def test_batch_reverse_geocoding(client):

tests/e2e/test_lists_api.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import pytest
88
import time
99
from unittest.mock import patch
10-
from geocodio import GeocodioClient
10+
from geocodio import Geocodio
1111
from geocodio.models import ListResponse, PaginatedResponse, ListProcessingState
1212
from geocodio.exceptions import GeocodioServerError
1313
import logging
@@ -22,7 +22,7 @@ def client():
2222
api_key = os.getenv("GEOCODIO_API_KEY")
2323
if not api_key:
2424
pytest.skip("GEOCODIO_API_KEY environment variable not set")
25-
return GeocodioClient(api_key)
25+
return Geocodio(api_key)
2626

2727

2828
@pytest.fixture
@@ -59,8 +59,8 @@ def wait_for_list_processed(client, list_id, timeout=120):
5959

6060
def test_create_list(client):
6161
"""
62-
Test creating a list with GeocodioClient.create_list()
63-
:param client: GeocodioClient instance
62+
Test creating a list with Geocodio.create_list()
63+
:param client: Geocodio instance
6464
"""
6565
new_list = client.create_list(file="Zip\n20003\n20001", filename="test_list.csv")
6666

@@ -69,8 +69,8 @@ def test_create_list(client):
6969

7070
def test_get_list_status(client, list_response):
7171
"""
72-
Test retrieving the status of a list with GeocodioClient.get_list_status()
73-
:param client: GeocodioClient instance
72+
Test retrieving the status of a list with Geocodio.get_list_status()
73+
:param client: Geocodio instance
7474
:param list_response: List object created in the fixture
7575
"""
7676
# Get the status of the test list

tests/unit/test_client.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
"""
2-
Tests for the GeocodioClient class
2+
Tests for the Geocodio class
33
"""
44

55
import pytest
66
import httpx
7-
from geocodio import GeocodioClient
7+
from geocodio import Geocodio
88
from geocodio.exceptions import AuthenticationError
99

1010

1111
@pytest.fixture
1212
def mock_request(mocker):
1313
"""Mock the _request method."""
14-
return mocker.patch('geocodio.client.GeocodioClient._request')
14+
return mocker.patch('geocodio.client.Geocodio._request')
1515

1616

1717
def test_client_initialization():
1818
"""Test that the client can be initialized with an API key"""
19-
client = GeocodioClient(api_key="test-key")
19+
client = Geocodio(api_key="test-key")
2020
assert client.api_key == "test-key"
2121
assert client.hostname == "api.geocod.io"
2222

2323

2424
def test_client_initialization_with_env_var(monkeypatch):
2525
"""Test that the client can be initialized with an environment variable"""
2626
monkeypatch.setenv("GEOCODIO_API_KEY", "env-key")
27-
client = GeocodioClient()
27+
client = Geocodio()
2828
assert client.api_key == "env-key"
2929

3030

@@ -33,7 +33,7 @@ def test_client_initialization_no_key(monkeypatch):
3333
# Ensure environment variable is not set
3434
monkeypatch.delenv("GEOCODIO_API_KEY", raising=False)
3535
with pytest.raises(AuthenticationError, match="No API key supplied and GEOCODIO_API_KEY is not set"):
36-
GeocodioClient()
36+
Geocodio()
3737

3838

3939
def test_geocode_with_census_data(mock_request):
@@ -64,7 +64,7 @@ def test_geocode_with_census_data(mock_request):
6464
}]
6565
})
6666

67-
client = GeocodioClient("fake-key")
67+
client = Geocodio("fake-key")
6868
response = client.geocode(
6969
{"street": "1109 N Highland St", "city": "Arlington", "state": "VA"},
7070
fields=["census2010"]
@@ -102,7 +102,7 @@ def test_geocode_with_acs_data(mock_request):
102102
}]
103103
})
104104

105-
client = GeocodioClient("fake-key")
105+
client = Geocodio("fake-key")
106106
response = client.geocode(
107107
{"street": "1109 N Highland St", "city": "Arlington", "state": "VA"},
108108
fields=["acs"]
@@ -154,7 +154,7 @@ def test_geocode_batch_with_custom_keys(mock_request):
154154
]
155155
})
156156

157-
client = GeocodioClient("fake-key")
157+
client = Geocodio("fake-key")
158158
response = client.geocode({
159159
"address1": "1109 N Highland St, Arlington, VA",
160160
"address2": "525 University Ave, Toronto, ON, Canada"
@@ -193,7 +193,7 @@ def test_geocode_with_congressional_districts(mock_request):
193193
}]
194194
})
195195

196-
client = GeocodioClient("fake-key")
196+
client = Geocodio("fake-key")
197197
response = client.geocode(
198198
{"street": "1109 N Highland St", "city": "Arlington", "state": "VA"},
199199
fields=["cd"]
@@ -229,7 +229,7 @@ def test_user_agent_header_in_request(mocker):
229229
}]
230230
})
231231

232-
client = GeocodioClient("test-api-key")
232+
client = Geocodio("test-api-key")
233233
client.geocode("1109 N Highland St, Arlington, VA")
234234

235235
# Verify request was made with correct headers
@@ -247,7 +247,7 @@ def test_user_agent_header_format():
247247
"""Test that the User-Agent header has the correct format."""
248248
from geocodio import __version__
249249

250-
client = GeocodioClient("test-api-key")
250+
client = Geocodio("test-api-key")
251251
expected_user_agent = f"geocodio-library-python/{__version__}"
252252
assert client.USER_AGENT == expected_user_agent
253253

@@ -262,7 +262,7 @@ def test_user_agent_header_in_batch_request(mocker):
262262
"results": []
263263
})
264264

265-
client = GeocodioClient("test-api-key")
265+
client = Geocodio("test-api-key")
266266
client.geocode(["Address 1", "Address 2"])
267267

268268
# Verify headers in batch request
@@ -295,7 +295,7 @@ def test_user_agent_header_in_reverse_geocode(mocker):
295295
}]
296296
})
297297

298-
client = GeocodioClient("test-api-key")
298+
client = Geocodio("test-api-key")
299299
client.reverse("38.886665,-77.094733")
300300

301301
# Verify headers in reverse geocode request
@@ -321,7 +321,7 @@ def test_user_agent_header_in_list_api(mocker):
321321
"per_page": 10
322322
})
323323

324-
client = GeocodioClient("test-api-key")
324+
client = Geocodio("test-api-key")
325325
client.get_lists()
326326

327327
# Verify headers in list API request

0 commit comments

Comments
 (0)