Skip to content

Commit

Permalink
leverage pytest-asyncio test discovery mode auto
Browse files Browse the repository at this point in the history
  • Loading branch information
jakob-keller committed Dec 15, 2024
1 parent e7d6ddf commit 872ccc3
Show file tree
Hide file tree
Showing 26 changed files with 0 additions and 186 deletions.
33 changes: 0 additions & 33 deletions tests/boto_tests/test_credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ async def load():


@pytest.mark.moto
@pytest.mark.asyncio
async def test_assumerolefetcher_no_cache():
response = {
'Credentials': {
Expand All @@ -151,7 +150,6 @@ async def test_assumerolefetcher_no_cache():


@pytest.mark.moto
@pytest.mark.asyncio
async def test_assumerolefetcher_cache_key_with_role_session_name():
response = {
'Credentials': {
Expand Down Expand Up @@ -181,7 +179,6 @@ async def test_assumerolefetcher_cache_key_with_role_session_name():


@pytest.mark.moto
@pytest.mark.asyncio
async def test_assumerolefetcher_cache_in_cache_but_expired():
response = {
'Credentials': {
Expand Down Expand Up @@ -216,7 +213,6 @@ async def test_assumerolefetcher_cache_in_cache_but_expired():


@pytest.mark.moto
@pytest.mark.asyncio
async def test_assumerolefetcher_mfa():
response = {
'Credentials': {
Expand Down Expand Up @@ -249,7 +245,6 @@ async def test_assumerolefetcher_mfa():


@pytest.mark.moto
@pytest.mark.asyncio
async def test_recursive_assume_role(assume_role_setup):
self = assume_role_setup

Expand Down Expand Up @@ -307,7 +302,6 @@ async def __aexit__(self, exc_type, exc_val, exc_tb):


@pytest.mark.moto
@pytest.mark.asyncio
async def test_webidentfetcher_no_cache():
response = {
'Credentials': {
Expand All @@ -330,7 +324,6 @@ async def test_webidentfetcher_no_cache():


@pytest.mark.moto
@pytest.mark.asyncio
async def test_credresolver_load_credentials_single_provider(
credential_provider,
):
Expand All @@ -348,7 +341,6 @@ async def test_credresolver_load_credentials_single_provider(


@pytest.mark.moto
@pytest.mark.asyncio
async def test_credresolver_no_providers(credential_provider):
provider1 = credential_provider('provider1', 'CustomProvider1', None)
resolver = credentials.AioCredentialResolver(providers=[provider1])
Expand All @@ -359,7 +351,6 @@ async def test_credresolver_no_providers(credential_provider):

# From class TestCanonicalNameSourceProvider(BaseEnvVar):
@pytest.mark.moto
@pytest.mark.asyncio
async def test_canonicalsourceprovider_source_creds(credential_provider):
creds = credentials.AioCredentials('a', 'b', 'c')
provider1 = credential_provider('provider1', 'CustomProvider1', creds)
Expand All @@ -373,7 +364,6 @@ async def test_canonicalsourceprovider_source_creds(credential_provider):


@pytest.mark.moto
@pytest.mark.asyncio
async def test_canonicalsourceprovider_source_creds_case_insensitive(
credential_provider,
):
Expand Down Expand Up @@ -419,7 +409,6 @@ def _f(config=None):


@pytest.mark.moto
@pytest.mark.asyncio
async def test_assumerolecredprovider_assume_role_no_cache(
credential_provider, assumerolecredprovider_config_loader
):
Expand Down Expand Up @@ -462,7 +451,6 @@ async def test_assumerolecredprovider_assume_role_no_cache(

# MFA
@pytest.mark.moto
@pytest.mark.asyncio
async def test_assumerolecredprovider_mfa(
credential_provider, assumerolecredprovider_config_loader
):
Expand Down Expand Up @@ -521,7 +509,6 @@ async def test_assumerolecredprovider_mfa(


@pytest.mark.moto
@pytest.mark.asyncio
async def test_assumerolecredprovider_mfa_cannot_refresh_credentials(
credential_provider, assumerolecredprovider_config_loader
):
Expand Down Expand Up @@ -578,7 +565,6 @@ async def test_assumerolecredprovider_mfa_cannot_refresh_credentials(

# From class TestAssumeRoleWithWebIdentityCredentialProvider
@pytest.mark.moto
@pytest.mark.asyncio
async def test_assumerolewebidentprovider_no_cache():
future = datetime.now(tzlocal()) + timedelta(hours=24)

Expand Down Expand Up @@ -631,7 +617,6 @@ def full_url(url):

# From class TestEnvVar(BaseEnvVar):
@pytest.mark.moto
@pytest.mark.asyncio
async def test_envvarprovider_env_var_present():
environ = {
'AWS_ACCESS_KEY_ID': 'foo',
Expand All @@ -647,7 +632,6 @@ async def test_envvarprovider_env_var_present():


@pytest.mark.moto
@pytest.mark.asyncio
async def test_envvarprovider_env_var_absent():
environ = {}
provider = credentials.AioEnvProvider(environ)
Expand All @@ -656,7 +640,6 @@ async def test_envvarprovider_env_var_absent():


@pytest.mark.moto
@pytest.mark.asyncio
async def test_envvarprovider_env_var_expiry():
expiry_time = datetime.now(tzlocal()) - timedelta(hours=1)
environ = {
Expand Down Expand Up @@ -692,7 +675,6 @@ def profile_config():


@pytest.mark.moto
@pytest.mark.asyncio
async def test_configprovider_file_exists(profile_config):
provider = credentials.AioConfigProvider(
'cli.cfg', 'default', profile_config
Expand All @@ -706,7 +688,6 @@ async def test_configprovider_file_exists(profile_config):


@pytest.mark.moto
@pytest.mark.asyncio
async def test_configprovider_file_missing_profile(profile_config):
provider = credentials.AioConfigProvider(
'cli.cfg', 'NOT-default', profile_config
Expand All @@ -717,7 +698,6 @@ async def test_configprovider_file_missing_profile(profile_config):

# From class TestSharedCredentialsProvider(BaseEnvVar):
@pytest.mark.moto
@pytest.mark.asyncio
async def test_sharedcredentials_file_exists():
parser = mock.Mock()
parser.return_value = {
Expand All @@ -741,7 +721,6 @@ async def test_sharedcredentials_file_exists():


@pytest.mark.moto
@pytest.mark.asyncio
async def test_sharedcredentials_file_missing():
parser = mock.Mock()
parser.side_effect = botocore.exceptions.ConfigNotFound(path='foo')
Expand All @@ -755,7 +734,6 @@ async def test_sharedcredentials_file_missing():

# From class TestBotoProvider(BaseEnvVar):
@pytest.mark.moto
@pytest.mark.asyncio
async def test_botoprovider_file_exists():
parser = mock.Mock()
parser.return_value = {
Expand All @@ -775,7 +753,6 @@ async def test_botoprovider_file_exists():


@pytest.mark.moto
@pytest.mark.asyncio
async def test_botoprovider_file_missing():
parser = mock.Mock()
parser.side_effect = botocore.exceptions.ConfigNotFound(path='foo')
Expand All @@ -787,7 +764,6 @@ async def test_botoprovider_file_missing():

# From class TestOriginalEC2Provider(BaseEnvVar):
@pytest.mark.moto
@pytest.mark.asyncio
async def test_originalec2provider_file_exists():
envrion = {'AWS_CREDENTIAL_FILE': 'foo.cfg'}
parser = mock.Mock()
Expand All @@ -808,7 +784,6 @@ async def test_originalec2provider_file_exists():


@pytest.mark.moto
@pytest.mark.asyncio
async def test_originalec2provider_file_missing():
provider = credentials.AioOriginalEC2Provider(environ={})
creds = await provider.load()
Expand Down Expand Up @@ -855,7 +830,6 @@ def fake_set_config_variable(self, logical_name, value):


@pytest.mark.moto
@pytest.mark.asyncio
async def test_createcredentialresolver(mock_session):
session = mock_session()

Expand All @@ -864,7 +838,6 @@ async def test_createcredentialresolver(mock_session):


@pytest.mark.moto
@pytest.mark.asyncio
async def test_get_credentials(mock_session):
session = mock_session()

Expand Down Expand Up @@ -1099,7 +1072,6 @@ def assume_role_setup(base_assume_role_test_setup):


@pytest.mark.moto
@pytest.mark.asyncio
async def test_sso_credential_fetcher_can_fetch_credentials(
ssl_credential_fetcher_setup,
):
Expand Down Expand Up @@ -1142,7 +1114,6 @@ async def test_sso_credential_fetcher_can_fetch_credentials(


@pytest.mark.moto
@pytest.mark.asyncio
async def test_sso_cred_fetcher_raises_helpful_message_on_unauthorized_exception(
ssl_credential_fetcher_setup,
):
Expand Down Expand Up @@ -1247,7 +1218,6 @@ def _add_get_role_credentials_response(self):


@pytest.mark.moto
@pytest.mark.asyncio
async def test_load_sso_credentials_without_cache(sso_provider_setup):
self = sso_provider_setup
_add_get_role_credentials_response(self)
Expand All @@ -1260,7 +1230,6 @@ async def test_load_sso_credentials_without_cache(sso_provider_setup):


@pytest.mark.moto
@pytest.mark.asyncio
async def test_load_sso_credentials_with_cache(sso_provider_setup):
self = sso_provider_setup

Expand All @@ -1281,7 +1250,6 @@ async def test_load_sso_credentials_with_cache(sso_provider_setup):


@pytest.mark.moto
@pytest.mark.asyncio
async def test_load_sso_credentials_with_cache_expired(sso_provider_setup):
self = sso_provider_setup
cached_creds = {
Expand All @@ -1305,7 +1273,6 @@ async def test_load_sso_credentials_with_cache_expired(sso_provider_setup):


@pytest.mark.moto
@pytest.mark.asyncio
async def test_required_config_not_set(sso_provider_setup):
self = sso_provider_setup
del self.config['sso_start_url']
Expand Down
1 change: 0 additions & 1 deletion tests/boto_tests/test_signers.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@


@pytest.mark.moto
@pytest.mark.asyncio
async def test_signers_generate_db_auth_token(rds_client):
hostname = 'prod-instance.us-east-1.rds.amazonaws.com'
port = 3306
Expand Down
8 changes: 0 additions & 8 deletions tests/boto_tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ async def send(self, request):


@pytest.mark.moto
@pytest.mark.asyncio
async def test_idmsfetcher_disabled():
env = {'AWS_EC2_METADATA_DISABLED': 'true'}
fetcher = utils.AioIMDSFetcher(env=env)
Expand All @@ -81,7 +80,6 @@ async def test_idmsfetcher_disabled():


@pytest.mark.moto
@pytest.mark.asyncio
async def test_idmsfetcher_get_token_success():
session = fake_aiohttp_session(
('blah', 200),
Expand All @@ -95,7 +93,6 @@ async def test_idmsfetcher_get_token_success():


@pytest.mark.moto
@pytest.mark.asyncio
async def test_idmsfetcher_get_token_not_found():
session = fake_aiohttp_session(
('blah', 404),
Expand All @@ -109,7 +106,6 @@ async def test_idmsfetcher_get_token_not_found():


@pytest.mark.moto
@pytest.mark.asyncio
async def test_idmsfetcher_get_token_bad_request():
session = fake_aiohttp_session(
('blah', 400),
Expand All @@ -123,7 +119,6 @@ async def test_idmsfetcher_get_token_bad_request():


@pytest.mark.moto
@pytest.mark.asyncio
async def test_idmsfetcher_get_token_timeout():
session = fake_aiohttp_session(
[
Expand All @@ -138,7 +133,6 @@ async def test_idmsfetcher_get_token_timeout():


@pytest.mark.moto
@pytest.mark.asyncio
async def test_idmsfetcher_get_token_retry():
session = fake_aiohttp_session(
[
Expand All @@ -155,7 +149,6 @@ async def test_idmsfetcher_get_token_retry():


@pytest.mark.moto
@pytest.mark.asyncio
async def test_idmsfetcher_retry():
session = fake_aiohttp_session(
[
Expand Down Expand Up @@ -184,7 +177,6 @@ async def test_idmsfetcher_retry():


@pytest.mark.moto
@pytest.mark.asyncio
async def test_idmsfetcher_timeout():
session = fake_aiohttp_session(
[
Expand Down
Loading

0 comments on commit 872ccc3

Please sign in to comment.