Jose Diaz-Gonzalez

Fix code smells in simple.py

...@@ -21,6 +21,7 @@ def foobar(): ...@@ -21,6 +21,7 @@ def foobar():
21 21
22 22
23 def _get(event, context): 23 def _get(event, context):
24 + assert context
24 customer_id = event.get('id') 25 customer_id = event.get('id')
25 if customer_id is None: 26 if customer_id is None:
26 raise Exception('No id provided for GET operation') 27 raise Exception('No id provided for GET operation')
...@@ -32,6 +33,7 @@ def _get(event, context): ...@@ -32,6 +33,7 @@ def _get(event, context):
32 33
33 34
34 def _post(event, context): 35 def _post(event, context):
36 + assert context
35 item = event['json_body'] 37 item = event['json_body']
36 if item is None: 38 if item is None:
37 raise Exception('No json_body found in event') 39 raise Exception('No json_body found in event')
...@@ -41,6 +43,7 @@ def _post(event, context): ...@@ -41,6 +43,7 @@ def _post(event, context):
41 43
42 44
43 def _put(event, context): 45 def _put(event, context):
46 + assert context
44 data = _get(event, context) 47 data = _get(event, context)
45 id_ = data.get('id') 48 id_ = data.get('id')
46 data.update(event['json_body']) 49 data.update(event['json_body'])
...@@ -51,6 +54,7 @@ def _put(event, context): ...@@ -51,6 +54,7 @@ def _put(event, context):
51 54
52 55
53 def handler(event, context): 56 def handler(event, context):
57 + assert context
54 LOG.info(event) 58 LOG.info(event)
55 http_method = event.get('http_method') 59 http_method = event.get('http_method')
56 if not http_method: 60 if not http_method:
......
...@@ -5,5 +5,6 @@ LOG.setLevel(logging.DEBUG) ...@@ -5,5 +5,6 @@ LOG.setLevel(logging.DEBUG)
5 5
6 6
7 def handler(event, context): 7 def handler(event, context):
8 + assert context
8 LOG.debug(event) 9 LOG.debug(event)
9 return {'status': 'success'} 10 return {'status': 'success'}
......
...@@ -6,6 +6,7 @@ LOG.setLevel(logging.INFO) ...@@ -6,6 +6,7 @@ LOG.setLevel(logging.INFO)
6 6
7 7
8 def handler(event, context): 8 def handler(event, context):
9 + assert context
9 for record in event['Records']: 10 for record in event['Records']:
10 start_time = record['Sns']['Timestamp'] 11 start_time = record['Sns']['Timestamp']
11 LOG.info('start_time: %s', start_time) 12 LOG.info('start_time: %s', start_time)
......