def test_init_cols(self): """ Test loading a runfile from json """ with tempfile.TemporaryDirectory() as tempdir: path_run_params = os.path.sep.join([tempdir, "run.json"]) with open(path_run_params, 'w') as f: json.dump(self.run_db, f) cl = Crosslevel() cl.load_runfile(path_run_params) self.assertEqual(cl.col_h , self.run_db['col_h'])
def test_fetch_data_is_df(self): with tempfile.TemporaryDirectory() as tempdir: path_settings = os.path.sep.join([tempdir, "local_settings.json"]) path_runfile = os.path.sep.join([tempdir, "runfile.json"]) with open(path_settings, 'w') as f: json.dump(self.local_settings, f) with open(path_runfile, 'w') as f: json.dump(self.run_db, f) cl = Crosslevel() cl.load_local_settings(path_settings) cl.load_runfile(path_runfile) cl.fetch_data()
def test_load_runfile_sets_cols(self): cols_h = ["ds_pgm_sb", "osa_pgm_sb"] cols_l = ["ds_cm_sb"] with tempfile.TemporaryDirectory() as tempdir: path = os.path.sep.join([tempdir, "run.json"]) with open(path, 'w') as f: json.dump(self.run_db, f) cl = Crosslevel() cl.load_runfile(path) self.assertEqual(cl.cols_h, cols_h) self.assertEqual(cl.cols_l, cols_l) self.assertEqual(self.run_db['jobs'], cl.jobs) self.assertEqual(cl.table_h, "collected_pgm_fcast_test") self.assertEqual(cl.table_l, "collected_cm_fcast_test") self.assertEqual(cl.schema_h, "landed_test") self.assertEqual(cl.schema_l, "landed_test")
def test_load_runfile_cols(self): """ Test that the cols needed for jobs are correctly initalised """ jobs = self.run_db['jobs'] cols_h = [] cols_l = [] for job in jobs: cols_h.append(job['col_h']) cols_l.append(job['col_l']) with tempfile.TemporaryDirectory() as tempdir: path_run_params = os.path.sep.join([tempdir, "run.json"]) with open(path_run_params, 'w') as f: json.dump(self.run_db, f) cl = Crosslevel() cl.load_runfile(path_run_params) self.assertEqual(cl.cols_h, cols_h) self.assertEqual(cl.cols_l, cols_l)