Skip to content

Commit e9e7dc3

Browse files
committed
Update tests
1 parent d80be29 commit e9e7dc3

3 files changed

Lines changed: 17 additions & 9 deletions

File tree

auth0/test_async/test_async_auth0.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import unittest
33
from unittest.mock import ANY, MagicMock
44

5+
import pytest
56
from aioresponses import CallbackResult, aioresponses
67
from yarl import URL
78

@@ -21,17 +22,18 @@ def callback(url, **kwargs):
2122
return callback, mock
2223

2324

24-
@unittest.skipIf(
25-
not hasattr(unittest, "IsolatedAsyncioTestCase"),
26-
"python 3.7 doesn't have IsolatedAsyncioTestCase",
27-
)
28-
class TestAuth0(getattr(unittest, "IsolatedAsyncioTestCase", object)):
25+
class TestAuth0(unittest.TestCase):
26+
@pytest.mark.asyncio
2927
@aioresponses()
3028
async def test_get(self, mocked):
3129
callback, mock = get_callback()
32-
mocked.get(clients, callback=callback)
30+
31+
await mocked.get(clients, callback=callback)
32+
3333
auth0 = Auth0(domain="example.com", token="jwt")
34+
3435
self.assertEqual(await auth0.clients.all_async(), payload)
36+
3537
mock.assert_called_with(
3638
URL("https://example.com/api/v2/clients?include_fields=true"),
3739
allow_redirects=True,
@@ -40,25 +42,30 @@ async def test_get(self, mocked):
4042
timeout=ANY,
4143
)
4244

45+
@pytest.mark.asyncio
4346
@aioresponses()
4447
async def test_shared_session(self, mocked):
4548
callback, mock = get_callback()
4649
callback2, mock2 = get_callback()
47-
mocked.get(clients, callback=callback)
48-
mocked.put(factors, callback=callback2)
50+
51+
await mocked.get(clients, callback=callback)
52+
await mocked.put(factors, callback=callback2)
53+
4954
async with Auth0(domain="example.com", token="jwt") as auth0:
5055
self.assertEqual(await auth0.clients.all_async(), payload)
5156
self.assertEqual(
5257
await auth0.guardian.update_factor_async("factor-1", {"factor": 1}),
5358
payload,
5459
)
60+
5561
mock.assert_called_with(
5662
URL("https://example.com/api/v2/clients?include_fields=true"),
5763
allow_redirects=True,
5864
params={"include_fields": "true"},
5965
headers=ANY,
6066
timeout=ANY,
6167
)
68+
6269
mock2.assert_called_with(
6370
URL("https://example.com/api/v2/guardian/factors/factor-1"),
6471
allow_redirects=True,

poetry.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ mock = "^5.1.0"
3939
pipx = "^1.2.0"
4040
pytest = "^7.4.0"
4141
pytest-aiohttp = "^1.0.4"
42+
pytest-asyncio = "^0.21.1"
4243
pytest-cov = "^4.1.0"
4344
responses = "^0.23.3"
4445

0 commit comments

Comments
 (0)