def test_get_account_list_no_dir(self):
     """
     The keystore directory should be created if it doesn't exist, refs:
     https://github.com/AndreMiras/PyWallet/issues/133
     """
     # nominal case when the directory already exists
     with TemporaryDirectory() as keystore_dir:
         self.assertTrue(os.path.isdir(keystore_dir))
         account_utils = AccountUtils(keystore_dir)
         self.assertEqual(account_utils.get_account_list(), [])
     # when the directory doesn't exist it should also be created
     self.assertFalse(os.path.isdir(keystore_dir))
     account_utils = AccountUtils(keystore_dir)
     self.assertTrue(os.path.isdir(keystore_dir))
     self.assertEqual(account_utils.get_account_list(), [])
     shutil.rmtree(keystore_dir, ignore_errors=True)
 def test_delete_account(self):
     """
     Creates a new account and delete it.
     Then verify we can load the account from the backup/trash location.
     """
     password = PASSWORD
     account = self.account_utils.new_account(password, iterations=1)
     address = account.address
     self.assertEqual(len(self.account_utils.get_account_list()), 1)
     # deletes the account and verifies it's not loaded anymore
     self.account_utils.delete_account(account)
     self.assertEqual(len(self.account_utils.get_account_list()), 0)
     # even recreating the AccountUtils object
     self.account_utils = AccountUtils(self.keystore_dir)
     self.assertEqual(len(self.account_utils.get_account_list()), 0)
     # tries to reload it from the backup/trash location
     deleted_keystore_dir = AccountUtils.deleted_account_dir(
         self.keystore_dir)
     self.account_utils = AccountUtils(deleted_keystore_dir)
     self.assertEqual(len(self.account_utils.get_account_list()), 1)
     self.assertEqual(self.account_utils.get_account_list()[0].address,
                      address)
 def setUp(self):
     self.keystore_dir = mkdtemp()
     self.account_utils = AccountUtils(self.keystore_dir)