def test_mark_object_as_blank(self, test_id, dynamo_test_environment): function_name = 'mark_object_as_blank' dynamo_driver = LeechDriver(table_name=blank_table_name) test_identifier_stem = test_id[0] test_id_value = test_id[1] dynamo_driver.mark_object_as_blank(identifier_stem=test_identifier_stem, id_value=test_id_value) self._assert_dynamo_call(function_name, test_id_value, test_identifier_stem, dynamo_test_environment, stage_name='extraction')
class Dentist: def __init__(self, metal_order, **kwargs): self._extraction_order = metal_order self._extraction_function_name = metal_order.extraction_function_name self._extraction_properties = metal_order.extraction_properties self._schema_entry = metal_order.schema_entry self._dynamo_driver = LeechDriver() self._transform_queue = kwargs.get( 'transform_queue', ForgeQueue.get_for_transform_queue(**kwargs)) @classmethod def extract_bulk(cls, metal_orders): results = [] for metal_order in metal_orders: dentist = cls(metal_order) result = dentist.extract() results.append(result) return results def extract(self): extracted_data = StageManager.run_extraction( self._extraction_function_name, self._extraction_properties) source_data = extracted_data['source'] if len(source_data) > 1: raise InvalidExtractionMultipleSourceException( self._extraction_function_name, self._extraction_order) if not source_data: return self._mark_object_blank() for entry in source_data: if not entry: return self._mark_object_blank() extracted_data['source'] = entry break transform_order = TransformObjectOrder( self._extraction_order.identifier_stem, self._extraction_order.id_value, extracted_data, self._schema_entry) self._transform_queue.add_order(transform_order) self._dynamo_driver.set_extraction_results( extracted_data, identifier_stem=self._extraction_order.identifier_stem, id_value=self._extraction_order.id_value) self._transform_queue.push_orders() def _mark_object_blank(self): return self._dynamo_driver.mark_object_as_blank( identifier_stem=self._extraction_order.identifier_stem, id_value=self._extraction_order.id_value)