XBuddy: Add support for obtaining Project SDK images.
* Adds a new alias 'project_sdk' mapping to a canonical image path.
* Adds support for pinned versions, including a 'VERSION' keyword in
aliases and API extensions for passing in a specific version. The
default is still 'latest'.
* Clarifies argument use in XBuddy._GetArtifact() docstring.
BUG=brillo:114
TEST=Unit tests.
TEST=Manual tests via cros flash --project-sdk.
Change-Id: I3e70ae7043d72906022e1d5203b69503be19f034
Reviewed-on: https://chromium-review.googlesource.com/251222
Trybot-Ready: Gilad Arnold <garnold@chromium.org>
Tested-by: Gilad Arnold <garnold@chromium.org>
Reviewed-by: Chris Sosa <sosa@chromium.org>
Reviewed-by: Don Garrett <dgarrett@chromium.org>
Commit-Queue: Gilad Arnold <garnold@chromium.org>
diff --git a/xbuddy_unittest.py b/xbuddy_unittest.py
index 0862ee6..074ebac 100755
--- a/xbuddy_unittest.py
+++ b/xbuddy_unittest.py
@@ -75,6 +75,16 @@
expected)
self.mox.VerifyAll()
+ def testLookupAlias(self):
+ """Tests _LookupAlias, including keyword substitution."""
+ alias = 'foobar'
+ path = 'remote/BOARD/VERSION/test'
+ self.mox.StubOutWithMock(self.mock_xb.config, 'get')
+ self.mock_xb.config.get(mox.IgnoreArg(), alias).AndReturn(path)
+ self.mox.ReplayAll()
+ self.assertEqual('remote/parrot/1.2.3/test',
+ self.mock_xb._LookupAlias(alias, 'parrot', '1.2.3'))
+
def testResolveVersionToBuildId_Official(self):
"""Check _ResolveVersionToBuildId recognizes aliases for official builds."""
board = 'b'
@@ -156,6 +166,42 @@
expected = ('ANY', 'parrot', 'latest', True)
self.assertEqual(self.mock_xb._InterpretPath(path=path), expected)
+ def testInterpretPathWithDefaults(self):
+ """Test path splitting with default board/version."""
+ path = ''
+ expected = ('ANY', 'parrot', 'latest', True)
+ self.assertEqual(expected, self.mock_xb._InterpretPath(
+ path=path, default_board='parrot'))
+
+ path = ''
+ expected = ('ANY', None, '1.2.3', True)
+ self.assertEqual(expected, self.mock_xb._InterpretPath(
+ path=path, default_version='1.2.3'))
+
+ path = ''
+ expected = ('ANY', 'parrot', '1.2.3', True)
+ self.assertEqual(expected, self.mock_xb._InterpretPath(
+ path=path, default_board='parrot', default_version='1.2.3'))
+
+ path = '1.2.3'
+ expected = ('ANY', None, '1.2.3', True)
+ self.assertEqual(expected, self.mock_xb._InterpretPath(
+ path=path, default_version='1.2.3'))
+
+ path = 'latest'
+ expected = ('ANY', None, 'latest', True)
+ self.assertEqual(expected, self.mock_xb._InterpretPath(
+ path=path, default_version='1.2.3'))
+
+ path = '1.2.3'
+ expected = ('ANY', 'parrot', '1.2.3', True)
+ self.assertEqual(expected, self.mock_xb._InterpretPath(
+ path=path, default_board='parrot', default_version='1.2.3'))
+
+ path = 'parrot'
+ expected = ('ANY', 'parrot', '1.2.3', True)
+ self.assertEqual(expected, self.mock_xb._InterpretPath(
+ path=path, default_version='1.2.3'))
def testTimestampsAndList(self):
"""Creation and listing of builds according to their timestamps."""