switch to using sure for assertions
This commit is contained in:
parent
cb07d17e13
commit
dd243d72c2
@ -1,7 +1,7 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
import unittest
|
|
||||||
import json
|
import json
|
||||||
|
import sure
|
||||||
|
|
||||||
from moto.awslambda.policy import Policy
|
from moto.awslambda.policy import Policy
|
||||||
|
|
||||||
@ -12,39 +12,38 @@ class MockLambdaFunction:
|
|||||||
self.policy = None
|
self.policy = None
|
||||||
|
|
||||||
|
|
||||||
class TestPolicy(unittest.TestCase):
|
def test_policy():
|
||||||
def test_policy(self):
|
policy = Policy(MockLambdaFunction("arn"))
|
||||||
policy = Policy(MockLambdaFunction("arn"))
|
statement = {
|
||||||
statement = {
|
"StatementId": "statement0",
|
||||||
"StatementId": "statement0",
|
"Action": "lambda:InvokeFunction",
|
||||||
"Action": "lambda:InvokeFunction",
|
"FunctionName": "function_name",
|
||||||
"FunctionName": "function_name",
|
"Principal": "events.amazonaws.com",
|
||||||
"Principal": "events.amazonaws.com",
|
"SourceArn": "arn:aws:events:us-east-1:111111111111:rule/rule_name",
|
||||||
"SourceArn": "arn:aws:events:us-east-1:111111111111:rule/rule_name",
|
"SourceAccount": "111111111111",
|
||||||
"SourceAccount": "111111111111",
|
}
|
||||||
}
|
|
||||||
|
|
||||||
expected = {
|
expected = {
|
||||||
"Action": "lambda:InvokeFunction",
|
"Action": "lambda:InvokeFunction",
|
||||||
"FunctionName": "function_name",
|
"FunctionName": "function_name",
|
||||||
"Principal": {"Service": "events.amazonaws.com"},
|
"Principal": {"Service": "events.amazonaws.com"},
|
||||||
"Effect": "Allow",
|
"Effect": "Allow",
|
||||||
"Resource": "arn:$LATEST",
|
"Resource": "arn:$LATEST",
|
||||||
"Sid": "statement0",
|
"Sid": "statement0",
|
||||||
"Condition": {
|
"Condition": {
|
||||||
"ArnLike": {
|
"ArnLike": {
|
||||||
"AWS:SourceArn": "arn:aws:events:us-east-1:111111111111:rule/rule_name",
|
"AWS:SourceArn": "arn:aws:events:us-east-1:111111111111:rule/rule_name",
|
||||||
},
|
|
||||||
"StringEquals": {"AWS:SourceAccount": "111111111111"},
|
|
||||||
},
|
},
|
||||||
}
|
"StringEquals": {"AWS:SourceAccount": "111111111111"},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
policy.add_statement(json.dumps(statement))
|
policy.add_statement(json.dumps(statement))
|
||||||
self.assertDictEqual(expected, policy.statements[0])
|
expected.should.be.equal(policy.statements[0])
|
||||||
|
|
||||||
sid = statement.get("StatementId", None)
|
sid = statement.get("StatementId", None)
|
||||||
if sid == None:
|
if sid == None:
|
||||||
raise "TestCase.statement does not contain StatementId"
|
raise "TestCase.statement does not contain StatementId"
|
||||||
|
|
||||||
policy.del_statement(sid)
|
policy.del_statement(sid)
|
||||||
self.assertEqual([], policy.statements)
|
[].should.be.equal(policy.statements)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user