def test0(self): """ Case to create wallet successfully. """ # Given password = "******" file_path = os.path.join(TEST_DIR, "test_keystore.txt") try: # When wallet1, _ = Wallet.create_keystore_file_of_wallet( file_path, password) # Then prefix = wallet1.address[0:2] self.assertEqual(prefix, "hx") except FilePathIsWrong: self.assertFalse(True) except PasswordIsNotAcceptable: self.assertFalse(True) except NoPermissionToWriteFile: self.assertFalse(True) # Remove used file. os.remove(file_path)
def test4(self): """ Case to overwrite keystore file. """ # Given password = "******" file_path = os.path.join(TEST_DIR, "test_keystore.txt") # When wallet1, _ = Wallet.create_keystore_file_of_wallet(file_path, password) try: wallet2, _ = Wallet.create_keystore_file_of_wallet( file_path, password) # Then except FileExists: # Raise exception that file exists. self.assertTrue(True) # Remove used file. os.remove(file_path)
def test6(self): """ Case to save the file in the correct format. """ # Given password = "******" file_path = os.path.join(TEST_DIR, "test_keystore.txt") # When wallet1, _ = Wallet.create_keystore_file_of_wallet(file_path, password) # Then self.assertTrue(validate_key_store_file(file_path))
def test3(self): """ Case to enter a directory without permission to write file. """ # Given password = "******" file_path = os.path.join("/", "test_keystore.txt") try: # When wallet1, _ = Wallet.create_keystore_file_of_wallet( file_path, password) # Then except NoPermissionToWriteFile: self.assertTrue(True)
def test1(self): """ Case to enter a directory that does not exist. """ # Given password = "******" file_path = os.path.join(TEST_DIR, 'unknown', "test_keystore.txt") try: # When wallet1, _ = Wallet.create_keystore_file_of_wallet( file_path, password) # Then except FilePathIsWrong: self.assertTrue(True)
def test2(self): """ Case to enter a invalid password. """ # Given password = "******" file_path = os.path.join(TEST_DIR, "unknown_folder", "test_keystore.txt") try: # When wallet1, _ = Wallet.create_keystore_file_of_wallet( file_path, password) # Then except PasswordIsNotAcceptable: self.assertTrue(True)
def test1(self): """ Case to get an address successfully on creating a keystore file of wallet """ file_path = os.path.join(TEST_DIR, "test_keystore.txt") if os.path.isfile(file_path): os.remove(file_path) # Given password = "******" keystore_file_path = os.path.join(TEST_DIR, "test_keystore.txt") try: # When wallet, _ = Wallet.create_keystore_file_of_wallet(keystore_file_path, password) # Then prefix = wallet.get_address()[0:2] self.assertEqual(prefix, "hx") except FileExistsError: self.assertFalse(True) except FilePathIsWrong: self.assertFalse(True)