def test_run_with_invalid_exclude_number(self, mock_actions): range_list = "12-15,^17" expected_result = "12,13,14,15" mock_ctx = mock.MagicMock() action = derive_params.ConvertRangeToNumberListAction(range_list) result = action.run(mock_ctx) self.assertEqual(result, expected_result)
def test_run_with_no_ranges(self): range_list = "24,25,26,27,60,65,66,67" expected_result = "24,25,26,27,60,65,66,67" mock_ctx = mock.MagicMock() action = derive_params.ConvertRangeToNumberListAction(range_list) result = action.run(mock_ctx) self.assertEqual(result, expected_result)
def test_run_with_empty_input(self, mock_actions): range_list = "" mock_ctx = mock.MagicMock() action = derive_params.ConvertRangeToNumberListAction(range_list) action.run(mock_ctx) msg = "Input param 'range_list' is blank." mock_actions.assert_called_once_with(error=msg)
def test_run_with_ranges_in_comma_delimited_list(self): range_list = ['24-27', '60', '65-67'] expected_result = "24,25,26,27,60,65,66,67" mock_ctx = mock.MagicMock() action = derive_params.ConvertRangeToNumberListAction(range_list) result = action.run(mock_ctx) self.assertEqual(result, expected_result)
def test_run_with_invalid_input(self, mock_actions): range_list = ",d" mock_ctx = mock.MagicMock() action = derive_params.ConvertRangeToNumberListAction(range_list) action.run(mock_ctx) msg = ("Invalid number in input param 'range_list': invalid " "literal for int() with base 10: ''") mock_actions.assert_called_once_with(error=msg)