Skip to content

Commit

Permalink
issue #114 - fix integration tests to not break during collection of …
Browse files Browse the repository at this point in the history
…other test sets
  • Loading branch information
jantman committed Feb 7, 2016
1 parent 6a8b7d8 commit 6cc0d3b
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions awslimitchecker/tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
import pytest
import os
import logging
import inspect
from awslimitchecker.utils import dict2cols
from awslimitchecker.limit import SOURCE_TA, SOURCE_API
from awslimitchecker.checker import AwsLimitChecker
Expand Down Expand Up @@ -179,15 +178,15 @@ def verify_usage(self, checker, creds, service_name, expect_usage):
@pytest.mark.integration
def DONOTtest_default_creds_all_services(self):
"""Test running alc with all services enabled"""
creds = self.normal_creds
creds = self.normal_creds()
checker = AwsLimitChecker(region=REGION)
yield "limits", self.verify_limits, checker, creds, None, True, True
yield "usage", self.verify_usage, checker, creds, None, True

@pytest.mark.integration
def test_default_creds_each_service(self):
"""test running one service at a time for all services"""
creds = self.normal_creds
creds = self.normal_creds()
checker = AwsLimitChecker(region=REGION)
for sname in _services:
eu = False
Expand All @@ -211,9 +210,9 @@ def test_default_creds_each_service(self):
@pytest.mark.integration
def test_sts(self):
"""test normal STS role"""
creds = self.sts_creds
creds = self.sts_creds()
checker = AwsLimitChecker(
account_id=os.environ['AWS_MASTER_ACCOUNT_ID'],
account_id=os.environ.get('AWS_MASTER_ACCOUNT_ID', None),
account_role='alc-integration-sts',
region=REGION,
)
Expand All @@ -224,12 +223,12 @@ def test_sts(self):
@pytest.mark.integration
def test_sts_external_id(self):
"""test STS role with external ID"""
creds = self.sts_creds
creds = self.sts_creds()
checker = AwsLimitChecker(
account_id=os.environ['AWS_MASTER_ACCOUNT_ID'],
account_id=os.environ.get('AWS_MASTER_ACCOUNT_ID', None),
account_role='alc-integration-sts',
region=REGION,
external_id=os.environ['AWS_EXTERNAL_ID'],
external_id=os.environ.get('AWS_EXTERNAL_ID', None),
)
yield "VPC limits", self.verify_limits, checker, creds, \
'VPC', True, False
Expand All @@ -238,9 +237,9 @@ def test_sts_external_id(self):
@pytest.mark.integration
def DONOTtest_sts_mfa(self):
"""test STS role with MFA"""
creds = self.sts_creds
creds = self.sts_creds()
checker = AwsLimitChecker(
account_id=os.environ['AWS_MASTER_ACCOUNT_ID'],
account_id=os.environ.get('AWS_MASTER_ACCOUNT_ID', None),
account_role='alc-integration-sts-mfa',
region=REGION,
external_id=args.external_id,
Expand All @@ -251,16 +250,14 @@ def DONOTtest_sts_mfa(self):
'VPC', True, False
yield "VPC usage", self.verify_usage, checker, creds, 'VPC', True

@property
def normal_creds(self):
return (
os.environ['AWS_MAIN_ACCESS_KEY_ID'],
os.environ['AWS_MAIN_SECRET_ACCESS_KEY']
os.environ.get('AWS_MAIN_ACCESS_KEY_ID', None),
os.environ.get('AWS_MAIN_SECRET_ACCESS_KEY', None)
)

@property
def sts_creds(self):
return (
os.environ['AWS_INTEGRATION_ACCESS_KEY_ID'],
os.environ['AWS_INTEGRATION_SECRET_KEY'],
os.environ.get('AWS_INTEGRATION_ACCESS_KEY_ID', None),
os.environ.get('AWS_INTEGRATION_SECRET_KEY', None)
)

0 comments on commit 6cc0d3b

Please sign in to comment.