def test_corrupted_db_duplicate_address_key(self, MockKeyStore, MockAddressBook): key_store = MockKeyStore() key_store.list_keys.return_value = ['old-name'] address_book = MockAddressBook() address_book.keys.return_value = ['old-name'] args = Mock() args.old = 'old-name' args.new = 'new-name' from pocketbook.commands.rename import run_rename with self.assertRaises(RuntimeError): run_rename(args)
def test_duplicate_destination_address_name(self, MockKeyStore, MockAddressBook): key_store = MockKeyStore() key_store.list_keys.return_value = [] address_book = MockAddressBook() address_book.keys.return_value = ['new-name'] args = Mock() args.old = 'old-name' args.new = 'new-name' from pocketbook.commands.rename import run_rename self.assertEqual(run_rename(args), 1)
def test_normal_address_rename(self, MockKeyStore, MockAddressBook): key_store = MockKeyStore() key_store.list_keys.return_value = [] address_book = MockAddressBook() address_book.keys.return_value = ['old-name'] args = Mock() args.old = 'old-name' args.new = 'new-name' from pocketbook.commands.rename import run_rename self.assertEqual(run_rename(args), 0) address_book.rename.assert_called_once_with('old-name', 'new-name')