def test_command_with_node0(self, instances, mocker): mock_input = mocker.patch('__builtin__.raw_input') mock_input.return_value.strip.return_value = 'node-0' real_command = subject.command() real_command.run_for('node-0') assert self.mock_node0.start_node.call_count == 0
def test_command_when_trying_to_start_node_on_node0_and_node_is_not_running_on_node0( self, instances, mocker): mock_input = mocker.patch('__builtin__.raw_input') mock_input.return_value.strip.return_value = 'node-0' self.mock_node0.node.descriptor = '' real_command = subject.command() real_command.run_for('node-0') self.mock_node0.start_node.assert_called_with()
def test_missing_node0(self, mocker, printing, command_instances): mock_input = mocker.patch('__builtin__.raw_input') mock_input.return_value.strip.return_value = 'other' del tnt_config.INSTANCES['node-0'] real_command = subject.command() real_command.run_for('other') assert self.mock_print.mock_calls == [ mocker.call('FAILED TO START other: no node-0 configured.'), ]
def test_command_when_not_trying_to_start_node_on_node0_and_node_is_running_on_node0(self, instances, mocker): mock_input = mocker.patch('__builtin__.raw_input') mock_input.return_value.strip.return_value = 'other' node0 = mocker.Mock() node0.descriptor = 'descriptor' tnt_config.INSTANCES['node-0'].node = node0 real_command = subject.command() real_command.run_for('other') self.mock_other_instance.start_node.assert_called_with('descriptor')
def test_command_when_trying_to_start_node_on_node0_and_node_is_not_running_on_node0(self, instances, mocker, printing): mock_input = mocker.patch('__builtin__.raw_input') mock_input.return_value.strip.return_value = 'node-0' node0 = mocker.Mock() node0.descriptor = '' tnt_config.INSTANCES['node-0'].node = node0 real_command = subject.command() real_command.run_for('node-0') assert self.mock_print.mock_calls == [] self.mock_node0.start_node.assert_called_with()
def test_command_failure_to_start(self, mocker, printing, command_instances): mock_input = mocker.patch('__builtin__.raw_input') mock_input.return_value.strip.return_value = 'other' node0 = mocker.Mock() node0.descriptor = '' tnt_config.INSTANCES['node-0'].node = node0 real_command = subject.command() real_command.run_for('other') assert self.mock_print.mock_calls == [ mocker.call('FAILED TO START other: try starting node-0 first.'), ]
def test_command_failure_to_start(self, mocker, printing, command_instances): mock_input = mocker.patch('__builtin__.raw_input') mock_input.return_value.strip.return_value = 'other' real_command = subject.command() real_command.run_for('other') assert self.mock_print.mock_calls == [ mocker.call('FAILED TO START other: did you forget about node-0?'), mocker.call( '\t(if you are trying to start node-0, this means it may already be running)' ) ]
def test_command_with_node0(self, instances, mocker, printing): mock_input = mocker.patch('__builtin__.raw_input') mock_input.return_value.strip.return_value = 'node-0' node0 = mocker.Mock() node0.descriptor = 'descriptor' tnt_config.INSTANCES['node-0'].node = node0 real_command = subject.command() real_command.run_for('node-0') assert self.mock_node0.start_node.call_count == 0 assert self.mock_print.mock_calls == [ mocker.call('It appears that node-0 is already running.'), ]
# Copyright (c) 2019, Substratum LLC (https://substratum.net) and/or its affiliates. All rights reserved. from command import SelectCommand, SetCommand import finish, info, init, nfo, update, kill, start, help, daisy, cluster, binaries_command COMMANDS = { init.name(): init.command(), # setup info.name(): info.command(), # always "all" update.name(): update.command(), start.name(): start.command(), 'tail': SelectCommand('tail', lambda instance: instance.tail(), "opens terminal(s) to tail -f MASQNode logs on"), 'subvert': SelectCommand('subvert', lambda instance: instance.subvert(), "subverts"), 'curl': SelectCommand('curl', lambda instance: instance.curl(), "prompts for URL and curl count, and executes on"), 'wget': SelectCommand('wget', lambda instance: instance.wget(), "wgets traffic on"), 'verify': SelectCommand('verify', lambda instance: instance.verify(), "checks whether traffic was routed for"), 'revert': SelectCommand('revert', lambda instance: instance.revert(), "reverts and cleans up traffic generation on"), 'inspect':
def test_command(self): real_command = subject.command() assert real_command.name == 'start' assert real_command.info == 'starts SubstratumNode on'