Don't attempt connections at the module level!

This commit is contained in:
Pedro Algarvio 2017-04-12 12:34:14 +01:00
parent c1a6e6a214
commit 4062bd9fd9
No known key found for this signature in database
GPG key ID: BB36BF6584A298FF
3 changed files with 17 additions and 36 deletions

View file

@ -11,30 +11,25 @@ from tests.support.case import ModuleCase
from tests.support.unit import skipIf
# Import 3rd-party libs
NO_BOTO_MODULE = True
BOTO_NOT_CONFIGURED = True
try:
import boto
NO_BOTO_MODULE = False
try:
boto.connect_iam()
BOTO_NOT_CONFIGURED = False
except boto.exception.NoAuthHandlerFound:
pass
except ImportError:
pass
NO_BOTO_MODULE = True
@skipIf(
NO_BOTO_MODULE,
'Please install the boto library before running boto integration tests.'
)
@skipIf(
BOTO_NOT_CONFIGURED,
'Please setup boto AWS credentials before running boto integration tests.'
)
class BotoIAMTest(ModuleCase):
def setUp(self):
try:
boto.connect_iam()
except boto.exception.NoAuthHandlerFound:
self.skipTest('Please setup boto AWS credentials before running boto integration tests.')
def test_get_account_id(self):
ret = self.run_function('boto_iam.get_account_id')
# The AWS account ID is a 12-digit number.

View file

@ -12,31 +12,24 @@ from tests.support.case import ModuleCase
from tests.support.unit import skipIf
# Import 3rd-party libs
NO_BOTO_MODULE = True
BOTO_NOT_CONFIGURED = True
try:
import boto
NO_BOTO_MODULE = False
try:
boto.connect_iam()
BOTO_NOT_CONFIGURED = False
except boto.exception.NoAuthHandlerFound:
pass
except ImportError:
pass
NO_BOTO_MODULE = True
@skipIf(
NO_BOTO_MODULE,
'Please install the boto library before running boto integration tests.'
)
@skipIf(
BOTO_NOT_CONFIGURED,
'Please setup boto AWS credentials before running boto integration tests.'
)
class BotoSNSTest(ModuleCase):
def setUp(self):
try:
boto.connect_iam()
except boto.exception.NoAuthHandlerFound:
self.skipTest('Please setup boto AWS credentials before running boto integration tests.')
# The name of the topic you want to create.
# Constraints: Topic names must be made up of only uppercase and
# lowercase ASCII letters, numbers, underscores, and hyphens,

View file

@ -13,31 +13,24 @@ from tests.support.unit import skipIf
from tests.support.mixins import SaltReturnAssertsMixin
# Import 3rd-party libs
NO_BOTO_MODULE = True
BOTO_NOT_CONFIGURED = True
try:
import boto
NO_BOTO_MODULE = False
try:
boto.connect_iam()
BOTO_NOT_CONFIGURED = False
except boto.exception.NoAuthHandlerFound:
pass
except ImportError:
pass
NO_BOTO_MODULE = True
@skipIf(
NO_BOTO_MODULE,
'Please install the boto library before running boto integration tests.'
)
@skipIf(
BOTO_NOT_CONFIGURED,
'Please setup boto AWS credentials before running boto integration tests.'
)
class BotoSNSTest(ModuleCase, SaltReturnAssertsMixin):
def setUp(self):
try:
boto.connect_iam()
except boto.exception.NoAuthHandlerFound:
self.skipTest('Please setup boto AWS credentials before running boto integration tests.')
# The name of the topic you want to create.
# Constraints: Topic names must be made up of only uppercase and
# lowercase ASCII letters, numbers, underscores, and hyphens,