Exemplo n.º 1
0
 def test_write_with_permission_error_fails(self):
     path = os.path.join(self.electrum_path, 'default_wallet')
     storage = WalletStorage(path)
     data = 'testdata'
     with patch('os.replace', new_callable=ReplaceWithPermissionErrorMock):
         with self.assertRaises(PermissionError):
             storage.write(data)
Exemplo n.º 2
0
 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
Exemplo n.º 3
0
 def test_write_with_permission_error_done(self):
     path = os.path.join(self.electrum_path, 'default_wallet')
     storage = WalletStorage(path)
     storage.write_attempts = 2
     data = 'testdata'
     with patch('os.replace', new_callable=ReplaceWithPermissionErrorMock):
         storage.write(data)
     with open(path, 'r') as fd:
         assert fd.read() == data
Exemplo n.º 4
0
    def test_write_dictionary_to_file(self):

        storage = WalletStorage(self.wallet_path)

        some_dict = {
            u"a": u"b",
            u"c": u"d",
            u"seed_version": FINAL_SEED_VERSION
        }

        for key, value in some_dict.items():
            storage.put(key, value)
        storage.write()

        with open(self.wallet_path, "r") as f:
            contents = f.read()
        self.assertEqual(some_dict, json.loads(contents))