Beispiel #1
0
    def test_minor_update_count(self):
        """
        Test update count for a package that has only minor releases
        """
        updates = updatable_utils.get_package_update_list('package2', '1.0.0')
        self.assertEqual(updates['newer_releases'], 3)
        self.assertEqual(len(updates['major_updates']), 0)
        self.assertEqual(len(updates['minor_updates']), 3)
        self.assertEqual(len(updates['patch_updates']), 0)

        updates = updatable_utils.get_package_update_list('package2', '1.1.0')
        self.assertEqual(updates['newer_releases'], 2)
        self.assertEqual(len(updates['major_updates']), 0)
        self.assertEqual(len(updates['minor_updates']), 2)
        self.assertEqual(len(updates['patch_updates']), 0)

        updates = updatable_utils.get_package_update_list('package2', '1.2.0')
        self.assertEqual(updates['newer_releases'], 1)
        self.assertEqual(len(updates['major_updates']), 0)
        self.assertEqual(len(updates['minor_updates']), 1)
        self.assertEqual(len(updates['patch_updates']), 0)

        updates = updatable_utils.get_package_update_list('package2', '1.3.0')
        self.assertEqual(updates['newer_releases'], 0)
        self.assertEqual(len(updates['major_updates']), 0)
        self.assertEqual(len(updates['minor_updates']), 0)
        self.assertEqual(len(updates['patch_updates']), 0)
Beispiel #2
0
def _list_package_updates(package_name, version, show_pre_releases=False):
    """
    Function used to list all package updates in console

    :param package_name: string
    :param version: string
    :param show_pre_releases bool
    """
    updates = updatable_utils.get_package_update_list(package_name, version)
    has_displayed_updates = updates['newer_releases'] or (
        show_pre_releases and updates['pre_releases'])
    current_release_license = updates["current_release_license"]

    if has_displayed_updates:
        print('%s (%s) - License: %s' %
              (package_name, version, current_release_license))

    if updates['newer_releases']:
        _list_updates('Major releases', updates['major_updates'],
                      current_release_license)
        _list_updates('Minor releases', updates['minor_updates'],
                      current_release_license)
        _list_updates('Patch releases', updates['patch_updates'],
                      current_release_license)
        _list_updates('Unknown releases', updates['non_semantic_versions'],
                      current_release_license)
        has_displayed_updates = True

    if show_pre_releases and updates['pre_releases']:
        _list_updates('Pre releases', updates['pre_release_updates'],
                      current_release_license)
        has_displayed_updates = True

    if has_displayed_updates:
        print("___")
Beispiel #3
0
    def test_major_update_version(self):
        """
        Test update versions for a package that has only major releases.
        This also shows that releases are ordered descendant by release date.
        """
        updates = updatable_utils.get_package_update_list('package3', '1.0.0')
        self.assertEqual(len(updates['major_updates']), 2)
        self.assertEqual(updates['major_updates'][0]['version'], '3.0.0')
        self.assertEqual(updates['major_updates'][1]['version'], '2.0.0')

        updates = updatable_utils.get_package_update_list('package3', '2.0.0')
        self.assertEqual(len(updates['major_updates']), 1)
        self.assertEqual(updates['major_updates'][0]['version'], '3.0.0')

        updates = updatable_utils.get_package_update_list('package3', '3.0.0')
        self.assertEqual(len(updates['major_updates']), 0)
Beispiel #4
0
 def test_non_semantic_count(self):
     """
     Test for package with non semantic verions
     """
     updates = updatable_utils.get_package_update_list('package6', '0.1')
     self.assertEqual(updates['newer_releases'], 0)
     self.assertEqual(len(updates['major_updates']), 0)
     self.assertEqual(len(updates['minor_updates']), 0)
     self.assertEqual(len(updates['patch_updates']), 0)
     self.assertEqual(len(updates['non_semantic_versions']), 3)
    def test_update_license(self):
        """
        Test update count for a package that has only major releases
        """
        updates = updatable_utils.get_package_update_list('package3', '1.0.0')
        self.assertEqual(updates['current_release'], '1.0.0')
        self.assertEqual(updates['latest_release'], '3.0.0')
        self.assertEqual(updates['current_release_license'], 'GPL-2.0')
        self.assertEqual(updates['latest_release_license'], 'MIT')

        updates = updatable_utils.get_package_update_list('package3', '2.0.0')
        self.assertEqual(updates['current_release'], '2.0.0')
        self.assertEqual(updates['latest_release'], '3.0.0')
        self.assertEqual(updates['current_release_license'], 'GPL-3.0')
        self.assertEqual(updates['latest_release_license'], 'MIT')

        updates = updatable_utils.get_package_update_list('package3', '3.0.0')
        self.assertEqual(updates['current_release'], '3.0.0')
        self.assertEqual(updates['latest_release'], '3.0.0')
        self.assertEqual(updates['current_release_license'], 'MIT')
        self.assertEqual(updates['latest_release_license'], 'MIT')
Beispiel #6
0
    def test_major_update_date(self):
        """
        Test update upload time for a package that has only major releases.
        This also shows that releases are ordered descendant by release date.
        """
        updates = updatable_utils.get_package_update_list('package3', '1.0.0')
        self.assertEqual(len(updates['major_updates']), 2)
        self.assertEqual(
            updates['major_updates'][0]['upload_time'],
            datetime.datetime(year=2015,
                              month=9,
                              day=29,
                              hour=23,
                              minute=34,
                              second=21))
        self.assertEqual(
            updates['major_updates'][1]['upload_time'],
            datetime.datetime(year=2013,
                              month=11,
                              day=29,
                              hour=23,
                              minute=34,
                              second=21))

        updates = updatable_utils.get_package_update_list('package3', '2.0.0')
        self.assertEqual(len(updates['major_updates']), 1)
        self.assertEqual(
            updates['major_updates'][0]['upload_time'],
            datetime.datetime(year=2015,
                              month=9,
                              day=29,
                              hour=23,
                              minute=34,
                              second=21))

        updates = updatable_utils.get_package_update_list('package3', '3.0.0')
        self.assertEqual(len(updates['major_updates']), 0)
Beispiel #7
0
    def test_unusual_semantic_count(self):
        """
        Test for packages for a package with unusual versions
        """
        updates = updatable_utils.get_package_update_list(
            'package5', '0.9999999')
        self.assertEqual(updates['newer_releases'], 2)
        self.assertEqual(len(updates['major_updates']), 0)
        self.assertEqual(len(updates['minor_updates']), 2)
        self.assertEqual(len(updates['patch_updates']), 0)

        updates = updatable_utils.get_package_update_list(
            'package5', '0.99999999')
        self.assertEqual(updates['newer_releases'], 1)
        self.assertEqual(len(updates['major_updates']), 0)
        self.assertEqual(len(updates['minor_updates']), 1)
        self.assertEqual(len(updates['patch_updates']), 0)

        updates = updatable_utils.get_package_update_list(
            'package5', '0.999999999')
        self.assertEqual(updates['newer_releases'], 0)
        self.assertEqual(len(updates['major_updates']), 0)
        self.assertEqual(len(updates['minor_updates']), 0)
        self.assertEqual(len(updates['patch_updates']), 0)