From a6b109f3d2cb197a3dd7861dd02ed15bbf9fa252 Mon Sep 17 00:00:00 2001 From: Richard Nemeth Date: Thu, 6 Jun 2024 13:22:11 +0200 Subject: [PATCH] test: final divergence tests --- tests/test_connection.py | 30 +++++++++++++++++++++++++++--- tests/test_keycloak_admin.py | 11 ++++++++++- tests/test_keycloak_openid.py | 11 ++++++++++- tests/test_keycloak_uma.py | 11 ++++++++++- 4 files changed, 57 insertions(+), 6 deletions(-) diff --git a/tests/test_connection.py b/tests/test_connection.py index c92e088..448fcee 100644 --- a/tests/test_connection.py +++ b/tests/test_connection.py @@ -1,6 +1,6 @@ """Connection test module.""" -from inspect import signature +from inspect import iscoroutinefunction, signature import pytest @@ -62,11 +62,35 @@ def test_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_")] + sync_methods = [ + method + for method in con_methods + if not method.startswith("a_") and not method.startswith("_") + ] + async_methods = [ + method for method in con_methods if iscoroutinefunction(getattr(ConnectionManager, method)) + ] for method in sync_methods: - async_method = method[2:] + if method in [ + "aclose", + "add_param_headers", + "del_param_headers", + "clean_headers", + "exist_param_headers", + "param_headers", + ]: + continue + async_method = f"a_{method}" assert (async_method in con_methods) is True sync_sign = signature(getattr(ConnectionManager, method)) async_sign = signature(getattr(ConnectionManager, async_method)) assert sync_sign.parameters == async_sign.parameters + + for async_method in async_methods: + if async_method in ["aclose"]: + continue + if async_method[2:].startswith("_"): + continue + + assert async_method[2:] in sync_methods diff --git a/tests/test_keycloak_admin.py b/tests/test_keycloak_admin.py index d7c8bc4..600bab6 100644 --- a/tests/test_keycloak_admin.py +++ b/tests/test_keycloak_admin.py @@ -3,7 +3,7 @@ import copy import os import uuid -from inspect import signature +from inspect import iscoroutinefunction, signature from typing import Tuple import freezegun @@ -6157,6 +6157,9 @@ def test_counter_part(): for method in admin_methods if not method.startswith("a_") and not method.startswith("_") ] + async_methods = [ + method for method in admin_methods if iscoroutinefunction(getattr(KeycloakAdmin, method)) + ] for method in sync_methods: async_method = f"a_{method}" @@ -6164,3 +6167,9 @@ def test_counter_part(): sync_sign = signature(getattr(KeycloakAdmin, method)) async_sign = signature(getattr(KeycloakAdmin, async_method)) assert sync_sign.parameters == async_sign.parameters + + for async_method in async_methods: + if async_method[2:].startswith("_"): + continue + + assert async_method[2:] in sync_methods diff --git a/tests/test_keycloak_openid.py b/tests/test_keycloak_openid.py index 56d0885..20b1599 100644 --- a/tests/test_keycloak_openid.py +++ b/tests/test_keycloak_openid.py @@ -1,6 +1,6 @@ """Test module for KeycloakOpenID.""" -from inspect import signature +from inspect import iscoroutinefunction, signature from typing import Tuple from unittest import mock @@ -984,6 +984,9 @@ def test_counter_part(): for method in openid_methods if not method.startswith("a_") and not method.startswith("_") ] + async_methods = [ + method for method in openid_methods if iscoroutinefunction(getattr(KeycloakOpenID, method)) + ] for method in sync_methods: async_method = f"a_{method}" @@ -991,3 +994,9 @@ def test_counter_part(): sync_sign = signature(getattr(KeycloakOpenID, method)) async_sign = signature(getattr(KeycloakOpenID, async_method)) assert sync_sign.parameters == async_sign.parameters + + for async_method in async_methods: + if async_method[2:].startswith("_"): + continue + + assert async_method[2:] in sync_methods diff --git a/tests/test_keycloak_uma.py b/tests/test_keycloak_uma.py index 462b7cb..aabc067 100644 --- a/tests/test_keycloak_uma.py +++ b/tests/test_keycloak_uma.py @@ -1,7 +1,7 @@ """Test module for KeycloakUMA.""" import re -from inspect import signature +from inspect import iscoroutinefunction, signature import pytest @@ -610,6 +610,9 @@ def test_counter_part(): for method in uma_methods if not method.startswith("a_") and not method.startswith("_") ] + async_methods = [ + method for method in uma_methods if iscoroutinefunction(getattr(KeycloakUMA, method)) + ] for method in sync_methods: async_method = f"a_{method}" @@ -617,3 +620,9 @@ def test_counter_part(): sync_sign = signature(getattr(KeycloakUMA, method)) async_sign = signature(getattr(KeycloakUMA, async_method)) assert sync_sign.parameters == async_sign.parameters + + for async_method in async_methods: + if async_method[2:].startswith("_"): + continue + + assert async_method[2:] in sync_methods