Пример #1
0
  def testDownloadSdk(self):
    """Tests DownloadSdk() with a numeric version."""
    brillo_sdk._DownloadSdk(gs.GSContext(), self.sdk_path, '1.2.3')

    # Given the explicit path and version, sync what we expect, and where.
    expected = [mock.call(mock.ANY,
                          self.sdk_path,
                          depth=1,
                          repo_cmd=mock.ANY),
                mock.call().Sync()]

    self.assertEqual(expected, self.mock_repo.mock_calls)

    # Verify that the right version number was written out.
    sdk_version_file = project_sdk.VersionFile(self.sdk_path)
    self.assertEqual('1.2.3', osutils.ReadFile(sdk_version_file))
Пример #2
0
  def testDownloadSdkFailureCleanup(self):
    """Tests DownloadSdk() with a numeric version."""

    # Create sdk_path, and put something in it so we confirm it's gone.
    osutils.Touch(os.path.join(self.sdk_path, 'contents'), makedirs=True)

    # Prep for failure via the repo mock.
    class FakeException(Exception):
      """Raised to simulate a failure."""

    self.mock_repo.side_effect = FakeException('Testing a failure.')

    # Run, and fail.
    with self.assertRaises(FakeException):
      brillo_sdk._DownloadSdk(gs.GSContext(), self.sdk_path, '1.2.3')

    # Make sure the SDK dir was cleaned up.
    self.assertFalse(os.path.exists(self.sdk_path))