예제 #1
0
  def testGsdUrlRunCommandError(self):
    """Verify None returned when RunCommand returns non-zero code."""
    test_result = CommandResult()
    test_result.returncode = -1

    cb_url_lib.RunCommand(['gsutil', 'ls', self.gsd_url], redirect_stdout=True,
                          redirect_stderr=True).AndReturn(test_result)
    self.mox.ReplayAll()
    actual = cb_url_lib.DetermineUrl(self.http_url, self.gsd_pattern)
    self.assertEqual(None, actual)
예제 #2
0
    def testGsdUrlRunCommandError(self):
        """Verify None returned when RunCommand returns non-zero code."""
        test_result = CommandResult()
        test_result.returncode = -1

        cb_url_lib.RunCommand(['gsutil', 'ls', self.gsd_url],
                              redirect_stdout=True,
                              redirect_stderr=True).AndReturn(test_result)
        self.mox.ReplayAll()
        actual = cb_url_lib.DetermineUrl(self.http_url, self.gsd_pattern)
        self.assertEqual(None, actual)
예제 #3
0
  def testGsdUrlFileCopyFails(self):
    """Verify return value when gsutil copy fails."""
    test_result = CommandResult()
    test_result.returncode = -1

    os.path.join(IsA(str), IsA(str)).AndReturn(self.named_file.name)
    cb_url_lib.RunCommand(
        ['gsutil', 'cp', self.gsd_url, self.named_file.name],
        redirect_stdout=True, redirect_stderr=True).AndReturn(test_result)
    self.mox.ReplayAll()
    self.assertFalse(cb_url_lib.Download(self.gsd_url))
예제 #4
0
  def testGsdUrlGoodLocalFileOpenSucceeds(self):
    """Verify return value when GSD URL opens properly."""
    test_result = CommandResult()
    test_result.returncode = 0

    os.path.join(IsA(str), IsA(str)).AndReturn(self.named_file.name)
    cb_url_lib.RunCommand(
        ['gsutil', 'cp', self.gsd_url, self.named_file.name],
        redirect_stdout=True, redirect_stderr=True).AndReturn(test_result)
    self.mox.ReplayAll()
    self.assertTrue(cb_url_lib.Download(self.gsd_url))
예제 #5
0
    def testGsdUrlFileCopyFails(self):
        """Verify return value when gsutil copy fails."""
        test_result = CommandResult()
        test_result.returncode = -1

        os.path.join(IsA(str), IsA(str)).AndReturn(self.named_file.name)
        cb_url_lib.RunCommand(
            ['gsutil', 'cp', self.gsd_url, self.named_file.name],
            redirect_stdout=True,
            redirect_stderr=True).AndReturn(test_result)
        self.mox.ReplayAll()
        self.assertFalse(cb_url_lib.Download(self.gsd_url))
예제 #6
0
    def testGsdUrlGoodLocalFileOpenSucceeds(self):
        """Verify return value when GSD URL opens properly."""
        test_result = CommandResult()
        test_result.returncode = 0

        os.path.join(IsA(str), IsA(str)).AndReturn(self.named_file.name)
        cb_url_lib.RunCommand(
            ['gsutil', 'cp', self.gsd_url, self.named_file.name],
            redirect_stdout=True,
            redirect_stderr=True).AndReturn(test_result)
        self.mox.ReplayAll()
        self.assertTrue(cb_url_lib.Download(self.gsd_url))
예제 #7
0
  def testGsdUrlNoMatch(self):
    """Verify None returned when MatchUrl() returns None."""
    with open('testdata/test_page_many_links.html', 'r') as test_page:
      test_result = CommandResult()
      test_result.output = test_page.read()
      test_result.returncode = 0

    cb_url_lib.RunCommand(['gsutil', 'ls', self.gsd_url], redirect_stdout=True,
                          redirect_stderr=True).AndReturn(test_result)
    self.mox.ReplayAll()
    actual = cb_url_lib.DetermineUrl(self.http_url, self.gsd_pattern)
    self.assertEqual(None, actual)
예제 #8
0
    def testGsdUrlNoMatch(self):
        """Verify None returned when MatchUrl() returns None."""
        with open('testdata/test_page_many_links.html', 'r') as test_page:
            test_result = CommandResult()
            test_result.output = test_page.read()
            test_result.returncode = 0

        cb_url_lib.RunCommand(['gsutil', 'ls', self.gsd_url],
                              redirect_stdout=True,
                              redirect_stderr=True).AndReturn(test_result)
        self.mox.ReplayAll()
        actual = cb_url_lib.DetermineUrl(self.http_url, self.gsd_pattern)
        self.assertEqual(None, actual)
예제 #9
0
  def testGsdUrlGood(self):
    """Verify GSD URL returned when page opens properly."""
    with open('testdata/test_page_gsd_links.html', 'r') as test_page:
      test_result = CommandResult()
      test_result.output = test_page.read()
      test_result.returncode = 0

    cb_url_lib.RunCommand(['gsutil', 'ls', self.gsd_url], redirect_stdout=True,
                          redirect_stderr=True).AndReturn(test_result)
    self.mox.ReplayAll()
    expected = (
        'gs://chromeos-releases/stable-channel/x86-alex/0.12.433.269/'
        'chromeos_0.12.433.269_x86-alex_recovery_stable-channel_mp-v3.bin')
    actual = cb_url_lib.DetermineUrl(self.http_url, self.gsd_pattern)
    self.assertEqual(expected, actual)
예제 #10
0
    def testGsdUrlGood(self):
        """Verify GSD URL returned when page opens properly."""
        with open('testdata/test_page_gsd_links.html', 'r') as test_page:
            test_result = CommandResult()
            test_result.output = test_page.read()
            test_result.returncode = 0

        cb_url_lib.RunCommand(['gsutil', 'ls', self.gsd_url],
                              redirect_stdout=True,
                              redirect_stderr=True).AndReturn(test_result)
        self.mox.ReplayAll()
        expected = (
            'gs://chromeos-releases/stable-channel/x86-alex/0.12.433.269/'
            'chromeos_0.12.433.269_x86-alex_recovery_stable-channel_mp-v3.bin')
        actual = cb_url_lib.DetermineUrl(self.http_url, self.gsd_pattern)
        self.assertEqual(expected, actual)
 def setUp(self):
   self.mox = mox.Mox()
   self.cros_fw = '/path/to/chromeos-firmwareupdate'
   self.fw_dir = '/tmp/tmp.ABCD'
   self.mock_cres = CommandResult()
   self.mox.StubOutWithMock(os.path, 'exists')
   self.mox.StubOutWithMock(cb_command_lib, 'RunCommand')
  def setUp(self):
    self.mox = mox.Mox()
    self.image_name = 'ssd_name_here.bin'
    self.cros_fw = 'chromeos-firmwareupdate'
    self.mock_cres = CommandResult()

    self.board = 'x86-alex'
    self.alex_ec = cb_constants.EC_NAME[self.board]
    self.alex_ec2 = cb_constants.EC2_NAME[self.board]
    self.alex_bios = cb_constants.BIOS_NAME[self.board]
 def setUp(self):
   self.mox = mox.Mox()
   # defaults used by most tests
   self.image = tempfile.NamedTemporaryFile(suffix='ssd.bin')
   self.image_name = self.image.name
   self.firmware_dest = tempfile.mkdtemp()
   self.mount_point = self.firmware_dest
   self.mox.StubOutWithMock(os, 'getcwd')
   self.mox.StubOutWithMock(cb_command_lib, 'RunCommand')
   self.mock_cres = CommandResult()
   self.mock_cres.output = 'uudecode present'
   # do not need to clean up empty temporary file
   self.clean_dirs = [self.firmware_dest]