-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlambda_functions_test.py
More file actions
40 lines (29 loc) · 1.13 KB
/
lambda_functions_test.py
File metadata and controls
40 lines (29 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/python
import unittest
import db
import lambda_functions
import logging
import os
class LambdaCommon(lambda_functions.LambdaCommon):
def createDb(self):
return db.DBMemory()
class TestLambdaFunctions(unittest.TestCase):
def testCommon(self):
obj = LambdaCommon()
def testPageBucket(self):
obj = LambdaCommon()
self.assertEqual("pagebucket",obj.getPageBucket())
os.environ["PAGE_BUCKET"] = "OVERRIDE_BUCKET"
self.assertEqual("OVERRIDE_BUCKET",obj.getPageBucket())
def testaddCorsHeaders(self):
resp = lambda_functions.addCorsHeaders({"statusCode":200,"body":"{}"})
self.assertEqual(200,resp["statusCode"])
self.assertEqual("{}",resp["body"])
self.assertTrue("Authorization" in resp["headers"]["Access-Control-Allow-Headers"].split(','))
self.assertTrue("Content-Type" in resp["headers"]["Access-Control-Allow-Headers"].split(','))
self.assertTrue("GET" in resp["headers"]["Access-Control-Allow-Methods"].split(','))
self.assertEqual("*",resp["headers"]["Access-Control-Allow-Origin"])
if __name__ == '__main__':
#FORMAT = "%(asctime)-15s %(message)s"
#logging.basicConfig(format=FORMAT)
unittest.main()