bapi: PushImage should return instruction URIs
Also rejiggered the mock.patch objects from the unittests. Chromite's
MockTestCase is useful if we want a patch object to persist across
several test methods. But in this case we were reinstantiating the patch
object each time, because sometimes we need the patch, sometimes we
don't, and sometimes we need to assert that it was never called. So it
makes sense to limit the scope of the patch object by using the
@mock.patch.object decorator directly.
Similarly, removed the persistent self.response from the unittests,
because calling PushImage affects the response object, which makes it
difficult to make assertions about what's in the response.
BUG=b:216363284
TEST=./run_tests
Change-Id: Ib8940da17cf747c2927fceaa71945b977741489b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/3421574
Tested-by: Greg Edelston <gredelston@google.com>
Auto-Submit: Greg Edelston <gredelston@google.com>
Reviewed-by: Benjamin Shai <bshai@google.com>
Commit-Queue: Greg Edelston <gredelston@google.com>
diff --git a/api/controller/image.py b/api/controller/image.py
index a0609ac..4d41123 100644
--- a/api/controller/image.py
+++ b/api/controller/image.py
@@ -464,13 +464,16 @@
for channel in input_proto.channels
]
try:
- pushimage.PushImage(
+ channel_to_uris = pushimage.PushImage(
input_proto.gs_image_dir,
input_proto.sysroot.build_target.name,
dry_run=input_proto.dryrun,
sign_types=sign_types,
**kwargs)
- return controller.RETURN_CODE_SUCCESS
except Exception:
logging.error('PushImage failed: ', exc_info=True)
return controller.RETURN_CODE_COMPLETED_UNSUCCESSFULLY
+ for uris in channel_to_uris.values():
+ for uri in uris:
+ _output_proto.instructions.add().instructions_file_path = uri
+ return controller.RETURN_CODE_SUCCESS