11"""
2- Tests for the GeocodioClient class
2+ Tests for the Geocodio class
33"""
44
55import pytest
66import httpx
7- from geocodio import GeocodioClient
7+ from geocodio import Geocodio
88from geocodio .exceptions import AuthenticationError
99
1010
1111@pytest .fixture
1212def 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
1717def 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
2424def 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
3939def 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