Fix the path handling for xbuddy paths missing parts.
Joy added a workaround for the empty '' problem by mapping '' ->
update_default rather than just treating '' as a subset of the larger
parsing problem. I've gone ahead and fixed this up to make more sense
while also allowing for more path expressions.
Before this CL, board was pretty much hard-coded to be the first
entry in any path. I've gone ahead and made this more intelligent
to only be the first entry if there is an unparsed non-image-type
remote/local name. This fixes issues like:
latest not mapping to local/BOARD/latest/ANY which it was always
meant to map to.
In addition, I've removed special casing of update_default. Now instead
update_default is just '' which gets parsed correctly when parsing the
path.
BUG=chromium:340313
TEST=Integration tests + Unit tests + much manual testing.
Change-Id: I38ed852b1ef4452ee3987e0d2a6163e7853e3ec0
Reviewed-on: https://chromium-review.googlesource.com/184697
Tested-by: Chris Sosa <sosa@chromium.org>
Reviewed-by: Yu-Ju Hong <yjhong@chromium.org>
Reviewed-by: Don Garrett <dgarrett@chromium.org>
Commit-Queue: Doug Anderson <dianders@chromium.org>
diff --git a/xbuddy_unittest.py b/xbuddy_unittest.py
index ea86072..0436589 100755
--- a/xbuddy_unittest.py
+++ b/xbuddy_unittest.py
@@ -112,7 +112,7 @@
self.assertEqual(self.mock_xb._InterpretPath(path=path), expected)
path = 'parrot/R27-2455.0.0'
- expected = ('test', 'parrot', 'R27-2455.0.0', True)
+ expected = ('ANY', 'parrot', 'R27-2455.0.0', True)
self.assertEqual(self.mock_xb._InterpretPath(path=path), expected)
path = 'remote/parrot/R27-2455.0.0'
@@ -120,18 +120,16 @@
self.assertEqual(self.mock_xb._InterpretPath(path=path), expected)
path = 'local/parrot/R27-2455.0.0'
- expected = ('test', 'parrot', 'R27-2455.0.0', True)
+ expected = ('ANY', 'parrot', 'R27-2455.0.0', True)
self.assertEqual(self.mock_xb._InterpretPath(path=path), expected)
path = ''
- self.assertRaises(xbuddy.XBuddyException,
- self.mock_xb._InterpretPath,
- path=path)
+ expected = ('ANY', None, 'latest', True)
+ self.assertEqual(self.mock_xb._InterpretPath(path=path), expected)
path = 'local'
- self.assertRaises(xbuddy.XBuddyException,
- self.mock_xb._InterpretPath,
- path=path)
+ expected = ('ANY', None, 'latest', True)
+ self.assertEqual(self.mock_xb._InterpretPath(path=path), expected)
path = 'local/parrot/latest/ANY'
expected = ('ANY', 'parrot', 'latest', True)