Devserver pregenerate with xbuddy.

To prepare for an update request that expects the payload to already
have been pregenerated.

BUG=chromium:260491
TEST=Manual and unittest

Change-Id: I02002f13a466aa4991606f61c990a63ae2814cca
Reviewed-on: https://gerrit.chromium.org/gerrit/66157
Commit-Queue: Joy Chen <joychen@chromium.org>
Reviewed-by: Joy Chen <joychen@chromium.org>
Tested-by: Joy Chen <joychen@chromium.org>
diff --git a/autoupdate_unittest.py b/autoupdate_unittest.py
index 35de73c..2917fd2 100755
--- a/autoupdate_unittest.py
+++ b/autoupdate_unittest.py
@@ -183,6 +183,24 @@
     self.assertEqual(au_mock.HandleUpdatePing(test_data), self.payload)
     self.mox.VerifyAll()
 
+  def testHandleForcePregenerateXBuddy(self):
+    """Check pregenerating an xbuddy path.
+
+    A forced image that starts with 'xbuddy:' uses the following path to
+    obtain an update.
+    """
+    self.mox.StubOutWithMock(autoupdate.Autoupdate,
+                             'GetUpdateForLabel')
+    au_mock = self._DummyAutoupdateConstructor()
+    au_mock.forced_image = "xbuddy:b/v/a"
+
+    au_mock.GetUpdateForLabel(
+        autoupdate.FORCED_UPDATE, 'b/v/a').AndReturn('p')
+    self.mox.ReplayAll()
+
+    au_mock.PreGenerateUpdate()
+    self.mox.VerifyAll()
+
   def testChangeUrlPort(self):
     r = autoupdate._ChangeUrlPort('http://fuzzy:8080/static', 8085)
     self.assertEqual(r, 'http://fuzzy:8085/static')