def test_latest(self): self.assertTrue(Series.latest().is_latest) self.assertEqual("ubuntu", Series.latest().distribution) self.assertTrue(Series.latest(distribution="ubuntu-rtm").is_latest) self.assertEqual("ubuntu-rtm", Series.latest(distribution="ubuntu-rtm").distribution) self.assertRaises(ValueError, Series.latest, distribution="nonexistent")
def live_item_path_winfoss(config, arch): # This is a mess of special cases. Fortunately it is now only of # historical interest. cpuarch, subarch = split_arch(arch) project = config["PROJECT"] series = config["DIST"] if series == "warty" or cpuarch not in ("amd64", "i386"): raise NoLiveItem maitri = "http://maitri.ubuntu.com/theopencd" henrik = "http://people.canonical.com/~henrik/winfoss" if project == "ubuntu": if series == "hoary": if cpuarch == "i386": return "%s/ubuntu/winfoss/latest/Hoary-WinFOSS.tgz" % maitri elif cpuarch == "amd64": return ("%s/ubuntu/amd64/latest/" "Hoary-WinFOSS-amd64.tgz" % maitri) elif series == "breezy": return "%s/winfoss/ubuntu/current/Ubuntu-WinFOSS-5.10.tgz" % maitri elif series >= "dapper" and series <= "karmic": if series > "gutsy": series = Series.find_by_name("gutsy") return "%s/%s/ubuntu/current/ubuntu-winfoss-%s.tar.gz" % ( henrik, series, series.version) elif project == "kubuntu": if series == "hoary" and cpuarch == "i386": return ("%s/kubuntu/winfoss/latest/" "Kubuntu-WinFOSS-i386.tgz" % maitri) elif series == "breezy": if cpuarch == "i386": return ("%s/winfoss/kubuntu/current/" "Kubuntu-WinFOSS-5.10.tgz" % maitri) elif cpuarch == "amd64": return ("%s/winfoss/kubuntu-AMD/current/" "Kubuntu-WinFOSS-5.10-AMD.tgz" % maitri) elif series >= "dapper" and series <= "karmic": if series > "gutsy": series = Series.find_by_name("gutsy") return "%s/%s/kubuntu/current/kubuntu-winfoss-%s.tar.gz" % ( henrik, series, series.version) elif project == "edubuntu": if series >= "feisty" and series <= "karmic": if series > "gutsy": series = Series.find_by_name("gutsy") return "%s/%s/edubuntu/current/edubuntu-winfoss-%s.tar.gz" % ( henrik, series, series.version) elif project == "tocd3" and cpuarch == "i386": return "%s/tocd3/fsm/TOCD3.tgz" % maitri elif project == "tocd3.1" and cpuarch == "i386": return "%s/winfoss/tocd3.1/current/TOCD-31.tgz" % maitri raise NoLiveItem
def live_item_path_winfoss(config, arch): # This is a mess of special cases. Fortunately it is now only of # historical interest. cpuarch, subarch = split_arch(arch) project = config.project series = config["DIST"] if series == "warty" or cpuarch not in ("amd64", "i386"): return maitri = "http://maitri.ubuntu.com/theopencd" henrik = "http://people.canonical.com/~henrik/winfoss" if project == "ubuntu": if series == "hoary": if cpuarch == "i386": yield "%s/ubuntu/winfoss/latest/Hoary-WinFOSS.tgz" % maitri elif cpuarch == "amd64": yield ("%s/ubuntu/amd64/latest/" "Hoary-WinFOSS-amd64.tgz" % maitri) elif series == "breezy": yield "%s/winfoss/ubuntu/current/Ubuntu-WinFOSS-5.10.tgz" % maitri elif series >= "dapper" and series <= "karmic": if series > "gutsy": series = Series.find_by_name("gutsy") yield "%s/%s/ubuntu/current/ubuntu-winfoss-%s.tar.gz" % ( henrik, series, series.version) elif project == "kubuntu": if series == "hoary" and cpuarch == "i386": yield ("%s/kubuntu/winfoss/latest/" "Kubuntu-WinFOSS-i386.tgz" % maitri) elif series == "breezy": if cpuarch == "i386": yield ("%s/winfoss/kubuntu/current/" "Kubuntu-WinFOSS-5.10.tgz" % maitri) elif cpuarch == "amd64": yield ("%s/winfoss/kubuntu-AMD/current/" "Kubuntu-WinFOSS-5.10-AMD.tgz" % maitri) elif series >= "dapper" and series <= "karmic": if series > "gutsy": series = Series.find_by_name("gutsy") yield "%s/%s/kubuntu/current/kubuntu-winfoss-%s.tar.gz" % ( henrik, series, series.version) elif project == "edubuntu": if series >= "feisty" and series <= "karmic": if series > "gutsy": series = Series.find_by_name("gutsy") yield "%s/%s/edubuntu/current/edubuntu-winfoss-%s.tar.gz" % ( henrik, series, series.version) elif project == "tocd3" and cpuarch == "i386": yield "%s/tocd3/fsm/TOCD3.tgz" % maitri elif project == "tocd3.1" and cpuarch == "i386": yield "%s/winfoss/tocd3.1/current/TOCD-31.tgz" % maitri
def test_publish_type(self): for image_type, project, dist, publish_type in ( ("daily-preinstalled", "ubuntu-netbook", "precise", "preinstalled-netbook"), ("daily-preinstalled", "ubuntu-headless", "precise", "preinstalled-headless"), ("daily-preinstalled", "ubuntu-server", "precise", "preinstalled-server"), ("daily-preinstalled", "ubuntu", "precise", "preinstalled-desktop"), ("daily-live", "edubuntu", "edgy", "live"), ("daily-live", "edubuntu", "feisty", "desktop"), ("daily-live", "kubuntu-netbook", "lucid", "netbook"), ("daily-live", "ubuntu-mid", "lucid", "mid"), ("daily-live", "ubuntu-moblin-remix", "lucid", "moblin-remix"), ("daily-live", "ubuntu-netbook", "hardy", "netbook"), ("daily-live", "ubuntu-server", "hardy", "live"), ("daily-live", "ubuntu", "breezy", "live"), ("daily-live", "ubuntu", "dapper", "desktop"), ("ports_dvd", "ubuntu", "hardy", "dvd"), ("dvd", "kubuntu", "hardy", "dvd"), ("daily", "edubuntu", "edgy", "install"), ("daily", "edubuntu", "feisty", "server"), ("daily", "edubuntu", "gutsy", "server"), ("daily", "edubuntu", "hardy", "addon"), ("daily", "jeos", "hardy", "jeos"), ("daily", "ubuntu-core", "precise", "core"), ("daily", "ubuntu-server", "breezy", "install"), ("daily", "ubuntu-server", "dapper", "server"), ("daily", "ubuntu", "breezy", "install"), ("daily", "ubuntu", "dapper", "alternate"), ): self.config["DIST"] = Series.find_by_name(dist) publisher = self.make_publisher(project, image_type) self.assertEqual(publish_type, publisher.publish_type)
def test_image_output(self): self.config["DIST"] = Series.find_by_name("hoary") self.assertEqual( os.path.join( self.config.root, "scratch", "kubuntu", "hoary", "daily", "debian-cd"), self.make_publisher("kubuntu", "daily").image_output)
def assertProjectEqual(self, expected, project, series, **kwargs): config = Config(read=False) config["PROJECT"] = project config["DIST"] = Series.find_by_name(series) for key, value in kwargs.items(): config[key.upper()] = value self.assertEqual(expected, live_project(config))
def name_to_series(self, name): """Return the series for a file basename.""" version = name.split("-")[1] try: return Series.find_by_version(".".join(version.split(".")[:2])) except ValueError: logger.warning("Unknown version: %s" % version) raise
def setUp(self): super(TestCheckInstallable, self).setUp() self.use_temp_dir() self.config = Config(read=False) self.config.root = self.temp_dir self.config["PROJECT"] = "ubuntu" self.config["CAPPROJECT"] = "Ubuntu" self.config["IMAGE_TYPE"] = "daily" self.config["DIST"] = Series.find_by_name("warty") self.config["ARCHES"] = "i386"
def test_publish_base(self): self.assertEqual( os.path.join( self.config.root, "www", "full", "kubuntu", "daily-live"), self.make_publisher("kubuntu", "daily-live").publish_base) self.config["DIST"] = Series.find_by_name("hoary") self.assertEqual( os.path.join( self.config.root, "www", "full", "kubuntu", "hoary", "daily-live"), self.make_publisher("kubuntu", "daily-live").publish_base)
def test_metalink_dirs(self): basedir = os.path.join(self.config.root, "www", "full") date = "20120912" publisher = self.make_publisher("ubuntu", "daily-live") self.assertEqual( (basedir, os.path.join("daily-live", date)), publisher.metalink_dirs(date)) self.config["DIST"] = Series.find_by_name("hoary") self.assertEqual( (basedir, os.path.join("hoary", "daily-live", date)), publisher.metalink_dirs(date)) publisher = self.make_publisher("kubuntu", "daily-live") self.config["DIST"] = Series.latest() self.assertEqual( (basedir, os.path.join("kubuntu", "daily-live", date)), publisher.metalink_dirs(date)) self.config["DIST"] = Series.find_by_name("hoary") self.assertEqual( (basedir, os.path.join("kubuntu", "hoary", "daily-live", date)), publisher.metalink_dirs(date))
def test_compare(self): series = Series.find_by_name("hoary") self.assertLess(series, "breezy") self.assertLessEqual(series, "hoary") self.assertLessEqual(series, "breezy") self.assertEqual(series, "hoary") self.assertNotEqual(series, "warty") self.assertNotEqual(series, "breezy") self.assertGreaterEqual(series, "warty") self.assertGreaterEqual(series, "hoary") self.assertGreater(series, "warty") self.assertLess(series, Series.find_by_name("breezy")) self.assertLessEqual(series, Series.find_by_name("hoary")) self.assertLessEqual(series, Series.find_by_name("breezy")) self.assertEqual(series, Series.find_by_name("hoary")) self.assertNotEqual(series, Series.find_by_name("warty")) self.assertNotEqual(series, Series.find_by_name("breezy")) self.assertGreaterEqual(series, Series.find_by_name("warty")) self.assertGreaterEqual(series, Series.find_by_name("hoary")) self.assertGreater(series, Series.find_by_name("warty"))
def test_size_limit(self): for project, dist, image_type, size_limit in ( ("edubuntu", None, "daily-preinstalled", 4700372992), ("edubuntu", None, "dvd", 4700372992), ("ubuntustudio", None, "dvd", 4700372992), ("ubuntu-mid", None, "daily-live", 1073741824), ("ubuntu-moblin-remix", None, "daily-live", 1073741824), ("kubuntu-active", None, "daily-live", 1073741824), ("kubuntu", None, "daily-live", 1000000000), ("ubuntu", None, "dvd", 4700372992), ("ubuntu", "precise", "daily-live", 736665600), ("ubuntu", "quantal", "daily-live", 801000000), ): if dist is not None: self.config["DIST"] = Series.find_by_name(dist) publisher = self.make_publisher(project, image_type) self.assertEqual(size_limit, publisher.size_limit)
def test_format(self): series = Series.find_by_name("warty") self.assertEqual("warty", "%s" % series) series = Series.find_by_name("ubuntu-rtm/14.09") self.assertEqual("14.09", "%s" % series)
def test_str(self): series = Series.find_by_name("warty") self.assertEqual("warty", str(series)) series = Series.find_by_name("ubuntu-rtm/14.09") self.assertEqual("14.09", str(series))
def test_full_name(self): series = Series.find_by_name("utopic") self.assertEqual("utopic", series.full_name) series = Series.find_by_name("ubuntu-rtm/14.09") self.assertEqual("ubuntu-rtm/14.09", series.full_name)
def test_find_by_version(self): series = Series.find_by_version("5.04") self.assertEqual(("hoary", "5.04", "Hoary Hedgehog"), tuple(series))
def assertPathsEqual(self, expected, arch, item, project, series): config = Config(read=False) config["PROJECT"] = project config["DIST"] = Series.find_by_name(series) self.assertEqual(expected, list(live_item_paths(config, arch, item)))
def assertMirrorEqual(self, base, arch, series): config = Config(read=False) config["DIST"] = Series.find_by_name(series) self.assertEqual( os.path.join(config.root, base), find_mirror(config, arch))
def test_distribution(self): series = Series.find_by_name("utopic") self.assertEqual("ubuntu", series.distribution) series = Series.find_by_name("ubuntu-rtm/14.09") self.assertEqual("ubuntu-rtm", series.distribution)
def test_str(self): series = Series.find_by_name("warty") self.assertEqual("warty", str(series))
def assertNoPaths(self, arch, item, project, series): config = Config(read=False) config["PROJECT"] = project config["DIST"] = Series.find_by_name(series) self.assertRaises( NoLiveItem, next, live_item_paths(config, arch, item))
def test_latest(self): self.assertTrue(Series.latest().is_latest)
def test_series(self): config = Config(read=False) config["DIST"] = Series.find_by_name("warty") self.assertEqual("warty", config.series)
def name_to_series(self, name): """Return the series for a file basename.""" dist = name.split("-")[0] return Series.find_by_name(dist)
def assertFlavoursEqual(self, expected, arch, project, series): config = Config(read=False) config["PROJECT"] = project config["DIST"] = Series.find_by_name(series) self.assertEqual(expected.split(), flavours(config, arch))
def setUp(self): super(TestDailyTreePublisher, self).setUp() self.use_temp_dir() self.config = Config(read=False) self.config.root = self.temp_dir self.config["DIST"] = Series.latest()
def test_image_type_dir(self): publisher = self.make_publisher("ubuntu", "daily-live") self.assertEqual("daily-live", publisher.image_type_dir) self.config["DIST"] = Series.find_by_name("hoary") self.assertEqual( os.path.join("hoary", "daily-live"), publisher.image_type_dir)
def test_displayversion(self): series = Series.find_by_name("breezy") self.assertEqual("5.10", series.displayversion("ubuntu")) series = Series.find_by_name("dapper") self.assertEqual("6.06.2 LTS", series.displayversion("ubuntu")) self.assertEqual("6.06.2", series.displayversion("xubuntu"))
def assertBuilderEqual(self, expected, arch, series, project=None): config = Config(read=False) config["DIST"] = Series.find_by_name(series) if project is not None: config["PROJECT"] = project self.assertEqual(expected, live_builder(config, arch))