def add_testsuite(sourcedir, config_file): norm_sourcedir = os.path.normpath(sourcedir) norm_config_file = os.path.normpath(config_file) print "\nProcessing {0} (config = {1})".format(norm_sourcedir, norm_config_file) old_testsuite = models.TestSuite.objects.get_most_recent_testsuite() testsuite = import_testsuite.create_testsuite() yaml_categories = yaml.load(open(norm_config_file).read())['Categories'] for cat in yaml_categories: new_category = import_testsuite.add_category('1', cat['Name'], None, testsuite, None) for epub in cat['Files']: fullpath = os.path.join(norm_sourcedir, epub) if os.path.isdir(fullpath): # this will add a new testsuite epubparser = epub_parser.EpubParser() epubparser.parse(fullpath, new_category, testsuite, cat['CategoryDisplayDepthLimit']) else: print "Not a directory: {0}".format(fullpath) num_tests = models.Test.objects.filter(testsuite=testsuite).count() print "This testsuite contains {0} tests".format(num_tests) import_testsuite.migrate_data(old_testsuite) print "Done importing testsuite."
def add_testsuite(sourcedir, config_file): norm_sourcedir = os.path.normpath(sourcedir) norm_config_file = os.path.normpath(config_file) print "\nProcessing {0} (config = {1})".format(norm_sourcedir, norm_config_file) old_testsuite = models.TestSuite.objects.get_most_recent_testsuite() testsuite = import_testsuite.create_testsuite() yaml_categories = yaml.load(open(norm_config_file).read())['Categories'] for cat in yaml_categories: new_category = import_testsuite.add_category('1', cat['Name'], None, testsuite, None) for epub in cat['Files']: fullpath = os.path.join(norm_sourcedir, epub) if os.path.isdir(fullpath): # this will add a new testsuite epubparser = epub_parser.EpubParser() epubparser.parse(fullpath, new_category, testsuite, cat['CategoryDisplayDepthLimit']) else: print "Not a directory: {0}".format(fullpath) num_tests = models.Test.objects.filter(testsuite = testsuite).count() print "This testsuite contains {0} tests".format(num_tests) import_testsuite.migrate_data(old_testsuite) print "Done importing testsuite."
def add_testsuite(config_section, sourcedir): yaml_categories = config_section['Categories'] testsuite_type = common.TESTSUITE_TYPE_DEFAULT if config_section['Type'] == "Accessibility": #TODO formalize this enum testsuite_type = common.TESTSUITE_TYPE_ACCESSIBILITY old_testsuite = models.TestSuite.objects.get_most_recent_testsuite_of_type(testsuite_type) testsuite = import_testsuite.create_testsuite(testsuite_type) epub_id_checker = epub_id_check.EpubIdCheck() epub_id_checker.process_epubs(sourcedir) for cat in yaml_categories: new_category = import_testsuite.add_category('1', cat['Name'], "", None, testsuite, None) for epubid in cat['EpubIds']: filename = epub_id_checker.get_filename_for_id(epubid) epubparser = epub_parser.EpubParser() epubparser.parse(filename, new_category, testsuite, cat['CategoryDisplayDepthLimit']) num_tests = models.Test.objects.filter(testsuite = testsuite).count() print "This testsuite contains {0} tests".format(num_tests) if old_testsuite != None: import_testsuite.migrate_data(old_testsuite) else: print "Nothing to migrate" print "Done importing testsuite."