def setUp(self): """ auto init""" self.mapper = Mapper() self.mapfile = 'testmap.yaml' udb = UnittestDB() metadata = udb.load_from_file('starting_db.yaml') self.mapper.load_mapfile(self.mapfile) self.mapper.validate_map(metadata) self.assertEqual(12, len(self.mapper.dict))
def test_by_sql_file(self): """test by sql file""" udb = UnittestDB() metadata = udb.load_from_file('starting_db.yaml') connection = self.engine.connect() metadata.bind = connection metadata.drop_all() connection.close() udb = UnittestDB() metadata = udb.read_from_oracle('oracle.sql') # for table in metadata.sorted_tables: # print table.name # for col in table.columns: # print col metadata.bind = self.engine metadata.create_all() udb.fill_tables(metadata, 10) metadata.drop_all()
def test_fill(self): """test fill""" # if path.exists('unittest2.db'): # unlink('unittest2.db') udb = UnittestDB() metadata = udb.load_from_file('starting_db.yaml') # for table in metadata.sorted_tables: # print table.name # for col in table.columns: # print col connection = self.engine.connect() metadata.bind = connection metadata.drop_all() for table in metadata.sorted_tables: for col in table.columns: col.autoincrement = False metadata.create_all() udb.fill_tables(metadata, 10) connection.close()
MAPFILE = ARG[1] elif ARG[0] == "--find_key": COLUMN = ARG[1] elif ARG[0] == "--find_column": KEY = ARG[1] elif ARG[0] == "--list_key": LIST_KEY = True elif ARG[0] == "--list_column": LIST_COLUMN = True elif ARG[0] == "--validate_map": VMAP = ARG[1] else: print "Ignoring unrecognized argument: %s" % ARG if not VMAP: usage() sys.exit(1) MAPPER.load_mapfile(MAPFILE) if COLUMN: print MAPPER.get_key(COLUMN) elif KEY: print MAPPER.get_column(KEY) elif LIST_KEY: print MAPPER.list_key() elif LIST_COLUMN: print MAPPER.list_column() elif VMAP: if MAPPER.validate_map(UDB.load_from_file(VMAP)): print "Validate is OK"