def test_check_manifest_unreadable_file(self): config = Config(read=False) config.root = self.use_temp_dir() manifest = os.path.join(self.temp_dir, "www", "simple", ".manifest") os.makedirs(os.path.dirname(manifest)) os.symlink(".manifest", manifest) self.assertRaises(IOError, check_manifest, config)
def test_check_manifest_unknown_file(self): config = Config(read=False) config.root = self.use_temp_dir() manifest = os.path.join(self.temp_dir, "www", "simple", ".manifest") with mkfile(manifest) as f: print( "ubuntu\tprecise\t/precise/ubuntu-12.04.2-desktop-i386.iso\t" "726970368", file=f) self.assertRaises(UnknownManifestFile, check_manifest, config)
def test_defaults(self, *args): config = Config(read=False) config.root = self.use_temp_dir() config["PROJECT"] = "ubuntu" config["DIST"] = "warty" os.mkdir(os.path.join(self.temp_dir, "etc")) stamp = os.path.join(config.root, "etc", ".next-build-suffix-ubuntu-warty-daily") self.assertFalse(os.path.exists(stamp)) self.assertEqual("20130225", next_build_id(config, "")) with open(stamp) as stamp_file: self.assertEqual("20130225:1\n", stamp_file.read())
def test_debug(self): config = Config(read=False) config.root = self.use_temp_dir() config["PROJECT"] = "ubuntu" config["DIST"] = "warty" config["DEBUG"] = "1" os.mkdir(os.path.join(self.temp_dir, "etc")) stamp = os.path.join(config.root, "etc", ".next-build-suffix-ubuntu-warty-daily") self.assertFalse(os.path.exists(stamp)) next_build_id(config, "daily") self.assertFalse(os.path.exists(stamp))
def check_manifest_pass(self): config = Config(read=False) config.root = self.use_temp_dir() manifest = os.path.join(self.temp_dir, "www", "simple", ".manifest") with mkfile(manifest) as f: print( "ubuntu\tprecise\t/precise/ubuntu-12.04.2-desktop-i386.iso\t" "726970368", file=f) touch( os.path.join(self.temp_dir, "www", "simple", "precise", "ubuntu-12.04.2-desktop-i386.iso"))
def test_chinese(self, *args): config = Config(read=False) config.root = self.use_temp_dir() config["PROJECT"] = "ubuntu" config["DIST"] = "raring" config["UBUNTU_DEFAULTS_LOCALE"] = "zh_CN" os.mkdir(os.path.join(self.temp_dir, "etc")) stamp = os.path.join( config.root, "etc", ".next-build-suffix-ubuntu-chinese-edition-raring-daily") self.assertFalse(os.path.exists(stamp)) self.assertEqual("20130225", next_build_id(config, "")) with open(stamp) as stamp_file: self.assertEqual("20130225:1\n", stamp_file.read())
def test_increment(self): config = Config(read=False) config.root = self.use_temp_dir() config["PROJECT"] = "ubuntu" config["DIST"] = "warty" config["DATE"] = "20120806" os.mkdir(os.path.join(self.temp_dir, "etc")) stamp = os.path.join(config.root, "etc", ".next-build-suffix-ubuntu-warty-daily-live") self.assertFalse(os.path.exists(stamp)) self.assertEqual("20120806", next_build_id(config, "daily-live")) with open(stamp) as stamp_file: self.assertEqual("20120806:1\n", stamp_file.read()) self.assertEqual("20120806.1", next_build_id(config, "daily-live")) with open(stamp) as stamp_file: self.assertEqual("20120806:2\n", stamp_file.read())
def test_get_mirrors(self): config = Config(read=False) config.root = self.use_temp_dir() production_path = os.path.join(self.temp_dir, "production", "trigger-mirrors") os.makedirs(os.path.dirname(production_path)) with mkfile(production_path) as production: print("sync x.example.org", file=production) print("async other.example.org", file=production) print("sync y.example.org z.example.org", file=production) self.assertEqual(["x.example.org", "y.example.org", "z.example.org"], _get_mirrors(config)) self.configure_triggers() self.assertEqual(["foo", "bar"], _get_mirrors(self.config)) self.config["UBUNTU_DEFAULTS_LOCALE"] = "zh_CN" self.assertEqual(["strix.canonical.com"], _get_mirrors(self.config))
def test_get_mirrors_async(self): config = Config(read=False) config.root = self.use_temp_dir() production_path = os.path.join(self.temp_dir, "production", "trigger-mirrors") with mkfile(production_path) as production: print("sync x.example.org", file=production) print("async a.example.org b.example.org", file=production) print("sync y.example.org z.example.org", file=production) print("async c.example.org", file=production) self.assertEqual(["a.example.org", "b.example.org", "c.example.org"], _get_mirrors_async(config)) self.configure_triggers() self.assertEqual(["foo-async", "bar-async"], _get_mirrors_async(self.config)) self.config["UBUNTU_DEFAULTS_LOCALE"] = "zh_CN" self.assertEqual([], _get_mirrors_async(self.config))
def test_check_manifest_no_manifest(self): config = Config(read=False) config.root = self.use_temp_dir() check_manifest(config)