示例#1
0
 def test_get_uri_query_string(self):
     # test with fake data
     d = Dist("oneiric", "11.10", "2011-10-10", True)
     meta = MetaReleaseCore()
     q = meta._get_release_notes_uri_query_string(d)
     self.assertTrue("os=ubuntu" in q)
     self.assertTrue("ver=11.10" in q)
示例#2
0
    def test_parse_next_release_unsupported(self, mock_download):
        # We should jump over an unsupported release. LP: #1497024
        meta = MetaReleaseCore()
        meta.current_dist_name = "foo"
        with tempfile.TemporaryFile() as f:
            f.write("""Dist: foo
Supported: 1
Date: Thu, 26 Oct 2006 12:00:00 UTC
Version: 1.0

Dist: goo
Supported: 0
Date: Thu, 26 Oct 2016 12:00:00 UTC
Version: 2.0

Dist: hoo
Supported: 1
Date: Thu, 26 Oct 2026 12:00:00 UTC
Version: 3.0
            """.encode("utf-8"))
            f.seek(0)
            meta.metarelease_information = f
            meta.parse()
            self.assertEqual(meta.upgradable_to.name, "hoo")
            self.assertEqual(meta.upgradable_to.version, "3.0")
            self.assertEqual(meta.upgradable_to.supported, True)
示例#3
0
 def test_parse_fails_for_all_non_tagfiles(self, mock_download):
     meta = MetaReleaseCore()
     with tempfile.TemporaryFile() as f:
         f.write("random stuff".encode("utf-8"))
         f.seek(0)
         meta.metarelease_information = f
         self.assertRaises(MetaReleaseParseError, meta.parse)
示例#4
0
 def test_get_uri_query_string(self):
     # test with fake data, use a space to test quoting
     d = Dist("xenial", "16.04 LTS", "2016-04-21", True)
     meta = MetaReleaseCore()
     q = meta._get_release_notes_uri_query_string(d)
     self.assertTrue("os%3Dubuntu" in q)
     self.assertTrue("ver%3D16.04%20LTS" in q)
示例#5
0
 def test_html_uri_real(self):
     # test parsing of a meta-releaes file from the server
     with EnvironmentVarGuard() as environ:
         environ["META_RELEASE_FAKE_CODENAME"] = "lucid"
         meta = MetaReleaseCore(forceDownload=True)
         while meta.downloading:
             time.sleep(0.1)
         self.assertIsNotNone(meta.new_dist)
         uri = meta.new_dist.releaseNotesHtmlUri
         f = urlopen(uri)
         data = f.read().decode("UTF-8")
         self.assertTrue(len(data) > 0)
         self.assertTrue("<html>" in data)
def get_new_dist():
    """
    common code to test new dist fetching, get the new dist information
    for trusty+1
    """
    shutil.rmtree(tmpdir)
    meta = MetaReleaseCore()
    #meta.DEBUG = True
    meta.current_dist_name = "trusty"
    meta.METARELEASE_URI = \
        "https://changelogs.ubuntu.com/meta-release-development"
    meta.downloaded.wait()
    meta._buildMetaReleaseFile()
    meta.download()
    return meta.new_dist
示例#7
0
def get_new_dist(current_release):
    """
    common code to test new dist fetching, get the new dist information
    for hardy+1
    """
    meta = MetaReleaseCore()
    #meta.DEBUG = True
    meta.current_dist_name = current_release
    fake_metarelease = os.path.join(CURDIR, "test-data", "meta-release")
    meta.METARELEASE_URI = "file://%s" % fake_metarelease
    while meta.downloading:
        time.sleep(0.1)
    meta._buildMetaReleaseFile()
    meta.download()
    return meta.new_dist
示例#8
0
 def test_html_uri_real(self):
     with EnvironmentVarGuard() as environ:
         environ["META_RELEASE_FAKE_CODENAME"] = "lucid"
         # useDevelopmentRelease=True is only needed until precise is
         # released
         meta = MetaReleaseCore(forceDownload=True,
                                forceLTS=True,
                                useDevelopmentRelease=True)
         while meta.downloading:
             time.sleep(0.1)
         self.assertIsNotNone(meta.new_dist)
         uri = meta.new_dist.releaseNotesHtmlUri
         f = urlopen(uri)
         data = f.read().decode("UTF-8")
         self.assertTrue(len(data) > 0)
         self.assertTrue("<html>" in data)
示例#9
0
    def test_parse_good(self, mock_download):
        meta = MetaReleaseCore()
        meta.current_dist_name = "foo"
        with tempfile.TemporaryFile() as f:
            f.write("""Dist: foo
Supported: 1
Date: Thu, 26 Oct 2006 12:00:00 UTC
Version: 1.0

Dist: goo
Supported: 1
Date: Thu, 26 Oct 2016 12:00:00 UTC
Version: 2.0
            """.encode("utf-8"))
            f.seek(0)
            meta.metarelease_information = f
            meta.parse()
            self.assertEqual(meta.upgradable_to.name, "goo")
            self.assertEqual(meta.upgradable_to.version, "2.0")
            self.assertEqual(meta.upgradable_to.supported, True)
示例#10
0
    def get_distro_upgrades(self):
        """
        Implement the {backend}-get-distro-upgrades functionality
        """
        pklog.info("Get distro upgrades")
        self.status(STATUS_INFO)
        self.allow_cancel(False)
        self.percentage(None)

        if META_RELEASE_SUPPORT == False:
            return

        #FIXME Evil to start the download during init
        meta_release = MetaReleaseCore(False, False)
        #FIXME: should use a lock
        while meta_release.downloading:
            time.sleep(1)
        #FIXME: Add support for description
        if meta_release.new_dist != None:
            self.distro_upgrade(
                DISTRO_UPGRADE_STABLE, meta_release.new_dist.name, "%s %s" %
                (meta_release.new_dist.name, meta_release.new_dist.version))
示例#11
0
    def test_parse_next_release_unsupported_devel(self, mock_download):
        # We should not jump over an unsupported release if we are running in
        # "devel" mode. LP: #1497024
        meta = MetaReleaseCore()
        meta.current_dist_name = "foo"
        meta.useDevelopmentRelease = True
        with tempfile.TemporaryFile() as f:
            f.write("""Dist: foo
Supported: 1
Date: Thu, 26 Oct 2006 12:00:00 UTC
Version: 1.0

Dist: goo
Supported: 0
Date: Thu, 26 Oct 2016 12:00:00 UTC
Version: 2.0
            """.encode("utf-8"))
            f.seek(0)
            meta.metarelease_information = f
            meta.parse()
            self.assertEqual(meta.upgradable_to.name, "goo")
            self.assertEqual(meta.upgradable_to.version, "2.0")
            self.assertEqual(meta.upgradable_to.supported, False)