[autotest] Fix get_all_versions for AFE version maps.
The `get_all_versions()` method for AFE version mapping RPC objects
would do the wrong thing for Android and CrOS version maps; the
returned dictionaries would include mappings of either target.
This fixes the API implementation to do the right thing for all
cases.
BUG=chromium:827734
TEST=test against the upcoming `stable_version` command.
Change-Id: Ie8ffc0e74fc4314796f43fda782574255a5f6617
Reviewed-on: https://chromium-review.googlesource.com/993975
Commit-Ready: Richard Barnette <jrbarnette@chromium.org>
Tested-by: Richard Barnette <jrbarnette@chromium.org>
Reviewed-by: Ningning Xia <nxia@chromium.org>
diff --git a/server/frontend.py b/server/frontend.py
index 01142a5..25aeba3 100644
--- a/server/frontend.py
+++ b/server/frontend.py
@@ -200,18 +200,6 @@
when calling the `get_stable_version` RPC.
"""
- # DEFAULT_BOARD - The stable_version RPC API recognizes this special
- # name as a mapping to use when no specific mapping for a board is
- # present. This default mapping is only allowed for CrOS image
- # types; other image type subclasses exclude it.
- #
- # TODO(jrbarnette): This value is copied from
- # site_utils.stable_version_utils, because if we import that
- # module here, it breaks unit tests. Something about the Django
- # setup...
- DEFAULT_BOARD = 'DEFAULT'
-
-
def __init__(self, afe, android):
self._afe = afe
self._android = android
@@ -276,21 +264,21 @@
Abstract stable version mapping for full OS images of various types.
"""
+ def _version_is_valid(self, version):
+ return True
+
def get_all_versions(self):
- # TODO(jrbarnette): We exclude non-OS (i.e. firmware) version
- # mappings, but the returned dict doesn't distinguish CrOS
- # boards from Android boards; both will be present, and the
- # subclass can't distinguish them.
- #
- # Ultimately, the right fix is to move knowledge of image type
- # over to the RPC server side.
- #
versions = super(_OSVersionMap, self).get_all_versions()
for board in versions.keys():
- if '/' in board:
+ if ('/' in board
+ or not self._version_is_valid(versions[board])):
del versions[board]
return versions
+ def get_version(self, board):
+ version = super(_OSVersionMap, self).get_version(board)
+ return version if self._version_is_valid(version) else None
+
def format_cros_image_name(board, version):
"""
@@ -321,6 +309,9 @@
def __init__(self, afe):
super(_CrosVersionMap, self).__init__(afe, False)
+ def _version_is_valid(self, version):
+ return version is not None and '/' not in version
+
def get_image_name(self, board):
"""
Return the full image name of the stable version for `board`.
@@ -346,11 +337,8 @@
def __init__(self, afe):
super(_AndroidVersionMap, self).__init__(afe, True)
-
- def get_all_versions(self):
- versions = super(_AndroidVersionMap, self).get_all_versions()
- del versions[self.DEFAULT_BOARD]
- return versions
+ def _version_is_valid(self, version):
+ return version is not None and '/' in version
class _SuffixHackVersionMap(_StableVersionMap):