コード例 #1
0
    def ensure_clean_slate(self):
        lambda_function = LambdaFunction('test-function')
        if lambda_function.exists():
            lambda_function.delete()

        lambda_role = Role('lambdapool-role-test-function')
        if lambda_role.exists():
            lambda_role.delete()
コード例 #2
0
class TestRoleGeneric:
    @pytest.fixture(autouse=True)
    def setup_role(self):
        self.role = Role('test-role')
        self.role.create()

    def teardown_method(self):
        self.role.delete()

    def test_role_policy_attachment(self):
        policies = get_role_policies('test-role')

        assert len(policies) == 1
        assert policies[
            0].arn == 'arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole'

    def test_role_policy_detachment(self):
        self.role.detach_policies()

        policies = get_role_policies('test-role')

        assert len(policies) == 0

        self.role.attach_policies()

    def test_repr(self):
        assert repr(self.role) == 'Role test-role'
コード例 #3
0
    def test_role_delete(self):
        role = Role('test-role')
        role.delete()

        assert role.exists() == False
コード例 #4
0
 def test_role_create(self):
     role = Role('test-role')
     with pytest.raises(AWSError):
         role.create()
コード例 #5
0
 def test_role_exists(self):
     role = Role('test-role')
     assert role.exists() == True
コード例 #6
0
 def teardown_method(self):
     role = Role('test-role')
     if role.exists():
         role.delete()
コード例 #7
0
 def setup_role(self):
     role = Role('test-role')
     role.create()
コード例 #8
0
    def test_role_get_arn(self):
        role = Role('test-role')

        with pytest.raises(AWSError):
            role.get_arn()
コード例 #9
0
 def test_role_delete(self):
     role = Role('test-role')
     with pytest.raises(AWSError):
         role.delete()
コード例 #10
0
 def test_role_create(self):
     role = Role('test-role')
     role.create()
     assert role.get_role().name == 'test-role'
コード例 #11
0
 def setup_role(self):
     self.role = Role('test-role')
     self.role.create()
コード例 #12
0
    def test_role_get_arn(self):
        role = Role('test-role')

        assert role.get_arn() == get_role_arn('test-role')