def test_raise_pseudos_not_exists(self): with self.assertRaises(FileNotFoundError): # create new non existant pseudo Hpseudo2 = os.path.expanduser("~/pseudo") self.launcher = Launcher(self.tempdir.name, Hpseudo2, abinit_variables=tbase1_1_vars)
def test_init_from_inplace_input(self): inputpath = os.path.join(here, "files", "tbase1_1.in") shutil.copy2(inputpath, self.tempdir.name) p = os.path.join(self.tempdir.name, "tbase1_1.in") self.launcher = Launcher.from_inplace_input(p, self.tempdir.name, Hpseudo, run=True)
def test_link_raise(self): with self.assertRaises(FileNotFoundError): self.launcher = Launcher(self.tempdir.name, Hpseudo, input_name="test.in", abinit_variables=tbase1_1_vars, to_link=os.path.join( self.tempdir.name, "odat_WFK"))
def test_raise_multiple_pseudo_dir(self): # temporary copy pseudo in another place tempdir2 = tempfile.TemporaryDirectory() shutil.copy(Hpseudo, tempdir2.name) Hpseudo2 = os.path.join(tempdir2.name, os.path.basename(Hpseudo)) with self.assertRaises(ValueError): self.launcher = Launcher(self.tempdir.name, [Hpseudo, Hpseudo2], abinit_variables=tbase1_1_vars) tempdir2.cleanup() del tempdir2
def test_launcher_from_file(self): inputpath = os.path.join(here, "files", "tbase1_1.in") self.launcher = Launcher.from_files(inputpath, self.tempdir.name, Hpseudo, run=True) # check that input file is created in good dir inputfile = os.path.join(self.tempdir.name, "tbase1_1.in") outputfile = os.path.join(self.tempdir.name, "tbase1_1.out") self.assertTrue(os.path.exists(inputfile)) self.assertTrue(os.path.exists(outputfile))
def test_launcher_from_args(self): self.launcher = Launcher(self.tempdir.name, Hpseudo, input_name="test_launcher.in", abinit_variables=tbase1_1_vars, run=True) # check that input file is created in good dir inputfile = os.path.join(self.tempdir.name, "test_launcher.in") outputfile = os.path.join(self.tempdir.name, "test_launcher.out") self.assertTrue(os.path.exists(inputfile)) self.assertTrue(os.path.exists(outputfile))
def test_linking(self): # create file to link tempdir2 = tempfile.TemporaryDirectory() path = os.path.join(tempdir2.name, "odat_WFK") with open(path, "a") as f: f.write("test") self.launcher = Launcher(self.tempdir.name, Hpseudo, input_name="test.in", abinit_variables=tbase1_1_vars, to_link=path) link = os.path.join(self.tempdir.name, "input_data", "idat_test_WFK") self.assertTrue(os.path.islink(link)) tempdir2.cleanup() del tempdir2
def test_raise_when_no_variables(self): with self.assertRaises(ValueError): self.launcher = Launcher(self.tempdir.name, Hpseudo, run=True)