def setUp(self): super(TestSimpleTree, self).setUp() self.use_temp_dir() self.config = Config(read=False) self.tree = SimpleTree(self.config, self.temp_dir)
class TestSimpleTree(TestCase): def setUp(self): super(TestSimpleTree, self).setUp() self.use_temp_dir() self.config = Config(read=False) self.tree = SimpleTree(self.config, self.temp_dir) def test_default_directory(self): self.config.root = self.temp_dir self.assertEqual( os.path.join(self.temp_dir, "www", "simple"), SimpleTree(self.config).directory) def test_name_to_series(self): self.assertEqual( "warty", self.tree.name_to_series("ubuntu-4.10-install-i386.iso")) self.assertRaises(ValueError, self.tree.name_to_series, "foo-bar.iso") def test_path_to_manifest(self): iso = "kubuntu/.pool/kubuntu-5.04-install-i386.iso" iso_path = os.path.join(self.temp_dir, iso) os.makedirs(os.path.dirname(iso_path)) touch(iso_path) self.assertEqual( "kubuntu\thoary\t/%s\t0" % iso, self.tree.path_to_manifest(iso)) def test_manifest_files_prefers_non_pool(self): pool = os.path.join(self.temp_dir, ".pool") os.mkdir(pool) touch(os.path.join(pool, "ubuntu-4.10-install-i386.iso")) dist = os.path.join(self.temp_dir, "warty") os.mkdir(dist) os.symlink( os.path.join(os.pardir, ".pool", "ubuntu-4.10-install-i386.iso"), os.path.join(dist, "ubuntu-4.10-install-i386.iso")) self.assertEqual( ["warty/ubuntu-4.10-install-i386.iso"], list(self.tree.manifest_files())) def test_manifest_files_includes_non_duplicates_in_pool(self): pool = os.path.join(self.temp_dir, ".pool") os.mkdir(pool) touch(os.path.join(pool, "ubuntu-4.10-install-i386.iso")) touch(os.path.join(pool, "ubuntu-4.10-install-amd64.iso")) dist = os.path.join(self.temp_dir, "warty") os.mkdir(dist) os.symlink( os.path.join(os.pardir, ".pool", "ubuntu-4.10-install-i386.iso"), os.path.join(dist, "ubuntu-4.10-install-i386.iso")) self.assertEqual([ "warty/ubuntu-4.10-install-i386.iso", ".pool/ubuntu-4.10-install-amd64.iso", ], list(self.tree.manifest_files())) def test_manifest(self): pool = os.path.join(self.temp_dir, "kubuntu", ".pool") os.makedirs(pool) touch(os.path.join(pool, "kubuntu-5.04-install-i386.iso")) touch(os.path.join(pool, "kubuntu-5.04-live-i386.iso")) dist = os.path.join(self.temp_dir, "kubuntu", "hoary") os.makedirs(dist) os.symlink( os.path.join(os.pardir, ".pool", "kubuntu-5.04-install-i386.iso"), os.path.join(dist, "kubuntu-5.04-install-i386.iso")) os.symlink( os.path.join(os.pardir, ".pool", "kubuntu-5.04-live-i386.iso"), os.path.join(dist, "kubuntu-5.04-live-i386.iso")) self.assertEqual([ "kubuntu\thoary\t/kubuntu/hoary/kubuntu-5.04-install-i386.iso\t0", "kubuntu\thoary\t/kubuntu/hoary/kubuntu-5.04-live-i386.iso\t0", ], self.tree.manifest())