def test_export_data_event_bad_extension(self): fname_name = "testfile_TestSimGroupView.blah" expected_fname = fname_name + ".csv" with temp_fname(fname_name) as fname_path: with temp_fname(expected_fname): model_view = self._get_model_view() model_view.do_export_data(fname_name) found = os.listdir(os.path.dirname(fname_path)) self.assertNotIn(fname_name, found) self.assertIn(expected_fname, found)
def test_export_data_event(self): fname_name = "testfile_TestSimGroupView.csv" with temp_fname(fname_name) as fname_path: model_view = self._get_model_view() model_view.do_export_data(fname_name) found = os.listdir(os.path.dirname(fname_path)) self.assertIn(fname_name, found)
def test_save_task_no_ext(self): filename_no_ext = "testing_tempfile_kromatography3" task = self.task with temp_fname(filename_no_ext): task.save_project_as(filename_no_ext) self.assertFalse(isfile(filename_no_ext)) correct_file = filename_no_ext + KROM_EXTENSION self.assertTrue(isfile(correct_file)) attempt_remove_file(correct_file)
def test_plot_export(self): data = XYData(name="test", x_data=arange(20), y_data=arange(20), x_metadata={"units": "min"}, y_metadata={"units": "AU"}) filepath = "test.png" with temp_fname(filepath): data.mpl_show(filepath=filepath) self.assertIn(filepath, listdir("."))
def write_sim_to_input_file_and_check(self, sim): cadet_input = build_cadet_input(sim) output_file = "test.h5" with temp_fname(output_file): write_to_h5(output_file, cadet_input, root='/input', overwrite=True) self.assertTrue(exists(output_file)) with h5py.File(F1NAME, "r") as h5: self.assertEqual(h5.keys(), [u"input"]) expected = [ u'CHROMATOGRAPHY_TYPE', u'discretization', u'model', u'sensitivity', u'solver' ] self.assertEqual(set(h5[u"input"].keys()), set(expected)) data_found = read_from_h5(output_file) return data_found
def test_export_data_event(self): fname_seed = "testfile_TestBindingModelOptimizerView.csv" with temp_fname(fname_seed) as fname: model_view = self._get_model_view() model_view.do_export_data(fname) self.assertIn(fname_seed, os.listdir(os.path.dirname(fname)))
def test_save_task(self): filename = "testing_tempfile_kromatography" + KROM_EXTENSION task = self.task with temp_fname(filename): task.save_project_as(filename) self.assertTrue(isfile(filename))
def test_plot_export_to_jpeg(self): data = XYData(name="test", x_data=arange(20), y_data=arange(20)) filepath = "test.jpg" with temp_fname(filepath): data.mpl_show(filepath=filepath) self.assertIn(filepath, listdir("."))