def test_ebr(self): job_ini = os.path.join(os.path.dirname(case_master.__file__), 'job.ini') with Print.patch() as p: job_id = run_job(job_ini, log_level='error') self.assertIn('id | name', str(p)) # sanity check on the performance view: make sure that the most # relevant information is stored (it can be lost for instance due # to a wrong refactoring of the safely_call function) with read(job_id) as dstore: perf = view('performance', dstore) self.assertIn('total event_based_risk', perf)
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)
def test_ebr(self): # test a single case of `run_job`, but it is the most complex one, # event based risk with post processing job_ini = os.path.join( os.path.dirname(case_master.__file__), 'job.ini') with Print.patch() as p: job_id = run_job(job_ini, log_level='error') self.assertIn('id | name', str(p)) # sanity check on the performance views: make sure that the most # relevant information is stored (it can be lost due to a wrong # refactoring of the monitoring and it happened several times) with read(job_id) as dstore: perf = view('performance', dstore) self.assertIn('total event_based_risk', perf)
def test_ebr(self): # test a single case of `run_job`, but it is the most complex one, # event based risk with post processing job_ini = os.path.join( os.path.dirname(case_master.__file__), 'job.ini') with Print.patch() as p: job_id = run_job(job_ini, log_level='error') self.assertIn('id | name', str(p)) # sanity check on the performance view: make sure that the most # relevant information is stored (it can be lost for instance due # to a wrong refactoring of the safely_call function) with read(job_id) as dstore: perf = view('performance', dstore) self.assertIn('total event_based_risk', perf)
def test_ebr(self): job_ini = os.path.join(os.path.dirname(case_master.__file__), 'job.ini') with Print.patch() as p: run_job(job_ini, log_level='error') self.assertIn('id | name', str(p))