def setUp(self): # global checksums self.checksum_signed_sha1 = None self.checksum_signed_sha256 = None self.checksum_upload_sha1 = None self.checksum_upload_sha256 = None # create new database self.db_fd, self.db_filename = tempfile.mkstemp() self.db_uri = 'sqlite:///' + self.db_filename # write out custom settings file self.cfg_fd, self.cfg_filename = tempfile.mkstemp() with open(self.cfg_filename, 'w') as cfgfile: cfgfile.write('\n'.join([ "SQLALCHEMY_DATABASE_URI = '%s'" % self.db_uri, "SQLALCHEMY_TRACK_MODIFICATIONS = False", "DEBUG = True", "CERTTOOL = 'flatpak run --command=certtool --filesystem=/tmp:ro org.freedesktop.fwupd'", "RESTORE_DIR = '/tmp'", "DOWNLOAD_DIR = '/tmp'", "SECRET_PASSWORD_SALT = 'lvfs%%%'", "SECRET_ADDR_SALT = 'addr%%%'", "SECRET_VENDOR_SALT = 'vendor%%%'", "MAIL_SUPPRESS_SEND = True", "WTF_CSRF_CHECK_DEFAULT = False", ])) # create instance import lvfs from lvfs import db from lvfs.dbutils import init_db self.app = lvfs.app.test_client() lvfs.app.config.from_pyfile(self.cfg_filename) with lvfs.app.app_context(): init_db(db) # ensure the plugins settings are set up self.login() self.app.get('/lvfs/settings/create') self.app.get('/lvfs/agreements/create') self.app.get('/lvfs/agreements/1/accept') rv = self.app.post('/lvfs/settings/modify', data=dict( clamav_enable='disabled', virustotal_enable='disabled', uefi_extract_size_min='0', ), follow_redirects=True) assert b'Updated settings' in rv.data, rv.data self.logout()
def initdb_command(): init_db(db)