def test_init_DB_auth(self, db): with pytest.raises(Exception): DB_auth(db.filepath, 0) dbs.initiate_db(db.filepath, 'auth', 1) dba = DB_auth(db.filepath, 1) assert len(dba.select_all('auth')) == 1
def pm(default_salt): db_path = Path(__file__).parent / 'test_db_pm.db' if not db_path.exists(): for t in ('auth', 'keys', 'password'): dbs.initiate_db(db_path, t) yield PM(default_salt, DB_auth(db_path), DB_keys(db_path), DB_password(db_path)) # remove db after testing db_path.unlink()
def test_init_DB_pwd(self, db): with pytest.raises(Exception): DB_password(db.filepath, 0) dbs.initiate_db(db.filepath, 'password', 1) dbp = DB_password(db.filepath, 1) assert len(dbp.select_all('apps')) == 1 assert len(dbp.select_all('emails')) == 1 assert len(dbp.select_all('data')) == 1
def test_init_DB_keys(self, db): with pytest.raises(Exception): DB_keys(db.filepath, 0) dbs.initiate_db(db.filepath, 'keys', 1) dbk = DB_keys(db.filepath, 1) assert len(dbk.select_all('app_keys')) == 1 assert len(dbk.select_all('email_keys')) == 1 assert len(dbk.select_all('data_keys')) == 1
def pm_temp(): db_path = Path(__file__).parent / 'test_db_temp.db' for t in ('auth', 'keys', 'password'): dbs.initiate_db(db_path, t, 1) yield PM(os.urandom(16), DB_auth(db_path), DB_keys(db_path), DB_password(db_path)) db_path.unlink()
def dbp(): db_path = Path(__file__).parent / 'test_db_pwd.db' if not db_path.exists(): dbs.initiate_db(db_path, 'password') yield DB_password(db_path) db_path.unlink()
def dbk(): db_path = Path(__file__).parent / 'test_db_keys.db' if not db_path.exists(): dbs.initiate_db(db_path, 'keys') yield DB_keys(db_path) db_path.unlink()
def dba(): db_path = Path(__file__).parent / 'test_db_auth.db' if not db_path.exists(): dbs.initiate_db(db_path, 'auth') yield DB_auth(db_path) db_path.unlink()
def test_reset_db_keys(self, dbk): # should this check if len(dbk.select_all(dbk.table_tuple[2])) > 100: dbk.filepath.unlink() dbs.initiate_db(dbk.filepath, 'keys') assert len(dbk.select_all(dbk.table_tuple[0])) == 10
def test_initiate_db_fail(self, db): with pytest.raises(Exception): dbs.initiate_db(db.filepath, 'not a type')
def test_initiate_password_db(self, db, num_of_dummies): dbp = dbs.initiate_db(db.filepath, 'password', num_of_dummies) assert len(dbp.select_all('apps')) == num_of_dummies assert len(dbp.select_all('emails')) == num_of_dummies assert len(dbp.select_all('data')) == num_of_dummies
def test_initiate_keys_db(self, db, num_of_dummies): dbk = dbs.initiate_db(db.filepath, 'keys', num_of_dummies) assert len(dbk.select_all('app_keys')) == num_of_dummies assert len(dbk.select_all('email_keys')) == num_of_dummies assert len(dbk.select_all('data_keys')) == num_of_dummies
def test_initiate_auth_db(self, db, num_of_dummies): dba = dbs.initiate_db(db.filepath, 'auth', num_of_dummies) assert len(dba.select_all('auth')) == num_of_dummies
def test_initiate_filepath(self): path = Path.cwd() / 'more_tests' / 'testing.db' dba = dbs.initiate_db(path, 'auth') assert len(dba.select_all('auth')) == 10 path.unlink() path.parent.rmdir()