Exemple #1
0
    def test_static_streams(self):

        tab_mod = self.create_simple_tab_model()
        stream_bar = self.app.test_frame.stream_bar
        stream_cont = StreamBarController(tab_mod, stream_bar)

        fluomd = {
            model.MD_DESCRIPTION: "test",
            model.MD_ACQ_DATE: time.time(),
            model.MD_BPP: 12,
            model.MD_BINNING: (1, 2),  # px, px
            model.MD_PIXEL_SIZE: (1e-6, 2e-5),  # m/px
            model.MD_POS: (13.7e-3, -30e-3),  # m
            model.MD_EXP_TIME: 1.2,  # s
            model.MD_IN_WL: (500e-9, 520e-9),  # m
            model.MD_OUT_WL: (600e-9, 630e-9),  # m
        }

        fluod = model.DataArray(numpy.zeros((512, 256), dtype="uint16"), fluomd)
        # Create the streams the same way as when opening a file, in
        # cont.tabs.AnalysisTab.display_new_data()
        fluo_panel = stream_cont.addStatic("Fluo Stream",
                                           fluod,
                                           cls=StaticFluoStream,
                                           add_to_view=True)

        # Check it indeed created a panel entry to a static fluo stream
        self.assertIsInstance(fluo_panel.stream, StaticFluoStream)

        # White box testing: we expect that the excitation/emission information
        # are simple text, so no reference to the value controls needs to be saved
        # Get the emission combo box (there should be only one)
        self.assertNotIn("emission", fluo_panel.entries)
        self.assertNotIn("excitation", fluo_panel.entries)
        test.gui_loop()

        semmd = {
            model.MD_DESCRIPTION: "test",
            model.MD_ACQ_DATE: time.time(),
            model.MD_BPP: 12,
            model.MD_BINNING: (1, 2),  # px, px
            model.MD_PIXEL_SIZE: (1e-6, 2e-5),  # m/px
            model.MD_POS: (13.7e-3, -30e-3),  # m
            model.MD_EXP_TIME: 1.2,  # s
        }

        semd = model.DataArray(numpy.zeros((256, 256), dtype="uint16"), semmd)
        # Create the streams the same way as when opening a file, in
        # cont.tabs.AnalysisTab.display_new_data()
        sem_cont = stream_cont.addStatic("SEM Stream", semd,
                                          cls=StaticSEMStream,
                                          add_to_view=True)

        # Check it indeed created a panel entry to a static fluo stream
        self.assertIsInstance(sem_cont.stream, StaticSEMStream)

        # White box testing: we expect autobc is available
        self.assertIn("autobc", sem_cont.entries)

        # Clear remaining streams
        stream_bar.clear()
        test.gui_loop()

        self.assertEqual(stream_bar.get_size(), 0)
    def test_static_streams(self):

        tab_mod = self.create_simple_tab_model()
        stream_bar = self.app.test_frame.stream_bar
        stream_cont = StreamBarController(tab_mod, stream_bar)

        fluomd = {
            model.MD_DESCRIPTION: "test",
            model.MD_ACQ_DATE: time.time(),
            model.MD_BPP: 12,
            model.MD_BINNING: (1, 2),  # px, px
            model.MD_PIXEL_SIZE: (1e-6, 2e-5),  # m/px
            model.MD_POS: (13.7e-3, -30e-3),  # m
            model.MD_EXP_TIME: 1.2,  # s
            model.MD_IN_WL: (500e-9, 520e-9),  # m
            model.MD_OUT_WL: (600e-9, 630e-9),  # m
        }

        fluod = model.DataArray(numpy.zeros((512, 256), dtype="uint16"),
                                fluomd)
        # Create the streams the same way as when opening a file, in
        # cont.tabs.AnalysisTab.display_new_data()
        fluo_panel = stream_cont.addStatic("Fluo Stream",
                                           fluod,
                                           cls=StaticFluoStream,
                                           add_to_view=True)

        # Check it indeed created a panel entry to a static fluo stream
        self.assertIsInstance(fluo_panel.stream, StaticFluoStream)

        # White box testing: we expect that the excitation/emission information
        # are simple text, so no reference to the value controls needs to be saved
        # Get the emission combo box (there should be only one)
        self.assertNotIn("emission", fluo_panel.entries)
        self.assertNotIn("excitation", fluo_panel.entries)
        test.gui_loop()

        semmd = {
            model.MD_DESCRIPTION: "test",
            model.MD_ACQ_DATE: time.time(),
            model.MD_BPP: 12,
            model.MD_BINNING: (1, 2),  # px, px
            model.MD_PIXEL_SIZE: (1e-6, 2e-5),  # m/px
            model.MD_POS: (13.7e-3, -30e-3),  # m
            model.MD_EXP_TIME: 1.2,  # s
        }

        semd = model.DataArray(numpy.zeros((256, 256), dtype="uint16"), semmd)
        # Create the streams the same way as when opening a file, in
        # cont.tabs.AnalysisTab.display_new_data()
        sem_cont = stream_cont.addStatic("SEM Stream",
                                         semd,
                                         cls=StaticSEMStream,
                                         add_to_view=True)

        # Check it indeed created a panel entry to a static fluo stream
        self.assertIsInstance(sem_cont.stream, StaticSEMStream)

        # White box testing: we expect autobc is available
        self.assertIn("autobc", sem_cont.entries)

        # Clear remaining streams
        stream_bar.clear()
        test.gui_loop()

        self.assertEqual(stream_bar.get_size(), 0)