|
|
@ -39,3 +39,29 @@ def test_bad_connection(): |
|
|
|
cm.raw_post(path="bad", data={}) |
|
|
|
with pytest.raises(KeycloakConnectionError): |
|
|
|
cm.raw_put(path="bad", data={}) |
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.asyncio |
|
|
|
async def a_test_bad_connection(): |
|
|
|
"""Test bad connection.""" |
|
|
|
cm = ConnectionManager(base_url="http://not.real.domain") |
|
|
|
with pytest.raises(KeycloakConnectionError): |
|
|
|
await cm.a_raw_get(path="bad") |
|
|
|
with pytest.raises(KeycloakConnectionError): |
|
|
|
await cm.a_raw_delete(path="bad") |
|
|
|
with pytest.raises(KeycloakConnectionError): |
|
|
|
await cm.a_raw_post(path="bad", data={}) |
|
|
|
with pytest.raises(KeycloakConnectionError): |
|
|
|
await cm.a_raw_put(path="bad", data={}) |
|
|
|
|
|
|
|
|
|
|
|
def test_counter_part(): |
|
|
|
"""Test that each function has its async counter part.""" |
|
|
|
con_methods = [ |
|
|
|
func for func in dir(ConnectionManager) if callable(getattr(ConnectionManager, func)) |
|
|
|
] |
|
|
|
sync_methods = [method for method in con_methods if method.startswith("a_")] |
|
|
|
|
|
|
|
for method in sync_methods: |
|
|
|
async_method = method[2:] |
|
|
|
assert (async_method in con_methods) is True |