def test_export_calc(self): tempdir = tempfile.mkdtemp() with Print.patch() as p: export('hcurves', tempdir, self.calc_id) [fname] = os.listdir(tempdir) self.assertIn(str(fname), str(p)) shutil.rmtree(tempdir)
def test_export_calc(self): tempdir = tempfile.mkdtemp() with Print.patch() as p: export('hcurves', self.calc_id, 'csv', tempdir) fnames = os.listdir(tempdir) self.assertIn(str(fnames[0]), str(p)) shutil.rmtree(tempdir)
def test_oqdata(self): # the that the environment variable OQ_DATADIR is honored job_ini = os.path.join(os.path.dirname(case_2.__file__), 'job_2.ini') tempdir = tempfile.mkdtemp() dbserver.ensure_on() with mock.patch.dict(os.environ, OQ_DATADIR=tempdir): [(job_id, oq)] = run_jobs([job_ini], log_level='error') job = commonlib.logs.dbcmd('get_job', job_id) self.assertTrue(job.ds_calc_dir.startswith(tempdir), job.ds_calc_dir) with Print.patch() as p: export('ruptures', job_id, 'csv', tempdir) self.assertIn('Exported', str(p)) shutil.rmtree(tempdir)
def test_oqdata(self): # the that the environment variable OQ_DATADIR is honored job_ini = os.path.join(os.path.dirname(case_2.__file__), 'job_2.ini') tempdir = tempfile.mkdtemp() dbserver.ensure_on() with mock.patch.dict(os.environ, OQ_DATADIR=tempdir): job_id = run_job(job_ini, log_level='error') job = commonlib.logs.dbcmd('get_job', job_id) self.assertTrue(job.ds_calc_dir.startswith(tempdir), job.ds_calc_dir) with Print.patch() as p: export('ruptures', job_id, 'csv', tempdir) self.assertIn('Exported', str(p)) shutil.rmtree(tempdir)