def test_should_works_with_datetime_formatter(self): decorator = format_parameters({"param_a": format_datetime}) endpoint = mock.MagicMock() decorated_endpoint = decorator(endpoint) decorated_endpoint(param_a='2020-01-01T0:0:00+00:00') endpoint.assert_called_once_with( param_a=DateTime(2020, 1, 1, 0, tzinfo=Timezone('UTC')))
def test_should_work_with_limit(self): decorator = format_parameters({"limit": check_limit}) endpoint = mock.MagicMock() decorated_endpoint = decorator(endpoint) decorated_endpoint(limit=89) endpoint.assert_called_once_with(limit=89)
def test_should_propagate_exceptions(self): decorator = format_parameters({"param_a": format_datetime}) endpoint = mock.MagicMock() decorated_endpoint = decorator(endpoint) with self.assertRaises(BadRequest): decorated_endpoint(param_a='XXXXX')