@@ -277,27 +277,58 @@ async def test_add_geostore_gfw_branch(
277277 assert mock_create_gfw_geostore .called is True
278278
279279
280- # @pytest.mark.asyncio
281- # async def test_get_geostore_rw_branch(
282- # async_client: AsyncClient, monkeypatch: MonkeyPatch
283- # ):
284- # url = "/geostore/88db597b6bcd096fb80d1542cdc442be"
285- #
286- # mock_proxy_get_geostore = AsyncMock(
287- # return_value=Response(status_code=200),
288- # spec=geostore.proxy_get_geostore
289- # )
290- #
291- # monkeypatch.setattr(geostore, "proxy_get_geostore", mock_proxy_get_geostore)
292- #
293- # response = await async_client.post(
294- # url,
295- # json=RWGeostoreIn(**create_rw_geostore_payload).dict(),
296- # follow_redirects=True
297- # )
298- #
299- # assert response.json() == create_rw_geostore_output
300- # assert response.status_code == 200
301- #
302- #
303- #
280+ @pytest .mark .asyncio
281+ async def test_get_geostore_rw_branch (
282+ async_client : AsyncClient , monkeypatch : MonkeyPatch
283+ ):
284+ url = "/geostore/88db597b6bcd096fb80d1542cdc442be"
285+
286+ mock_proxy_get_geostore = AsyncMock (
287+ return_value = RWGeostoreResponse (** example_geostore_resp ),
288+ spec = geostore .proxy_get_geostore ,
289+ )
290+ monkeypatch .setattr (geostore , "proxy_get_geostore" , mock_proxy_get_geostore )
291+
292+ mock_geostore_obj = MagicMock (spec = Geostore )
293+ mock_get_gfw_geostore_from_any_dataset = AsyncMock (
294+ return_value = mock_geostore_obj ,
295+ spec = crud_geostore .get_gfw_geostore_from_any_dataset ,
296+ )
297+ monkeypatch .setattr (
298+ crud_geostore ,
299+ "get_gfw_geostore_from_any_dataset" ,
300+ mock_get_gfw_geostore_from_any_dataset ,
301+ )
302+
303+ _ = await async_client .get (url )
304+
305+ assert mock_proxy_get_geostore .called is True
306+ assert mock_get_gfw_geostore_from_any_dataset .called is False
307+
308+
309+ @pytest .mark .asyncio
310+ async def test_get_geostore_gfw_branch (
311+ async_client : AsyncClient , monkeypatch : MonkeyPatch
312+ ):
313+ url = "/geostore/db2b4428-bad2-fc94-1ea8-041597dc482c"
314+
315+ mock_proxy_get_geostore = AsyncMock (
316+ return_value = RWGeostoreResponse (** example_geostore_resp ),
317+ spec = geostore .proxy_get_geostore ,
318+ )
319+ monkeypatch .setattr (geostore , "proxy_get_geostore" , mock_proxy_get_geostore )
320+
321+ mock_get_gfw_geostore_from_any_dataset = AsyncMock (
322+ return_value = Geostore (** create_gfw_geostore_data ),
323+ spec = crud_geostore .get_gfw_geostore_from_any_dataset ,
324+ )
325+ monkeypatch .setattr (
326+ crud_geostore ,
327+ "get_gfw_geostore_from_any_dataset" ,
328+ mock_get_gfw_geostore_from_any_dataset ,
329+ )
330+
331+ _ = await async_client .get (url )
332+
333+ assert mock_proxy_get_geostore .called is False
334+ assert mock_get_gfw_geostore_from_any_dataset .called is True
0 commit comments