Skip to content

Commit 0835d0b

Browse files
test: update tests to use renamed Geocodio class
Update all test files and smoke tests to import and use the new Geocodio class name instead of GeocodioClient.
1 parent 559a88c commit 0835d0b

File tree

8 files changed

+41
-41
lines changed

8 files changed

+41
-41
lines changed

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...")

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

tests/unit/test_geocoding.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,19 @@
77
import pytest
88
from dotenv import load_dotenv
99

10-
from geocodio import GeocodioClient
10+
from geocodio import Geocodio
1111
from geocodio.exceptions import AuthenticationError
1212

1313
# Load environment variables from .env file
1414
load_dotenv()
1515

1616
@pytest.fixture
17-
def client() -> GeocodioClient:
18-
"""Create a GeocodioClient instance for testing."""
17+
def client() -> Geocodio:
18+
"""Create a Geocodio instance for testing."""
1919
api_key = os.getenv("GEOCODIO_API_KEY")
2020
if not api_key:
2121
pytest.skip("GEOCODIO_API_KEY environment variable not set")
22-
return GeocodioClient(api_key)
22+
return Geocodio(api_key)
2323

2424
def test_client_requires_api_key():
2525
"""Test that client raises AuthenticationError when no API key is provided."""
@@ -30,13 +30,13 @@ def test_client_requires_api_key():
3030

3131
try:
3232
with pytest.raises(AuthenticationError):
33-
GeocodioClient("")
33+
Geocodio("")
3434
finally:
3535
# Restore the environment variable
3636
if original_key:
3737
os.environ["GEOCODIO_API_KEY"] = original_key
3838

39-
def test_single_forward_geocode(client: GeocodioClient):
39+
def test_single_forward_geocode(client: Geocodio):
4040
"""Test forward geocoding of a single address."""
4141
response = client.geocode("3730 N Clark St, Chicago, IL")
4242

@@ -63,7 +63,7 @@ def test_single_forward_geocode(client: GeocodioClient):
6363
assert components.state == "IL"
6464
assert components.zip == "60613"
6565

66-
def test_batch_forward_geocode(client: GeocodioClient):
66+
def test_batch_forward_geocode(client: Geocodio):
6767
"""Test forward geocoding of multiple addresses."""
6868
addresses: List[str] = [
6969
"3730 N Clark St, Chicago, IL",
@@ -85,7 +85,7 @@ def test_batch_forward_geocode(client: GeocodioClient):
8585
assert denver.accuracy > 0.9
8686
assert denver.accuracy_type == "rooftop"
8787

88-
def test_single_reverse_geocode(client: GeocodioClient):
88+
def test_single_reverse_geocode(client: Geocodio):
8989
"""Test reverse geocoding of coordinates."""
9090
response = client.reverse("38.9002898,-76.9990361")
9191

@@ -102,7 +102,7 @@ def test_single_reverse_geocode(client: GeocodioClient):
102102
assert 38.89 < result.location.lat < 38.91
103103
assert -77.00 < result.location.lng < -76.99
104104

105-
def test_geocode_with_fields(client: GeocodioClient):
105+
def test_geocode_with_fields(client: Geocodio):
106106
"""Test geocoding with additional data fields."""
107107
response = client.geocode(
108108
"3730 N Clark St, Chicago, IL",

0 commit comments

Comments
 (0)