TCase_posttest_index = 20 TCase_without_dups = {} with open('../../data/PVP2S_tests.csv', 'rb') as f: next(f) # header row1 not used next(f) # header row2 not used reader = csv.reader(f, delimiter=';') for row in reader: #(debug) print row[pk_index] + ' :: ' + str(row) TCase_without_dups[int(row[TCase_pk_index])] = row # create usecase INSERTs for k, row in sorted(TCase_without_dups.iteritems()): print TCase_template.format(k, row[6], repair_fmt(row[8]), row[9], row[TCase_fk_index], repair_fmt(row[10]), repair_fmt(row[13])) pass print "SELECT pg_catalog.setval('testmgr_testclass_id_seq', " + str(k + 1) + ", true);" # create TestClass INSERTs (all words from columns 18-20, which is SAML_Requests, PreTest, PostTest) TClass_without_dups = set() for k, row in sorted(TCase_without_dups.iteritems()): tclasses = row[TCase_samlrequ_index] if row[TCase_pretest_index]: tclasses += ', ' + row[TCase_pretest_index] if row[TCase_posttest_index]: tclasses += ', ' + row[TCase_posttest_index] tclasses = tclasses.replace(" ","") # create list of unique class names for n in tclasses.split(","):
import csv from repairfmt import repair_fmt leftonline = 'INSERT INTO requmgr_requirement (id, name, feature_id, operation_count) VALUES (' pk_index = 4 fk_index = 2 eliminate_dups = {} # TODO need to make uniquy by name, f_id with open('../../db/PVP2S_tests.csv', 'rb') as f: next(f) # header row1 not used next(f) # header row2 not used reader = csv.reader(f, delimiter=';') for row in reader: #print row[pk_index] + ' :: ' + str(row) eliminate_dups[int(row[pk_index])] = row for k, row in sorted(eliminate_dups.iteritems()): print leftonline + str(k) + ", '" + repair_fmt(row[5]) + "', " + row[fk_index] + ", 0);"
#Column indices from input data Oper_fk_index = 4 Oper_shortid_index = 6 Oper_pk_index = 7 Oper_operation_index = 15 Oper_samlrequ_index = 18 Oper_pretest_index = 19 Oper_posttest_index = 20 Oper_without_dups = {} with open('../../data/PVP2S_tests.csv', 'rb') as f: next(f) # header row1 not used next(f) # header row2 not used reader = csv.reader(f, delimiter=';') for row in reader: #(debug) print row[pk_index] + ' :: ' + str(row) Oper_without_dups[int(row[Oper_pk_index])] = row Oper_template = "UPDATE testmgr_usecase SET operation = '{}' WHERE id = {}; -- {}" # create Operation INSERTs for k, row in sorted(Oper_without_dups.iteritems()): if row[Oper_operation_index] != '': print Oper_template.format(row[Oper_operation_index], k, repair_fmt(row[16]))
TCase_pretest_index = 19 TCase_posttest_index = 20 TCase_without_dups = {} with open('../../data/PVP2S_tests.csv', 'rb') as f: next(f) # header row1 not used next(f) # header row2 not used reader = csv.reader(f, delimiter=';') for row in reader: #(debug) print row[pk_index] + ' :: ' + str(row) TCase_without_dups[int(row[TCase_pk_index])] = row # create usecase INSERTs for k, row in sorted(TCase_without_dups.iteritems()): print TCase_template.format(k, row[6], repair_fmt(row[8]), row[9], row[TCase_fk_index], repair_fmt(row[10]), repair_fmt(row[13])) pass print "SELECT pg_catalog.setval('testmgr_testclass_id_seq', " + str( k + 1) + ", true);" # create TestClass INSERTs (all words from columns 18-20, which is SAML_Requests, PreTest, PostTest) TClass_without_dups = set() for k, row in sorted(TCase_without_dups.iteritems()): tclasses = row[TCase_samlrequ_index] if row[TCase_pretest_index]: tclasses += ', ' + row[TCase_pretest_index] if row[TCase_posttest_index]: tclasses += ', ' + row[TCase_posttest_index] tclasses = tclasses.replace(" ", "") # create list of unique class names
import csv from repairfmt import repair_fmt leftonline = 'INSERT INTO requmgr_requirement (id, name, feature_id, operation_count) VALUES (' pk_index = 4 fk_index = 2 eliminate_dups = {} # TODO need to make uniquy by name, f_id with open('../../db/PVP2S_tests.csv', 'rb') as f: next(f) # header row1 not used next(f) # header row2 not used reader = csv.reader(f, delimiter=';') for row in reader: #print row[pk_index] + ' :: ' + str(row) eliminate_dups[int(row[pk_index])] = row for k, row in sorted(eliminate_dups.iteritems()): print leftonline + str(k) + ", '" + repair_fmt( row[5]) + "', " + row[fk_index] + ", 0);"