Fix bug with WaitForArtifacts that has a side-effect that didn't matter before.

Async broke the assumption that WaitForArtifacts would only be called once.
Make the side-effect optional.

BUG=chromium:274824
TEST=Ran stage of deltas with async=True and is_synced etc + unittests.

Change-Id: I012385fe1cbeadffb7ae283051aad502576a7325
Reviewed-on: https://gerrit.chromium.org/gerrit/66149
Reviewed-by: Alex Miller <milleral@chromium.org>
Reviewed-by: Chris Sosa <sosa@chromium.org>
Tested-by: Chris Sosa <sosa@chromium.org>
diff --git a/autoupdate_unittest.py b/autoupdate_unittest.py
index 72d583e..9fe04b5 100755
--- a/autoupdate_unittest.py
+++ b/autoupdate_unittest.py
@@ -37,6 +37,7 @@
     self.mox.StubOutWithMock(common_util, 'GetFileSize')
     self.mox.StubOutWithMock(common_util, 'GetFileSha1')
     self.mox.StubOutWithMock(common_util, 'GetFileSha256')
+    self.mox.StubOutWithMock(common_util, 'IsInsideChroot')
     self.mox.StubOutWithMock(autoupdate_lib, 'GetUpdateResponse')
     self.mox.StubOutWithMock(autoupdate.Autoupdate, '_GetRemotePayloadAttrs')
     self.port = 8080
@@ -116,6 +117,7 @@
                              'GenerateUpdateImageWithCache')
     au_mock = self._DummyAutoupdateConstructor()
 
+    common_util.IsInsideChroot().AndReturn(True)
     self._xbuddy._GetArtifact(
         [''], self.test_board, lookup_only=True).AndReturn(
             (latest_label, constants.TEST_IMAGE_FILE))
@@ -161,6 +163,7 @@
       with open(update_image, 'w') as fh:
         fh.write('')
 
+    common_util.IsInsideChroot().AndReturn(True)
     au_mock.GenerateUpdateImageWithCache(static_forced_image,
         static_image_dir=static_forced_image_dir).WithSideEffects(
         mock_fn).AndReturn('cache')