def testMain(self):
    """Test that the main function works."""
    options = mock.MagicMock()
    old_binhost = 'http://prebuilt/1'
    options.previous_binhost_url = [old_binhost]
    options.board = 'x86-foo'
    options.profile = None
    target = prebuilt.BuildTarget(options.board, options.profile)
    options.build_path = '/trunk'
    options.dryrun = False
    options.private = True
    options.packages = []
    options.sync_host = True
    options.git_sync = True
    options.upload_board_tarball = True
    options.prepackaged_tarball = None
    options.toolchains_overlay_tarballs = []
    options.toolchains_overlay_upload_path = ''
    options.toolchain_tarballs = []
    options.toolchain_upload_path = ''
    options.upload = 'gs://upload/'
    options.binhost_base_url = options.upload
    options.prepend_version = True
    options.set_version = None
    options.skip_upload = False
    options.filters = True
    options.key = 'PORTAGE_BINHOST'
    options.binhost_conf_dir = None
    options.sync_binhost_conf = True
    options.slave_targets = [prebuilt.BuildTarget('x86-bar', 'aura')]
    self.PatchObject(prebuilt, 'ParseOptions',
                     return_value=tuple([options, target]))
    self.PatchObject(binpkg, 'GrabRemotePackageIndex', return_value=True)
    init_mock = self.PatchObject(prebuilt.PrebuiltUploader, '__init__',
                                 return_value=None)
    expected_gs_acl_path = os.path.join('/fake_path',
                                        prebuilt._GOOGLESTORAGE_GSUTIL_FILE)
    self.PatchObject(portage_util, 'FindOverlayFile',
                     return_value=expected_gs_acl_path)
    host_mock = self.PatchObject(
        prebuilt.PrebuiltUploader, 'SyncHostPrebuilts', return_value=None)
    board_mock = self.PatchObject(
        prebuilt.PrebuiltUploader, 'SyncBoardPrebuilts', return_value=None)

    prebuilt.main([])

    init_mock.assert_called_once_with(options.upload, expected_gs_acl_path,
                                      options.upload, mock.ANY,
                                      options.build_path, options.packages,
                                      False, None, False,
                                      target, options.slave_targets,
                                      mock.ANY)
    board_mock.assert_called_once_with(
        options.key, options.git_sync,
        options.sync_binhost_conf, options.upload_board_tarball, None,
        [], '', [], '')
    host_mock.assert_called_once_with(
        options.key, options.git_sync, options.sync_binhost_conf)
 def testMain(self):
   """Test that the main function works."""
   options = mox.MockObject(object)
   old_binhost = 'http://prebuilt/1'
   options.previous_binhost_url = [old_binhost]
   options.board = 'x86-foo'
   options.profile = None
   target = prebuilt.BuildTarget(options.board, options.profile)
   options.build_path = '/trunk'
   options.dryrun = False
   options.private = True
   options.packages = []
   options.sync_host = True
   options.git_sync = True
   options.upload_board_tarball = True
   options.prepackaged_tarball = None
   options.toolchain_tarballs = []
   options.toolchain_upload_path = ''
   options.upload = 'gs://upload/'
   options.binhost_base_url = options.upload
   options.prepend_version = True
   options.set_version = None
   options.skip_upload = False
   options.filters = True
   options.key = 'PORTAGE_BINHOST'
   options.binhost_conf_dir = 'foo'
   options.sync_binhost_conf = True
   options.slave_targets = [prebuilt.BuildTarget('x86-bar', 'aura')]
   self.mox.StubOutWithMock(prebuilt, 'ParseOptions')
   prebuilt.ParseOptions([]).AndReturn(tuple([options, target]))
   self.mox.StubOutWithMock(binpkg, 'GrabRemotePackageIndex')
   binpkg.GrabRemotePackageIndex(old_binhost).AndReturn(True)
   self.mox.StubOutWithMock(prebuilt.PrebuiltUploader, '__init__')
   self.mox.StubOutWithMock(prebuilt, 'GetBoardOverlay')
   fake_overlay_path = '/fake_path'
   prebuilt.GetBoardOverlay(
       options.build_path, options.board).AndReturn(fake_overlay_path)
   expected_gs_acl_path = os.path.join(fake_overlay_path,
                                       prebuilt._GOOGLESTORAGE_ACL_FILE)
   prebuilt.PrebuiltUploader.__init__(options.upload, expected_gs_acl_path,
                                      options.upload, mox.IgnoreArg(),
                                      options.build_path, options.packages,
                                      False, options.binhost_conf_dir, False,
                                      target, options.slave_targets,
                                      mox.IgnoreArg())
   self.mox.StubOutWithMock(prebuilt.PrebuiltUploader, 'SyncHostPrebuilts')
   prebuilt.PrebuiltUploader.SyncHostPrebuilts(
       options.key, options.git_sync, options.sync_binhost_conf)
   self.mox.StubOutWithMock(prebuilt.PrebuiltUploader, 'SyncBoardPrebuilts')
   prebuilt.PrebuiltUploader.SyncBoardPrebuilts(
       options.key, options.git_sync,
       options.sync_binhost_conf, options.upload_board_tarball, None, [], '')
   self.mox.ReplayAll()
   prebuilt.main([])
 def testMain(self):
   """Test that the main function works."""
   options = mox.MockObject(object)
   old_binhost = 'http://prebuilt/1'
   options.previous_binhost_url = [old_binhost]
   options.board = 'x86-foo'
   options.profile = None
   target = prebuilt.BuildTarget(options.board, options.profile)
   options.build_path = '/trunk'
   options.debug = False
   options.private = True
   options.packages = []
   options.sync_host = True
   options.git_sync = True
   options.upload_board_tarball = True
   options.prepackaged_tarball = None
   options.toolchain_tarballs = []
   options.toolchain_upload_path = ''
   options.upload = 'gs://upload/'
   options.binhost_base_url = options.upload
   options.prepend_version = True
   options.set_version = None
   options.skip_upload = False
   options.filters = True
   options.key = 'PORTAGE_BINHOST'
   options.binhost_conf_dir = 'foo'
   options.sync_binhost_conf = True
   options.slave_targets = [prebuilt.BuildTarget('x86-bar', 'aura')]
   self.mox.StubOutWithMock(prebuilt, 'ParseOptions')
   prebuilt.ParseOptions().AndReturn(tuple([options, target]))
   self.mox.StubOutWithMock(binpkg, 'GrabRemotePackageIndex')
   binpkg.GrabRemotePackageIndex(old_binhost).AndReturn(True)
   self.mox.StubOutWithMock(prebuilt.PrebuiltUploader, '__init__')
   self.mox.StubOutWithMock(prebuilt, 'GetBoardOverlay')
   fake_overlay_path = '/fake_path'
   prebuilt.GetBoardOverlay(
       options.build_path, options.board).AndReturn(fake_overlay_path)
   expected_gs_acl_path = os.path.join(fake_overlay_path,
                                       prebuilt._GOOGLESTORAGE_ACL_FILE)
   prebuilt.PrebuiltUploader.__init__(options.upload, expected_gs_acl_path,
                                      options.upload, mox.IgnoreArg(),
                                      options.build_path, options.packages,
                                      False, options.binhost_conf_dir, False,
                                      target, options.slave_targets)
   self.mox.StubOutWithMock(prebuilt.PrebuiltUploader, 'SyncHostPrebuilts')
   prebuilt.PrebuiltUploader.SyncHostPrebuilts(mox.IgnoreArg(), options.key,
       options.git_sync, options.sync_binhost_conf)
   self.mox.StubOutWithMock(prebuilt.PrebuiltUploader, 'SyncBoardPrebuilts')
   prebuilt.PrebuiltUploader.SyncBoardPrebuilts(
       mox.IgnoreArg(), options.key, options.git_sync,
       options.sync_binhost_conf, options.upload_board_tarball, None, [], '')
   self.mox.ReplayAll()
   prebuilt.main([])
Esempio n. 4
0
    def testMain(self):
        """Test that the main function works."""
        options = mock.MagicMock()
        old_binhost = 'http://prebuilt/1'
        options.previous_binhost_url = [old_binhost]
        options.board = 'x86-foo'
        options.profile = None
        target = prebuilt.BuildTarget(options.board, options.profile)
        options.build_path = '/trunk'
        options.dryrun = False
        options.private = True
        options.packages = []
        options.sync_host = True
        options.git_sync = True
        options.upload_board_tarball = True
        options.prepackaged_tarball = None
        options.toolchains_overlay_tarballs = []
        options.toolchains_overlay_upload_path = ''
        options.toolchain_tarballs = []
        options.toolchain_upload_path = ''
        options.upload = 'gs://upload/'
        options.binhost_base_url = options.upload
        options.prepend_version = True
        options.set_version = None
        options.skip_upload = False
        options.filters = True
        options.key = 'PORTAGE_BINHOST'
        options.binhost_conf_dir = None
        options.sync_binhost_conf = True
        options.slave_targets = [prebuilt.BuildTarget('x86-bar', 'aura')]
        self.PatchObject(prebuilt,
                         'ParseOptions',
                         return_value=tuple([options, target]))
        self.PatchObject(binpkg, 'GrabRemotePackageIndex', return_value=True)
        init_mock = self.PatchObject(prebuilt.PrebuiltUploader,
                                     '__init__',
                                     return_value=None)
        expected_gs_acl_path = os.path.join(
            '/fake_path', prebuilt._GOOGLESTORAGE_GSUTIL_FILE)
        self.PatchObject(portage_util,
                         'FindOverlayFile',
                         return_value=expected_gs_acl_path)
        host_mock = self.PatchObject(prebuilt.PrebuiltUploader,
                                     'SyncHostPrebuilts',
                                     return_value=None)
        board_mock = self.PatchObject(prebuilt.PrebuiltUploader,
                                      'SyncBoardPrebuilts',
                                      return_value=None)

        prebuilt.main([])

        init_mock.assert_called_once_with(options.upload, expected_gs_acl_path,
                                          options.upload, mock.ANY,
                                          options.build_path, options.packages,
                                          False, None, False, target,
                                          options.slave_targets, mock.ANY)
        board_mock.assert_called_once_with(options.key, options.git_sync,
                                           options.sync_binhost_conf,
                                           options.upload_board_tarball, None,
                                           [], '', [], '')
        host_mock.assert_called_once_with(options.key, options.git_sync,
                                          options.sync_binhost_conf)