@@ -29,7 +29,9 @@ def anyio_backend() -> str:
2929 return "asyncio"
3030
3131
32- def nipost (distance_m : float = 6.0 , * , valid : bool = True , found : bool = True ) -> AsyncClient :
32+ def nipost (
33+ distance_m : float = 6.0 , * , valid : bool = True , found : bool = True , key : str = "key"
34+ ) -> AsyncClient :
3335 def handle (request : httpx .Request ) -> httpx .Response :
3436 if request .url .path == "/v1/lookup" :
3537 return httpx .Response (
@@ -48,7 +50,7 @@ def handle(request: httpx.Request) -> httpx.Response:
4850 data |= {"unit" : unit , "area" : "EK-01-A03-FK" , "district" : "EK-01-A03" , "state" : "EK" }
4951 return httpx .Response (200 , json = {"data" : data })
5052
51- return AsyncClient (" key" , http = httpx .AsyncClient (transport = httpx .MockTransport (handle )))
53+ return AsyncClient (key , http = httpx .AsyncClient (transport = httpx .MockTransport (handle )))
5254
5355
5456def reading (relation : Relation | None , question : str | None = None ) -> ParsedAddress :
@@ -211,6 +213,16 @@ async def test_an_unassigned_typed_code_falls_back_to_the_pin() -> None:
211213 assert result .evidence [1 ] == "NIPOST says it is not assigned."
212214
213215
216+ @pytest .mark .anyio
217+ async def test_a_code_a_test_key_cannot_confirm_says_so () -> None :
218+ resolver = Resolver (nipost = nipost (valid = False , key = "nipost_pk_test_1" ))
219+ result = await resolver .resolve ("EK-01-A03-FK-01, NTA Road" )
220+ assert result .evidence [1 ] == (
221+ "NIPOST says it is not assigned. It was asked with a test key, which may not see "
222+ "assigned codes."
223+ )
224+
225+
214226@pytest .mark .anyio
215227async def test_a_spaced_code_counts_only_when_nipost_confirms_it () -> None :
216228 text = "No 12 Oba St 45, Ikeja"
0 commit comments