api: android.GetLatestBuild: re-support android_build_branch param
This adds back support for specifying which Android branch to look up.
The android_package param remains required.
BUG=b:259008604
TEST=run_tests
TEST=./api/contrib/call_scripts/android__get_latest_build
Change-Id: If045a4ec7e5248b45de43b219a36d111d36f7f0f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/4025568
Tested-by: Shao-Chuan Lee <shaochuan@chromium.org>
Auto-Submit: Shao-Chuan Lee <shaochuan@chromium.org>
Reviewed-by: Kazuhiro Inaba <kinaba@chromium.org>
Reviewed-by: Jack Neus <jackneus@google.com>
Commit-Queue: Jack Neus <jackneus@google.com>
diff --git a/api/controller/android_unittest.py b/api/controller/android_unittest.py
index 8c37306..3bb62ec 100644
--- a/api/controller/android_unittest.py
+++ b/api/controller/android_unittest.py
@@ -27,8 +27,10 @@
self._mock.return_value = ("7123456", {})
self._output_proto = android_pb2.GetLatestBuildResponse()
- def _GetRequest(self, android_package=None):
+ def _GetRequest(self, android_build_branch=None, android_package=None):
req = android_pb2.GetLatestBuildRequest()
+ if android_build_branch is not None:
+ req.android_build_branch = android_build_branch
if android_package is not None:
req.android_package = android_package
return req
@@ -48,18 +50,36 @@
self._mock.assert_not_called()
self.assertEqual(self._output_proto.android_version, "7123456")
- def testFailsIfPackageMissing(self):
- """Fails if android_package is missing."""
+ def testFailsIfBranchAndPackageMissing(self):
+ """Fails if both android_build_branch and android_package are missing."""
req = self._GetRequest()
with self.assertRaises(cros_build_lib.DieSystemExit):
android.GetLatestBuild(req, self._output_proto, self.api_config)
self._mock.assert_not_called()
- def testSuccess(self):
- """Test a successful call."""
+ def testFailsIfPackageMissing(self):
+ """Fails if android_package is missing."""
+ req = self._GetRequest(android_build_branch="android-branch")
+ with self.assertRaises(cros_build_lib.DieSystemExit):
+ android.GetLatestBuild(req, self._output_proto, self.api_config)
+ self._mock.assert_not_called()
+
+ def testPackageSpecified(self):
+ """Test calling with Android package specified."""
req = self._GetRequest(android_package="android-package")
android.GetLatestBuild(req, self._output_proto, self.api_config)
- self._mock.assert_called_once_with("android-package")
+ self.assertEqual(self._output_proto.android_version, "7123456")
+
+ def testBranchAndPackageSpecified(self):
+ """Test calling with both Android branch and package specified."""
+ req = self._GetRequest(
+ android_build_branch="android-branch",
+ android_package="android-package",
+ )
+ android.GetLatestBuild(req, self._output_proto, self.api_config)
+ self._mock.assert_called_once_with(
+ "android-package", build_branch="android-branch"
+ )
self.assertEqual(self._output_proto.android_version, "7123456")