def _setup_models(self): """Create all models in the test database.""" # Since we are using a sqlite database in memory (at least that's what the default in # test.ini is), we need to create all the tables necessary. So let's import all the models # and create all the tables. import_all_models() meta.metadata.create_all(bind=meta.engine)
def setup_config(command, filename, section, vars): """ Run when debexpo is being set up, when ``paster setup-app`` is executed and shouldn't be called directly. ``command`` Pointer to the setup function. ``filename`` File used for configuration. E.g. `development.ini`. ``section`` Section in the config file; usually `app:main`. ``vars`` Extra variables passed to the setup. """ conf = appconfig("config:" + filename) if not pylons.test.pylonsapp: config = load_environment(conf.global_conf, conf.local_conf) else: config = pylons.test.pylonsapp.config log.info("Creating database tables") import_all_models() meta.metadata.create_all(bind=meta.engine) log.info("Successfully setup database tables") if not os.path.isdir(config["debexpo.upload.incoming"]): log.info("Creating incoming directory") os.mkdir(config["debexpo.upload.incoming"]) else: log.info("Incoming directory already exists") if not os.path.isdir(config["debexpo.repository"]): log.info("Creating repository directory") os.mkdir(config["debexpo.repository"]) else: log.info("Repository directory already exists") log.info("Making sure all ISO countries are in the database") debexpo.model.user_countries.create_iso_countries() log.info("Making sure all tags do exist") debexpo.model.sponsor_metrics.create_tags() log.info("Import data store pre-existing data") debexpo.model.data_store.fill_data_store()
def setup_config(command, filename, section, vars): """ Run when debexpo is being set up, when ``paster setup-app`` is executed and shouldn't be called directly. ``command`` Pointer to the setup function. ``filename`` File used for configuration. E.g. `development.ini`. ``section`` Section in the config file; usually `app:main`. ``vars`` Extra variables passed to the setup. """ conf = appconfig('config:' + filename) if not pylons.test.pylonsapp: config = load_environment(conf.global_conf, conf.local_conf) else: config = pylons.test.pylonsapp.config log.info('Creating database tables') import_all_models() meta.metadata.create_all(bind=meta.engine) log.info('Successfully setup database tables') if not os.path.isdir(config['debexpo.upload.incoming']): log.info('Creating incoming directory') os.mkdir(config['debexpo.upload.incoming']) else: log.info('Incoming directory already exists') if not os.path.isdir(config['debexpo.repository']): log.info('Creating repository directory') os.mkdir(config['debexpo.repository']) else: log.info('Repository directory already exists') log.info('Making sure all ISO countries are in the database') debexpo.model.user_countries.create_iso_countries() log.info('Making sure all tags do exist') debexpo.model.sponsor_metrics.create_tags() log.info('Import data store pre-existing data') debexpo.model.data_store.fill_data_store()
def __init__(self, *args, **kwargs): """ Sets up database with data to provide a database to test. """ TestController.__init__(self, *args, **kwargs) # Since we are using a sqlite database in memory (at least that's what the default in # test.ini is), we need to create all the tables necessary. So let's import all the models # and create all the tables. import_all_models() meta.metadata.create_all(bind=meta.engine) # Create a test user and save it. user = User(name='Test user', email='*****@*****.**', password=md5.new('password').hexdigest(), lastlogin=datetime.now()) meta.session.save(user) meta.session.commit() # Keep this so tests don't have to constantly create it. self.emailpassword = base64.encodestring('[email protected]:password')[:-1]
def setup_config(command, filename, section, vars): """ Run when debexpo is being set up, when ``paster setup-app`` is executed and shouldn't be called directly. ``command`` Pointer to the setup function. ``filename`` File used for configuration. E.g. `development.ini`. ``section`` Section in the config file; usually `app:main`. ``vars`` Extra variables passed to the setup. """ conf = appconfig('config:' + filename) load_environment(conf.global_conf, conf.local_conf) log.info('Creating database tables') import_all_models() meta.metadata.create_all(bind=meta.engine) log.info('Successfully setup database tables') if not os.path.isdir(config['debexpo.upload.incoming']): log.info('Creating incoming directory') os.mkdir(config['debexpo.upload.incoming']) else: log.info('Incoming directory already exists') if not os.path.isdir(config['debexpo.repository']): log.info('Creating repository directory') os.mkdir(config['debexpo.repository']) else: log.info('Repository directory already exists')
def __init__(self, *args, **kwargs): """ Sets up database with data to provide a database to test. """ TestController.__init__(self, *args, **kwargs) # Since we are using a sqlite database in memory (at least that's what the default in # test.ini is), we need to create all the tables necessary. So let's import all the models # and create all the tables. import_all_models() meta.metadata.create_all(bind=meta.engine) # Create a test user and save it. user = User(name='Test user', email='*****@*****.**', password=md5.new('password').hexdigest(), lastlogin=datetime.now()) meta.session.save(user) meta.session.commit() # Keep this so tests don't have to constantly create it. self.emailpassword = base64.encodestring( '[email protected]:password')[:-1]