def test_create_event(): import py_event_mocks r = py_event_mocks.create_event("aws:s3") assert "Records" in r r = py_event_mocks.create_event("aws:s3", {"foo": "bar"}) assert "Records" in r assert "foo" in r r = py_event_mocks.create_event("aws:s3", {"Records": [{"foo": "bar"}]}) assert "awsRegion" in r["Records"][0] assert "foo" in r["Records"][1]
def test_get(self): self.test_create() id_ = self.response['body'][8:44] event = create_event("aws:api-gateway-event") event['pathParameters'] = {'id': id_} response = App.get(self=self, event=event, context=None) self.assertEqual(response['statusCode'], 200)
def test_create(self): event = create_event("aws:api-gateway-event") event['body'] = '{"text":"Testing class with random message"}' self.response = App.create(self=self, event=event, context=None) self.assertEqual(self.response['statusCode'], 200) event[ 'body'] = '{"this will fail": "Testing class with random message"}' with self.assertRaises(Exception): self.response = App.create(self=self, event=event, context=None)
def test_update(self): self.test_create() id_ = self.response['body'][8:44] event = create_event("aws:api-gateway-event") event['pathParameters'] = {'id': id_} event['body'] = '{"text":"Changing message", "checked":"True"}' response = App.update(self=self, event=event, context=None) self.assertEqual(response['statusCode'], 200) event['body'] = '{"text":"Changing message", "this will fail":"True"}' with self.assertRaises(Exception): self.response = App.update(self=self, event=event, context=None) event[ 'body'] = '{"this will fail":"Changing message", "checked":"True"}' with self.assertRaises(Exception): self.response = App.update(self=self, event=event, context=None) event[ 'body'] = '{"this will fail":"Changing message", "this will fail":"True"}' with self.assertRaises(Exception): self.response = App.update(self=self, event=event, context=None)