Ejemplo n.º 1
0
  def testGetLatestVersion(self):
    """Tests the GetLatestVersion functions."""
    download_helper = github.GitHubReleasesDownloadHelper(self._DOWNLOAD_URL)

    latest_version = download_helper.GetLatestVersion(self._PROJECT_NAME, None)

    self.assertEqual(latest_version, self._PROJECT_VERSION)
Ejemplo n.º 2
0
  def testGetProjectIdentifier(self):
    """Tests the GetProjectIdentifier functions."""
    download_helper = github.GitHubReleasesDownloadHelper(self._DOWNLOAD_URL)

    project_identifier = download_helper.GetProjectIdentifier()

    expected_project_identifier = 'com.github.{0:s}.{1:s}'.format(
        self._PROJECT_ORGANIZATION, self._PROJECT_NAME)

    self.assertEqual(project_identifier, expected_project_identifier)
Ejemplo n.º 3
0
  def testGetDownloadURL(self):
    """Tests the GetDownloadURL functions."""
    download_helper = github.GitHubReleasesDownloadHelper(self._DOWNLOAD_URL)

    download_url = download_helper.GetDownloadURL(
        self._PROJECT_NAME, self._PROJECT_VERSION)

    expected_download_url = (
        'https://github.com/{0:s}/{1:s}/archive/{2:s}.tar.gz').format(
            self._PROJECT_ORGANIZATION, self._PROJECT_NAME,
            self._PROJECT_VERSION)

    self.assertEqual(download_url, expected_download_url)
Ejemplo n.º 4
0
    def NewDownloadHelper(cls, project_definition):
        """Creates a new download helper.

    Args:
      project_definition (ProjectDefinition): project definition.

    Returns:
      DownloadHelper: download helper.

    Raises:
      ValueError: if no corresponding helper could be found for the download
          URL.
    """
        download_url = project_definition.download_url

        if download_url.endswith('/'):
            download_url = download_url[:-1]

        # Unify http:// and https:// URLs for the download helper check.
        if download_url.startswith('https://'):
            download_url = 'http://{0:s}'.format(download_url[8:])

        # Remove URL arguments.
        download_url, _, _ = download_url.partition('?')

        if download_url.startswith('http://pypi.org/project/'):
            return pypi.PyPIDownloadHelper(
                download_url, source_name=project_definition.pypi_source_name)

        if (download_url.startswith('http://sourceforge.net/projects/')
                and download_url.endswith('/files')):
            return sourceforge.SourceForgeDownloadHelper(download_url)

        if (download_url.startswith('http://github.com/')
                and download_url.endswith('/releases')):
            return github.GitHubReleasesDownloadHelper(download_url)

        raise ValueError('Unsupported download URL: {0:s}.'.format(
            project_definition.download_url))