-
Notifications
You must be signed in to change notification settings - Fork 26
/
test.py
30 lines (23 loc) · 846 Bytes
/
test.py
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
import unittest
import json
from handler import list_posts, get_post
class TestHandler(unittest.TestCase):
""" Tests handler methods """
def test_list_posts(self):
""" Tests list_posts """
res = list_posts(None, None)
self.assertEquals(200, res['statusCode'])
self.assertTrue(len(res['body']) > 0)
def test_get_post(self):
""" Tests get_post """
event = {}
event['pathParameters'] = {}
event['pathParameters']['id'] = "1"
res = get_post(event, None)
self.assertEquals(200, res['statusCode'])
post = json.loads(res['body'])
self.assertEquals(1, post['id'])
self.assertEquals("sunt aut facere repellat provident occaecati excepturi optio reprehenderit",
post['title'])
if __name__ == '__main__':
unittest.main()