def test_write(self): path = os.path.join(self.electrum_path, 'default_wallet') storage = WalletStorage(path) data = 'testdata' storage.write(data) with open(path, 'r') as fd: assert fd.read() == data
def test_write_with_permission_error_fails(self): path = os.path.join(self.electrum_path, 'default_wallet') storage = WalletStorage(path) storage.write_attempts = 1 data = 'testdata' with patch('os.replace', new_callable=ReplaceWithPermissionErrorMock): with self.assertRaises(PermissionError): storage.write(data)
def test_write_with_permission_error_done(self): path = os.path.join(self.electrum_path, 'default_wallet') storage = WalletStorage(path) data = 'testdata' with patch('os.replace', new_callable=ReplaceWithPermissionErrorMock): storage.write(data) with open(path, 'r') as fd: assert fd.read() == data