def test_connected_collections_have_same_color(self):
     # Model with 1 exp and 1 sim from it
     chrom_model = make_sample_chrom_model(exp_name=self.exp_name,
                                           include_sim=True)
     view = ChromatogramModelView(chromatogram_model=chrom_model,
                                  open_uv_on_open=True)
     with temp_bringup_ui_for(view):
         self.assertEqual(view.displayed_log_family_names, [LOG_FAMILY_UV])
         self.assertEqual(view.displayed_log_collection_names,
                          [self.exp_name, "Sim: " + self.exp_name])
 def test_disconnected_change_exp_color(self):
     # Model with 1 exp and 1 sim from it
     chrom_model = make_sample_chrom_model(exp_name=self.exp_name,
                                           include_sim=True)
     sim_name = "Sim: " + self.exp_name
     editor = PlotColorEditor(collection_list=chrom_model.log_collections,
                              disconnected_plots=True)
     color_trait = editor.collection_map[self.exp_name]
     editor.trait_set(**{color_trait: "red"})
     self.assertIn(self.exp_name, editor.modified_colors)
     self.assertEqual(editor.modified_colors[self.exp_name], "red")
     self.assertNotIn(sim_name, editor.modified_colors)
    def test_connected_visibility(self):
        # Model with 1 exp and 1 sim from it
        chrom_model = make_sample_chrom_model(exp_name=self.exp_name,
                                              include_sim=True)
        editor = PlotColorEditor(collection_list=chrom_model.log_collections)
        # exp only should be visible:
        color_trait = editor.collection_map[self.exp_name]
        exp_idx = color_trait.split("_")[-1]
        visibility_trait = "plot_always_visible_{}".format(exp_idx)
        self.assertTrue(getattr(editor, visibility_trait))

        sim_idx = 1 if exp_idx == "0" else 0
        visibility_trait = "plot_always_visible_{}".format(sim_idx)
        self.assertFalse(getattr(editor, visibility_trait))
    def test_disconnect_change_sim_color_reconnect(self):
        # Model with 1 exp and 1 sim from it
        chrom_model = make_sample_chrom_model(exp_name=self.exp_name,
                                              include_sim=True)
        sim_name = "Sim: " + self.exp_name
        editor = PlotColorEditor(collection_list=chrom_model.log_collections,
                                 disconnected_plots=True)
        sim_color_trait = editor.collection_map[sim_name]
        editor.trait_set(**{sim_color_trait: "red"})
        self.assertIn(sim_name, editor.modified_colors)
        self.assertEqual(editor.modified_colors[sim_name], "red")
        self.assertNotIn(self.exp_name, editor.modified_colors)
        exp_color_trait = editor.collection_map[self.exp_name]
        self.assertEqual(getattr(editor, exp_color_trait), "blue")

        # Reconnecting makes the simulation's color to be set back to the color
        # of its source experiment:
        editor.disconnected_plots = False
        self.assertEqual(editor.modified_colors[sim_name], "blue")
 def setUp(self):
     self.exp_name = 'Run_1'
     self.chrom_model = make_sample_chrom_model(exp_name=self.exp_name)
     self.chromatogram_plot = make_sample_model_calibration_plot()
 def setUp(self):
     self.exp_name = 'Run_1'
     self.chrom_model = make_sample_chrom_model(exp_name=self.exp_name)
     self.view = ChromatogramModelView(chromatogram_model=self.chrom_model)
 def setUp(self):
     self.exp_name = 'Run_1'
     self.chrom_model = make_sample_chrom_model(exp_name=self.exp_name)