def test_parse_time_raises_exception(self, parse_date_mock): input = "some time" parsed_result = None parse_date_mock.return_value = parsed_result with self.assertRaises(UserException) as ctx: LogsCommandContext._parse_time(input, "some prop") self.assertEqual(str(ctx.exception), "Unable to parse the time provided by 'some prop'")
def test_parse_time_raises_exception(self, parse_date_mock): input = "some time" parsed_result = None parse_date_mock.return_value = parsed_result with self.assertRaises(UserException) as ctx: LogsCommandContext._parse_time(input, "some prop") self.assertEquals(str(ctx.exception), "Unable to parse the time provided by 'some prop'")
def test_parse_time(self, to_utc_mock, parse_date_mock): input = "some time" parsed_result = "parsed" expected = "bar" parse_date_mock.return_value = parsed_result to_utc_mock.return_value = expected actual = LogsCommandContext._parse_time(input, "some prop") self.assertEquals(actual, expected) parse_date_mock.assert_called_with(input) to_utc_mock.assert_called_with(parsed_result)
def test_parse_time_empty_time(self): result = LogsCommandContext._parse_time(None, "some prop") self.assertIsNone(result)