def testPrepareBinhostUploadsNonGsUri(self): """PrepareBinhostUploads dies when URI does not point to GS.""" input_proto = binhost_pb2.PrepareDevInstallBinhostUploadsRequest() input_proto.chroot.path = self.chroot_path input_proto.sysroot.path = self.sysroot_path input_proto.uploads_dir = self.uploads_dir input_proto.uri = 'https://foo.bar' with self.assertRaises(ValueError): binhost.PrepareDevInstallBinhostUploads(input_proto, self.response, self.api_config)
def testValidateOnly(self): """Sanity check that a validate only call does not execute any logic.""" patch = self.PatchObject(binhost_service, 'ReadDevInstallFilesToCreatePackageIndex') input_proto = binhost_pb2.PrepareDevInstallBinhostUploadsRequest() input_proto.uri = 'gs://chromeos-prebuilt/target' input_proto.chroot.path = self.chroot_path input_proto.sysroot.path = self.sysroot_path input_proto.uploads_dir = self.uploads_dir binhost.PrepareDevInstallBinhostUploads(input_proto, self.response, self.validate_only_config) patch.assert_not_called()
def testMockCall(self): """Test that a mock call does not execute logic, returns mocked value.""" patch = self.PatchObject(binhost_service, 'ReadDevInstallFilesToCreatePackageIndex') input_proto = binhost_pb2.PrepareDevInstallBinhostUploadsRequest() input_proto.uri = 'gs://chromeos-prebuilt/target' input_proto.chroot.path = self.chroot_path input_proto.sysroot.path = self.sysroot_path input_proto.uploads_dir = self.uploads_dir binhost.PrepareDevInstallBinhostUploads(input_proto, self.response, self.mock_call_config) self.assertEqual(len(self.response.upload_targets), 3) self.assertEqual(self.response.upload_targets[2].path, 'Packages') patch.assert_not_called()
def testDevInstallerUpload(self): """Basic sanity test testing uploads of dev installer prebuilts.""" # self.RunStage() input_proto = binhost_pb2.PrepareDevInstallBinhostUploadsRequest() input_proto.uri = 'gs://chromeos-prebuilt/target' input_proto.chroot.path = self.chroot_path input_proto.sysroot.path = self.sysroot_path input_proto.uploads_dir = self.uploads_dir # Call method under test binhost.PrepareDevInstallBinhostUploads(input_proto, self.response, self.api_config) # Verify results expected_upload_targets = [ 'app-arch/zip-3.0-r3.tbz2', 'virtual/chromium-os-printing-1-r4.tbz2', 'virtual/python-enum34-1.tbz2', 'Packages' ] self.assertCountEqual([ut.path for ut in self.response.upload_targets], expected_upload_targets) # All of the upload_targets should also be in the uploads_directory for target in self.response.upload_targets: self.assertExists( os.path.join(input_proto.uploads_dir, target.path))