From 0fd58ee68e7a820adc51a238fc5ce0c92da9cb91 Mon Sep 17 00:00:00 2001 From: Jan Range Date: Fri, 1 Mar 2024 20:51:36 +0100 Subject: [PATCH] test async functions --- tests/api/test_async_api.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 tests/api/test_async_api.py diff --git a/tests/api/test_async_api.py b/tests/api/test_async_api.py new file mode 100644 index 0000000..9cb8232 --- /dev/null +++ b/tests/api/test_async_api.py @@ -0,0 +1,18 @@ +import asyncio +import pytest + +from pyDataverse.api import NativeApi + + +class TestAsyncAPI: + + @pytest.mark.asyncio + async def test_async_api(self, native_api): + + async with native_api: + tasks = [native_api.get_info_version() for _ in range(10)] + responses = await asyncio.gather(*tasks) + + assert len(responses) == 10 + for response in responses: + assert response.status_code == 200, "Request failed."