def setUpClass(cls): """ Sets up a random tree-like structure with a few sub-files and -folders Similar to test_FileSystem. :return: """ os.makedirs(cls.cams_dir) for i in range(cls.n_cams): DummyFiles.CAMSGenerator(cls.cams_dir).generate() for tile in cls.tiles: cls.mnt += [ DummyFiles.MNTGenerator(cls.root, tile=tile).generate() ]
def test_l2_generation(self): import shutil gen = DummyFiles.L2Generator(self.root) prod = gen.generate() self.assertTrue(os.path.exists(gen.mtd)) self.assertTrue(os.path.exists(gen.prod)) self.assertTrue("_MTD_ALL.xml" in os.path.basename(gen.mtd)) self.assertTrue(os.path.dirname(gen.mtd), gen.prod) self.assertEqual(prod, prod) shutil.rmtree(gen.prod) self.assertFalse(os.path.exists(gen.prod))
def test_s2_l1_generation(self): import shutil gen = DummyFiles.L1Generator(self.root, platform="sentinel2") prod = gen.generate() self.assertTrue(os.path.exists(gen.mtd)) self.assertTrue(os.path.exists(gen.prod)) self.assertTrue("MTD_MSIL1C.xml" in os.path.basename(gen.mtd)) self.assertTrue("MSIL1C" in gen.prod) self.assertEqual(prod, prod) shutil.rmtree(gen.prod) self.assertFalse(os.path.exists(gen.prod))
def test_parasite_l2a_product(self): from Chain import DummyFiles prod = DummyFiles.L2Generator(self.product_root, platform="venus", tile=self.tile) prod.generate() with self.assertRaises(IOError): StartMaja(self.folders_file, self.tile, self.site, self.start, self.end, nbackward=self.nbackward, overwrite=self.overwrite) import shutil shutil.rmtree(prod.prod) self.assertFalse(os.path.exists(prod.prod))
def setUp(self): self.wdir = os.path.join(os.getcwd(), "wp_wdir") self.outdir = os.path.join(os.getcwd(), "wp_outdir") self.l1 = DummyFiles.L1Generator(root=os.getcwd(), tile="T11ABC", platform="sentinel2").generate() self.l1_list = [DummyFiles.L1Generator(root=os.getcwd(), tile="T11ABC", platform="sentinel2").generate() for _ in range(3)] self.other_l1 = [DummyFiles.L1Generator(root=os.getcwd()).generate() for _ in range(3)] self.l2 = DummyFiles.L2Generator(root=self.outdir, tile="T11ABC", platform="sentinel2").generate() self.other_l2 = [DummyFiles.L2Generator(root=self.outdir).generate() for _ in range(3)] self.gipp_dir = os.path.join(os.getcwd(), "gipp_dir") FileSystem.create_directory(self.gipp_dir) self.gipp = DummyFiles.GippGenerator(root=self.gipp_dir, platform="sentinel2").generate() self.cams = DummyFiles.CAMSGenerator(root=os.getcwd(), date=self.l1.date, platform="sentinel2").generate() FileSystem.create_directory(self.wdir) FileSystem.create_directory(self.outdir)
def setUpClass(cls): from Chain import DummyFiles from Common import FileSystem cls.product_root = os.path.join(cls.root, cls.tile) FileSystem.create_directory(cls.product_root) DummyFiles.L1Generator(cls.product_root, tile=cls.tile, date=cls.start_product, platform="sentinel2").generate() DummyFiles.L1Generator(cls.product_root, tile=cls.tile, date=cls.end_product, platform="sentinel2").generate() for d in set([DummyFiles.random_date() for _ in range(cls.n_dummies)]): DummyFiles.L1Generator(cls.product_root, tile=cls.tile, date=d, platform="sentinel2").generate() DummyFiles.L2Generator(cls.product_root, tile=cls.tile, date=d, platform="sentinel2").generate() for d in set([DummyFiles.random_date() for _ in range(cls.n_not_used)]): DummyFiles.L1Generator(cls.product_root, date=d, platform="sentinel2").generate() DummyFiles.L2Generator(cls.product_root, date=d, platform="sentinel2").generate() cls.folders_file = os.path.join(cls.root, "test_working_folders_file.txt") modify_folders_file(cls.template_folders_file, new_file=cls.folders_file, exeMaja=os.getcwd(), repWork=os.getcwd(), repGIPP=os.getcwd(), repL1=os.getcwd(), repL2=os.getcwd(), repMNT=os.getcwd()) cls.mnt = DummyFiles.MNTGenerator(root=cls.root, tile=cls.tile, platform="sentinel2") cls.mnt.generate() cls.cams = os.path.join(cls.root, "CAMS") os.makedirs(cls.cams) DummyFiles.CAMSGenerator(cls.cams, cls.start_product).generate() DummyFiles.CAMSGenerator(cls.cams, cls.end_product).generate() for _ in range(cls.n_not_used): DummyFiles.CAMSGenerator(cls.cams).generate() assert os.path.isfile(cls.folders_file)