def test_nonstandard(self): tempdir = tempfile.mkdtemp() try: self.bagdir = os.path.join(tempdir, "samplebag") shutil.copytree(os.path.join(datadir, "samplembag"), self.bagdir) os.mkdir(os.path.join(self.bagdir, "metadata", "trial3")) self.bag = xtend.as_extended(Bag(self.bagdir)) contents = list(self.bag.nonstandard()) self.assertIn("about.txt", contents) self.assertIn(os.path.join("metadata", "pod.json"), contents) self.assertIn(os.path.join("metadata", "trial3"), contents) self.assertIn(os.path.join("data", "trial1.json"), contents) self.assertIn(os.path.join("data", "trial2.json"), contents) self.assertIn(os.path.join("data", "trial3/trial3a.json"), contents) self.assertIn(os.path.join("multibag", "member-bags.tsv"), contents) self.assertIn(os.path.join("multibag", "file-lookup.tsv"), contents) self.assertEqual(len(contents), 8) finally: shutil.rmtree(tempdir)
def test_replicate_withlink(self): tempdir = tempfile.mkdtemp() try: self.bagdir = os.path.join(tempdir, "samplebag") shutil.copytree(os.path.join(datadir, "samplembag"), self.bagdir) os.mkdir(os.path.join(self.bagdir, "metadata", "trial3")) self.bag = xtend.as_extended(Bag(self.bagdir)) self.bag.replicate_with_hardlink = True self.assertTrue( os.path.exists(os.path.join(self.bag._bagdir, "bagit.txt"))) outdir = os.path.join(tempdir, "otherbag") self.assertFalse(os.path.exists(os.path.join(outdir, "bagit.txt"))) self.bag.replicate("bagit.txt", outdir) self.assertTrue(os.path.exists(os.path.join(outdir, "bagit.txt"))) self.assertTrue(ishardlink(os.path.join(outdir, "bagit.txt"))) finally: shutil.rmtree(tempdir)
def setUp(self): self.bagroot = os.path.join(datadir, "samplembag.zip") self.bag = xtend.as_extended(open_bag(self.bagroot))