def test_should_throw_exception_when_node_is_not_up_and_running(self): mock_command_helper = mock() mock_string_attr = mock() mock_string_attr.succeeded=False lxc_node = LXCNode("123", mock_command_helper, "test_host_name") when(mock_command_helper).run_command_silently("ping -c1 123").thenReturn(mock_string_attr) with self.assertRaisesRegexp(Exception, "Node 123 is not running"): lxc_node.wait_for_ready(lambda : None, 5)
def test_should_not_throw_exception_when_node_is_up_and_running(self): mock_command_helper = mock() mock_string_attr = mock() mock_string_attr.succeeded=True lxc_node = LXCNode("123", mock_command_helper, "test_host_name") when(mock_command_helper).run_command_silently("ping -c1 123").thenReturn(mock_string_attr) lxc_node.wait_for_ready(lambda : None, 15)