def test_parser_target(self):
     target_fname = 'test_data/test_spider_target.txt'
     parse_file_rpt = []
     for at in parser_target_for_spider(target_fname):
         print at
         result, err_code, rpt = at
         if rpt:
             parse_file_rpt.append(rpt)
         self.assertIsNotNone(result, rpt)
     print 'Rpt:'
     map(printer, parse_file_rpt)
        
     print  
     g_for_reduce = parser_target_for_spider(target_fname)
Esempio n. 2
0
def main():
    
    # Инициализируем паука
    path = 'App/Spider/targets_folder'
    kSpiderTargetsPath = tools.get_app_cfg_by_path(path)
    
    # Запускаем паука
    # Проверяем файл целей
    target_name = kSpiderTargetsPath+'iron_man_aa_target.txt'
    parse_file_rpt = []
    for at in parser_target_for_spider(target_name):
        result, err_code, rpt = at
        if rpt:
            parse_file_rpt.append(rpt)
            print at[0]
    if parse_file_rpt:
        # Есть замечания
        print 'Rpt Parse file:'
        map(printer, parse_file_rpt)
        if not run_other():
            return
        
    
    # Базовая проверка целостности задания
    all_right, rpt = check_availabel_resourses(target_name)
    if not all_right:
        print 'Rpt Checking pathes:'
        map(printer, rpt)
        if not run_other():
            return
            
    
    # TODO(zaqwes): сделать отчет по преобразованию
    rpt = Init()
    if rpt:
        print 'Rpt init convertors:'
        map(printer, rpt)
    rpt = base_spider(target_name)
    map(printer, rpt)
 def test_parser_target_bad_format(self):
     target_fname = 'test_data/test_spider_target_bad.txt'
     gen = parser_target_for_spider(target_fname)
     for at in gen:
         tmp, err_code, rpt = at
         self.assertEqual(err_code, 2, "Ошибка форматирование файла задания")
 def test_parser_target_bad_file(self):
     target_fname = 'test_spider_target.txt_f'
     gen = parser_target_for_spider(target_fname)
     for at in gen:
         self.assertIsNone(at[0], "File no exist")