Ejemplo n.º 1
0
    def setUp(self):
        self.model = LogfileModel(0, 6, None)

        for i, f in enumerate(testfiles):
            self.model.add_item(f)
            # select Detector A and channel 1
            self.model.item(i, 3).setText("B")
            self.model.item(i, 4).setText("2")
Ejemplo n.º 2
0
    def setUp(self):
        self.model = LogfileModel(0, 6, None)

        for i, f in enumerate(testfiles):
            self.model.add_item(f)
            # select Detector B and channel 2
            self.model.item(i, 3).setText("B")
            self.model.item(i, 4).setText("2")

        self.form = IntegratorDialog(self.model)
Ejemplo n.º 3
0
    def setUp(self):
        self.model = LogfileModel(0, 6, None)
        for f in testfiles:
            self.model.add_item(f)

        # select Detector B and channel 2
        self.model.item(0, 3).setText("B")
        self.model.item(0, 4).setText("2")

        self.form = PeakTableDialog(self.model)
Ejemplo n.º 4
0
class FSECplotterUtilsTestCase(TestCase):
    def setUp(self):
        self.model = LogfileModel(0, 6, None)

        for i, f in enumerate(testfiles):
            self.model.add_item(f)
            # select Detector A and channel 1
            self.model.item(i, 3).setText("B")
            self.model.item(i, 4).setText("2")

    def test_calc_yscale_factor(self):
        scale_factor = calc_yscale_factor(self.model, 0, 30)
        npt.assert_almost_equal(scale_factor,
                                SCALE_FACTOR,
                                decimal=MAX_DECIMAL)

    def test_find_peak(self):
        filenames, peak_x, peak_y = calc_max_peak(self.model, 0, 30)

        fname_true = [
            os.path.splitext(os.path.basename(f))[0] for f in testfiles
        ]
        eq_(filenames, fname_true)
        npt.assert_almost_equal(peak_x[0], MAX_VOLUME, decimal=MAX_DECIMAL)
        npt.assert_almost_equal(peak_y[0], MAX_VALUE, decimal=MAX_DECIMAL)

    def test_get_enabled_filename(self):
        fname = get_enabled_filename(self.model)
        fname_true = [
            os.path.splitext(os.path.basename(f))[0] for f in testfiles
        ]
        eq_(fname, fname_true)

        self.model.item(1, 0).setCheckState(0)
        fname = get_enabled_filename(self.model)
        del fname_true[1]
        eq_(fname, fname_true)

        self.model.item(1, 0).setCheckState(2)

    def test_peak_integrate(self):
        integrated = peak_integrate(self.model, 0, 30)
        npt.assert_almost_equal(integrated,
                                INTEGRATED_PEAK,
                                decimal=MAX_DECIMAL)

    def tearDown(self):
        del self.model
Ejemplo n.º 5
0
class TmCalcDialogTestCase(TestCase):
    def setUp(self):
        self.model = LogfileModel(0, 6, None)

        for i, f in enumerate(testfiles):
            self.model.add_item(f)

            # select Detector A and channel 1
            self.model.item(i, 3).setText("B")
            self.model.item(i, 4).setText("1")

        self.form = TmCalcDialog(self.model)

    def reset_form_empty(self):
        self.form.ui.removeFileExtensionCheckBox.setCheckState(0)
        self.form.ui.lineEdit_temp.setText("")
        self.form.ui.lineEdit.setText("")
        self.form.ui.lineEdit_2.setText("")

        self.form.tmplot_dialog.fig_saved = False
        self.form.tmplot_dialog.fit_complete = False

    def test_defaults(self):
        eq_(self.form.ui.lineEdit_temp.text(), "")
        eq_(self.form.ui.lineEdit.text(), "")
        eq_(self.form.ui.lineEdit_2.text(), "")

    def test_parse_temperature(self):
        self.reset_form_empty()

        self.form.ui.removeFileExtensionCheckBox.setCheckState(0)
        QTest.mouseClick(self.form.ui.updateListButton, Qt.LeftButton)

        top_item = self.form.ui.treeWidget.topLevelItem(0)
        eq_(top_item.data(1, 0), "17")

    def test_parse_temperature2(self):
        self.reset_form_empty()

        self.form.ui.removeFileExtensionCheckBox.setCheckState(2)
        QTest.mouseClick(self.form.ui.updateListButton, Qt.LeftButton)

        top_item = self.form.ui.treeWidget.topLevelItem(0)
        eq_(top_item.data(1, 0), "4")

    def test_set_temperature(self):
        self.reset_form_empty()

        # set the temperature of first item to "20"
        self.form.ui.lineEdit_temp.setText("20")

        top_item = self.form.ui.treeWidget.topLevelItem(0)
        self.form.ui.treeWidget.setCurrentItem(
            top_item, 0, QtCore.QItemSelectionModel.Select)
        QTest.mouseClick(self.form.ui.set_temp_button, Qt.LeftButton)

        top_item = self.form.ui.treeWidget.topLevelItem(0)
        eq_(top_item.data(1, 0), "20")

    def test_min_max_volume_inverse(self):
        self.reset_form_empty()
        self.form.ui.removeFileExtensionCheckBox.setCheckState(2)
        QTest.mouseClick(self.form.ui.updateListButton, Qt.LeftButton)

        self.form.ui.lineEdit.setText("2")
        self.form.ui.lineEdit_2.setText("1")

        okWidget = self.form.ui.buttonBox.button(self.form.ui.buttonBox.Ok)
        QTest.mouseClick(okWidget, Qt.LeftButton)

        ok_(not self.form.tmplot_dialog.fit_complete)

    def test_min_volume_empty(self):
        self.reset_form_empty()
        self.form.ui.removeFileExtensionCheckBox.setCheckState(2)
        QTest.mouseClick(self.form.ui.updateListButton, Qt.LeftButton)

        self.form.ui.lineEdit_2.setText("1")

        okWidget = self.form.ui.buttonBox.button(self.form.ui.buttonBox.Ok)
        QTest.mouseClick(okWidget, Qt.LeftButton)

        ok_(not self.form.tmplot_dialog.fit_complete)

    def test_max_volume_empty(self):
        self.reset_form_empty()
        self.form.ui.removeFileExtensionCheckBox.setCheckState(2)
        QTest.mouseClick(self.form.ui.updateListButton, Qt.LeftButton)

        self.form.ui.lineEdit.setText("1")

        okWidget = self.form.ui.buttonBox.button(self.form.ui.buttonBox.Ok)
        QTest.mouseClick(okWidget, Qt.LeftButton)

        ok_(not self.form.tmplot_dialog.fit_complete)

    def test_volume_empty(self):
        self.reset_form_empty()
        self.form.ui.removeFileExtensionCheckBox.setCheckState(2)
        QTest.mouseClick(self.form.ui.updateListButton, Qt.LeftButton)

        okWidget = self.form.ui.buttonBox.button(self.form.ui.buttonBox.Ok)
        QTest.mouseClick(okWidget, Qt.LeftButton)

        ok_(not self.form.tmplot_dialog.fit_complete)

    def test_accept(self):
        self.reset_form_empty()

        self.form.ui.removeFileExtensionCheckBox.setCheckState(2)
        QTest.mouseClick(self.form.ui.updateListButton, Qt.LeftButton)

        self.form.ui.lineEdit.setText("1")
        self.form.ui.lineEdit_2.setText("2")

        # prevent showing the warning dialog
        self.form.tmplot_dialog.fig_saved = True
        ok_button = self.form.tmplot_dialog.ok_button
        QtCore.QTimer.singleShot(0, ok_button.clicked)
        # close the child dialog
        okWidget = self.form.ui.buttonBox.button(self.form.ui.buttonBox.Ok)
        QTest.mouseClick(okWidget, Qt.LeftButton)

        ok_(self.form.tmplot_dialog.fit_complete)

    def tearDown(self):
        del self.form
Ejemplo n.º 6
0
class IntegratorDialogTestCase(TestCase):
    def setUp(self):
        self.model = LogfileModel(0, 6, None)

        for i, f in enumerate(testfiles):
            self.model.add_item(f)
            # select Detector B and channel 2
            self.model.item(i, 3).setText("B")
            self.model.item(i, 4).setText("2")

        self.form = IntegratorDialog(self.model)

    def reset_form_empty(self):
        self.form.ui.lineEdit.setText("")
        self.form.ui.lineEdit_2.setText("")

        self.form.integrate_accepted = False

    def test_defaults(self):
        eq_(self.form.ui.lineEdit.text(), "")
        eq_(self.form.ui.lineEdit_2.text(), "")

    def test_min_max_volume_inverse(self):
        self.reset_form_empty()
        self.form.ui.lineEdit.setText("2")
        self.form.ui.lineEdit_2.setText("1")

        okWidget = self.form.ui.buttonBox.button(self.form.ui.buttonBox.Ok)
        QTest.mouseClick(okWidget, Qt.LeftButton)

        ok_(not self.form.integrate_accepted)

    def test_min_volume_empty(self):
        self.reset_form_empty()
        self.form.ui.lineEdit_2.setText("1")

        okWidget = self.form.ui.buttonBox.button(self.form.ui.buttonBox.Ok)
        QTest.mouseClick(okWidget, Qt.LeftButton)

        ok_(not self.form.integrate_accepted)

    def test_max_volume_empty(self):
        self.reset_form_empty()
        self.form.ui.lineEdit.setText("1")

        okWidget = self.form.ui.buttonBox.button(self.form.ui.buttonBox.Ok)
        QTest.mouseClick(okWidget, Qt.LeftButton)

        ok_(not self.form.integrate_accepted)

    def test_volume_empty(self):
        self.reset_form_empty()

        okWidget = self.form.ui.buttonBox.button(self.form.ui.buttonBox.Ok)
        QTest.mouseClick(okWidget, Qt.LeftButton)

        ok_(not self.form.integrate_accepted)

    def test_accept(self):
        self.reset_form_empty()

        self.form.ui.lineEdit.setText("0")
        self.form.ui.lineEdit_2.setText("30")

        # prevent showing the warning dialog
        ok_button = self.form.plot_dialog.ok_button
        QtCore.QTimer.singleShot(0, ok_button.clicked)
        # close the child dialog
        okWidget = self.form.ui.buttonBox.button(self.form.ui.buttonBox.Ok)
        QTest.mouseClick(okWidget, Qt.LeftButton)

        ok_(self.form.integrate_accepted)
        eq_(self.form.min_volume, 0)
        eq_(self.form.max_volume, 30)
        ok_(self.form.plot_dialog.filenames)
        ok_(self.form.plot_dialog.intensities)

    def tearDown(self):
        del self.form
Ejemplo n.º 7
0
class PeakTableDialogTestCase(TestCase):
    def setUp(self):
        self.model = LogfileModel(0, 6, None)
        for f in testfiles:
            self.model.add_item(f)

        # select Detector B and channel 2
        self.model.item(0, 3).setText("B")
        self.model.item(0, 4).setText("2")

        self.form = PeakTableDialog(self.model)

    def reset_form_empty(self):
        self.form.ui.lineEdit_min.setText("")
        self.form.ui.lineEdit_max.setText("")

    def test_defaults(self):
        # no text is set in default
        eq_(self.form.ui.lineEdit_min.text(), "")
        eq_(self.form.ui.lineEdit_max.text(), "")

        # normalization check box is not checked
        eq_(self.form.ui.normalizeCheckBox.checkState(), 0)

        # no item is set in default
        eq_(self.form.ui.tableWidget.rowCount(), 1)
        eq_(self.form.ui.tableWidget.item(0, 0), None)
        eq_(self.form.ui.tableWidget.item(0, 1), None)
        eq_(self.form.ui.tableWidget.item(0, 2), None)

    def test_peak_search(self):
        self.reset_form_empty()

        self.form.ui.lineEdit_min.setText("0.0")
        self.form.ui.lineEdit_max.setText("30.0")

        QTest.mouseClick(self.form.ui.updateButton, Qt.LeftButton)

        eq_(self.form.ui.tableWidget.rowCount(), len(testfiles))

        filename, _ = os.path.splitext(os.path.basename(testfiles[0]))
        eq_(self.form.ui.tableWidget.item(0, 0).text(), filename)
        eq_(self.form.ui.tableWidget.item(0, 1).text(), str(MAX_VOLUME[0]))
        eq_(self.form.ui.tableWidget.item(0, 2).text(), str(MAX_VALUE[0]))

    def test_automated_update(self):
        self.reset_form_empty()

        self.form.ui.lineEdit_min.setText("0.0")
        self.form.ui.lineEdit_max.setText("30.0")

        eq_(self.form.ui.tableWidget.rowCount(), len(testfiles))

        filename, _ = os.path.splitext(os.path.basename(testfiles[0]))
        eq_(self.form.ui.tableWidget.item(0, 0).text(), filename)
        eq_(self.form.ui.tableWidget.item(0, 1).text(), str(MAX_VOLUME[0]))
        eq_(self.form.ui.tableWidget.item(0, 2).text(), str(MAX_VALUE[0]))

    def test_peak_normalization(self):
        self.reset_form_empty()

        self.form.ui.lineEdit_min.setText("0.0")
        self.form.ui.lineEdit_max.setText("30.0")

        self.form.ui.normalizeCheckBox.setCheckState(2)

        QTest.mouseClick(self.form.ui.updateButton, Qt.LeftButton)

        eq_(self.form.ui.tableWidget.rowCount(), len(testfiles))

        filename, _ = os.path.splitext(os.path.basename(testfiles[0]))
        eq_(self.form.ui.tableWidget.item(0, 0).text(), filename)
        eq_(self.form.ui.tableWidget.item(0, 1).text(), str(MAX_VOLUME[0]))
        eq_(self.form.ui.tableWidget.item(0, 2).text(), "1.0")

    def tearDown(self):
        del self.form