def __get_s3_objects_from(event) -> list: records = sqs_event.get_bodies(event) records = [ s3_event.get_single_s3_object(record) for record in records if not s3_event.is_s3_test_event(record) ] return records
def __get_s3_object_from(event) -> Optional[Tuple]: record = sqs_event.get_single_body(event) return s3_event.get_single_s3_object(record)
def __get_s3_object_from(event) -> Optional[Tuple]: record = sqs_event.get_single_body(event) if s3_event.is_s3_test_event(record): return None return s3_event.get_single_s3_object(record)
def test_single_s3_object_of_no_records_is_none(self): event = {} self.assertIsNone(s3_event.get_single_s3_object(event))
def test_single_s3_object_of_multi_records_event(self): event = {"Records": [{"s3": {"bucket": {"name": "bucket0"}, "object": {"key": "key0"}}}, {"s3": {"bucket": {"name": "bucket1"}, "object": {"key": "key1"}}} ]} with self.assertRaises(ValueError): s3_event.get_single_s3_object(event)
def test_single_s3_object_of_single_record_event(self): event = {"Records": [{"s3": {"bucket": {"name": "bucket0"}, "object": {"key": "key0"}}}]} self.assertEqual(("bucket0", "key0"), s3_event.get_single_s3_object(event))