def custom_setup(self, tmp_path): super(TestCreateLocker, self).custom_setup(tmp_path) try: Locker.delete(self.locker_name, self.pw) except PhibesNotFoundError: pass self.setup_command()
def custom_setup(self, tmp_path): super(EmptyLocker, self).custom_setup(tmp_path) for name in self.lockers: try: Locker.delete(name, self.password) except PhibesNotFoundError: pass self.lockers = {} try: Locker.delete(self.locker_name, self.password) except PhibesNotFoundError: pass finally: self.my_locker = Locker.create( password=self.password, crypt_id=crypto.default_id, locker_name=self.locker_name ) # create a locker for each registered crypt instance for crypt_id in crypto.list_crypts(): # dedupe the names with random numbers wart = str(random.randint(1000, 9999)) # but make sure there isn't a freak collision while self.locker_name + str(wart) in self.lockers: wart = str(random.randint(1000, 9999)) locker_name = self.locker_name + wart self.lockers[locker_name] = Locker.create( password=self.password, crypt_id=crypt_id, locker_name=locker_name ) return
def custom_teardown(self, tmp_path): super(TestLocker, self).custom_teardown(tmp_path) try: Locker.delete( password=self.password, locker_name=self.locker_name ) except PhibesNotFoundError: pass
def custom_setup(self, tmp_path): super(TestLocker, self).custom_setup(tmp_path) try: if Locker.get( password=self.password, locker_name=self.locker_name ): Locker.delete( password=self.password, locker_name=self.locker_name ) except Exception: pass
def custom_setup(self, tmp_path): super(TestDeleteLocker, self).custom_setup(tmp_path) try: Locker.delete(password=self.pw, locker_name=self.locker_name) except PhibesNotFoundError: pass crypt_id = crypto.list_crypts()[0] Locker.create( password=self.pw, crypt_id=crypt_id, locker_name=self.locker_name ) self.setup_command()
def custom_setup(self, tmp_path): ConfigModel().storage = StoreType.Memory.name super(TestGetLocker, self).custom_setup(tmp_path) try: if Locker.get(password=self.password, locker_name=self.locker_name): Locker.delete(password=self.password, locker_name=self.locker_name) Locker.create(password=self.password, crypt_id=crypto.default_id, locker_name=self.locker_name) except Exception: pass
def test_good(self, tmp_path, datadir, setup_and_teardown): result = Locker.delete( password=self.password, locker_name=self.locker_name ) assert result is None with pytest.raises(PhibesNotFoundError): Locker.get( password=self.password, locker_name=self.locker_name )
def custom_teardown(self, tmp_path): super(TestCreateLocker, self).custom_teardown(tmp_path) try: Locker.delete(self.locker_name, self.pw) except PhibesNotFoundError: pass
def delete_locker(password: str, locker_name: str, **kwargs): return Locker.delete(password=password, locker_name=locker_name)