Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@placebo_session
def setUp(self, session):
self.ec2 = session.resource('ec2', region_name='eu-west-1')
self.ssm = session.client('ssm', region_name='eu-west-1')
@placebo_session
def test_no_outputs(self, session):
os.environ['SERVERLESS_STAGE'] = 'dev'
os.environ['SERVERLESS_PROJECT_NAME'] = 'no_outputs'
out = serverless_helpers.load_cfn_outputs(session)
assert out == {}
@placebo_session
def test_notfound(self, session):
os.environ['SERVERLESS_STAGE'] = 'dev'
os.environ['SERVERLESS_PROJECT_NAME'] = 'nonexistent'
out = serverless_helpers.load_cfn_outputs(session)
assert out == {}
@placebo_session
def setUp(self, session):
self.ec2 = session.resource('ec2', region_name='eu-west-1')
self.instance_id = 'i-0c32153096cd68a6d'
@placebo_session
def test_normal_outputs(self, session):
os.environ['SERVERLESS_STAGE'] = 'dev'
os.environ['SERVERLESS_PROJECT_NAME'] = 'mws'
out = serverless_helpers.load_cfn_outputs(session)
assert len(out) == 2
assert 'Description' in out['IamRoleArnLambda']
assert 'Value' in out['IamRoleArnLambda']
assert out['IamRoleArnLambda']['Value'].startswith('arn:aws:iam::123456789012')
assert out['DynamoTable']['Description'] == 'Name of DDB table'
assert os.getenv('SERVERLESS_CF_IamRoleArnLambda').startswith('arn:aws:iam::123456789012')
@placebo_session
def test_decorator(self, session):
# Tear it up..
PLACEBO_TEST_DIR = os.path.join(os.getcwd(), 'placebo_test_runs')
prefix = 'TestUtils.test_decorator'
record_dir = os.path.join(PLACEBO_TEST_DIR, prefix)
self.assertTrue(os.path.exists(record_dir))
# Tear it down..
shutil.rmtree(PLACEBO_TEST_DIR)
@placebo_session
def setUp(self, session):
self.ec2 = session.resource('ec2', region_name='eu-west-1')
self.instance_id = 'i-0c32153096cd68a6d'
self.config_data = {
'alias': 'test',
'name': 'SSM-test',
'profile': 'default',
'region': 'eu-west-1'
}
self.config = MagicMock()
self.config.configure_mock(**{
'get_host.return_value': self.config_data
})