Build API: Add validate-only functionality.
Add the ability to request only validating the call arguments.
The validation-only call allow testing calls against branched
code, and more quickly verifying inputs than by running the
full endpoint.
This is only the core functionality for the validation.
BUG=chromium:987263
TEST=run_tests
Cq-Depend: chromium:1726253
Change-Id: I235443b0e7f29409d0229fabb9a22927c56c7ebf
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/1726252
Commit-Queue: Alex Klein <saklein@chromium.org>
Tested-by: Alex Klein <saklein@chromium.org>
Reviewed-by: David Burger <dburger@chromium.org>
Reviewed-by: Evan Hernandez <evanhernandez@chromium.org>
diff --git a/api/api_config.py b/api/api_config.py
new file mode 100644
index 0000000..117f69b
--- /dev/null
+++ b/api/api_config.py
@@ -0,0 +1,29 @@
+# -*- coding: utf-8 -*-
+# Copyright 2019 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""API config object."""
+
+from __future__ import print_function
+
+import collections
+
+
+ApiConfig = collections.namedtuple('ApiConfig', ['validate_only'])
+
+
+class ApiConfigMixin(object):
+ """Mixin to add an API Config factory properties.
+
+ This is meant to be used for tests to make these configs more uniform across
+ all of the tests since there's very little to change anyway.
+ """
+
+ @property
+ def api_config(self):
+ return ApiConfig(validate_only=False)
+
+ @property
+ def validate_only_config(self):
+ return ApiConfig(validate_only=True)