def test_extract_by_vin_not_existing(): extractor = Extractor() mapping = extractor.extract_by_vin('ae1013078659') assert mapping == {} extractor.close()
def test_extract_by_frame1(): extractor = Extractor() mapping = extractor.extract_by_framenum('BJ5W', '212063') mapping.pop('url') assert mapping == { 'date': '04.1998', 'engine': 'ガソリン', 'mark': 'MAZDA', 'model': 'Familia', 'many_url': False, } extractor.close()
def test_extract_by_frame2(): extractor = Extractor() mapping = extractor.extract_by_framenum('RF1', '1527314') mapping.pop('url') assert mapping == { 'engine': 'B20B', 'mark': 'HONDA', 'model': 'STEP WGN', 'option': 'Кондиционер с ручным управлением, Складывающиеся сидения, 3-спицевый руль', 'many_url': True, } extractor.close()
def test_extract_by_vin_nissan_teana(): extractor = Extractor() mapping = extractor.extract_by_vin('Z8NBCWJ32BS020772') mapping.pop('url') assert mapping == { 'date': '06.2011', 'engine': 'QR25DE', 'mark': 'NISSAN', 'model': 'TEANA', 'many_url': False, 'option': 'Привод:4WD' } extractor.close()
def test_extract_by_vin_mitsubishi_outlander(): extractor = Extractor() mapping = extractor.extract_by_vin('JMBXTGF3WDZ007092') mapping.pop('url') assert mapping == { 'date': '10.2012', 'engine': '2400 - INSTYLE(4WD/5P),CVT LHD', 'mark': 'MITSUBISHI', 'model': 'OUTLANDER', 'many_url': False, 'option': 'S05: SIZE-UP TIRE; AUDIO SYSTEM (5); LEATHER SEAT & ROOM TRIM; CARGO FLOOR BOX; PRIVACY GLASS; R/CONT MIRROR (WITH FOLDING CONTROL); TEL COMMUNICATION SYSTEM; TEL COMMUNICATION SYSTEM (B); ONE TOUCH START SYSTEM; ONE TOUCH START SYSTEM; RR HARNESS (OTHER OPTION)' } extractor.close()
class OrdersWorker: def __init__(self): self.name = 'orders_worker' self.extractor = Extractor(self.name) self.transformer = Transformer(self.name) self.loader = Loader(self.name) self.logger = Logger(self.name) def process(self): self.logger.info('Started') orders = self.extractor.extract_orders('orders') self.logger.info(f'Extracted orders: {orders.count()}') users = self.extractor.extract_users('users') data = self.transformer.merge_users_and_orders(users, orders) self.loader.load(data) self.logger.info(f'Written records: {len(data)}') self.logger.info('Finished')
def test_extract_by_vin_mitsubishi_montero(): extractor = Extractor() mapping = extractor.extract_by_vin('JA4MW51RX1J019722') mapping.pop('url') assert mapping == { 'date': '08.2000', 'engine': '3500/LONG WAGON<01M-> - LTD(NSS4),S5FA/T FED', 'mark': 'MITSUBISHI', 'model': 'MONTERO', 'many_url': True, 'option': "A01: RR HEATER + H/DUTY HEATER; DUAL AUTO A/C; HMSL + DOOR LOCK; AUTO A/C + OTHER OPTION; A/C + RR HEATER; A/C + RR HEATER; DUAL A/C + RR HEATER; DUAL A/C + RR HEATER; AUTO A/C + OTHER OPTION; RR HEATER + DUAL A/C; RR HEATER + DUAL COOLER", } extractor.close()
def __init__(self): self.name = 'orders_worker' self.extractor = Extractor(self.name) self.transformer = Transformer(self.name) self.loader = Loader(self.name) self.logger = Logger(self.name)