def test_wireup(self): """ Verify that the command is wired up correctly. (sync) The API method indeed calls the appropiate command. """ with patch( 'iota.commands.core.remove_neighbors.RemoveNeighborsCommand.__call__', MagicMock(return_value=async_return( 'You found me!'))) as mocked_command: api = Iota(self.adapter) response = api.remove_neighbors('uris') self.assertTrue(mocked_command.called) self.assertEqual(response, 'You found me!')
import sys from iota import Iota if not sys.argv[1:]: print("Error: No nodes given as parameters") print("Use: removeAllNeighbors [Node Direction]") sys.exit(1) for node in sys.argv[1:]: api = Iota('http://'+node+':14265') neighbors = api.getNeighbors() uris = [] for v in neighbors.get("neighbors"): addr = v.get("address") protocol = v.get("connectionType") uris.append(protocol+"://"+addr) api.remove_neighbors(uris)