def test_should_not_be_editable_when_you_are_in_the_first_row_and_column_different_from_time(self):
        row_index = 0
        column_index = thermal_cycle_row.colTIME
        valid_index = FakeIndex(row_index, column_index, True)
        dat = [[123, 1]]

        not_editable = QtCore.Qt.ItemFlags(QtCore.Qt.ItemIsEnabled)
        self.assertEqual(not_editable, thermal_cycle_flags.execute(
            FakeTermalCurveModel(dat), valid_index))
    def test_temperature_should_not_be_editable_when_rate_is_zero(self):
        row_index = 1
        column_index = thermal_cycle_row.colTEMP
        valid_index = FakeIndex(row_index, column_index, True)
        dat = [[], [123, 321, 0, 132]]

        not_editable = QtCore.Qt.ItemFlags(QtCore.Qt.ItemIsEnabled)
        self.assertEqual(not_editable, thermal_cycle_flags.execute(
            FakeTermalCurveModel(dat), valid_index))
    def test_should_not_be_editable_when_you_are_in_the_temp_column_and_time_is_negative(self):
        row_index = 0
        column_index = 12386
        valid_index = FakeIndex(row_index, column_index, True)
        dat = [[-1]]

        not_editable = QtCore.Qt.ItemFlags(QtCore.Qt.ItemIsEnabled)
        self.assertEqual(not_editable, thermal_cycle_flags.execute(
            FakeTermalCurveModel(dat), valid_index))
    def test_rate_is_not_editable_when_not_int_rate_mode(self):
        row_index = 1
        column_index = thermal_cycle_row.colRATE
        valid_index = FakeIndex(row_index, column_index, True)
        dat = [[], [123, 321, 80, 132]]
        modes = ['any mode', 'points']

        not_editable = QtCore.Qt.ItemFlags(QtCore.Qt.ItemIsEnabled)

        self.assertEqual(not_editable, thermal_cycle_flags.execute(FakeTermalCurveModel(dat, modes), valid_index))
    def test_nothing_should_be_editalble_when_offline(self):
        row_index = 0
        column_index = thermal_cycle_row.colTEMP
        valid_index = FakeIndex(row_index, column_index, True)
        dat = [[123, 321, 0, 132]]

        not_editable = QtCore.Qt.ItemFlags(QtCore.Qt.ItemIsEnabled)
        is_live = False

        self.assertEqual(not_editable, thermal_cycle_flags.execute(
            FakeTermalCurveModel(dat, ['any mode']), valid_index, is_live=is_live))
    def test_temperature_is_always_editable(self):
        row_index = 1
        column_index = thermal_cycle_row.colTEMP
        valid_index = FakeIndex(row_index, column_index, True)
        dat = [[], [123, 321, 80, 132]]
        modes = ['any mode', 'any mode']

        editable = QtCore.Qt.ItemFlags(
            QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEditable | QtCore.Qt.ItemIsEnabled)

        self.assertEqual(editable, thermal_cycle_flags.execute(FakeTermalCurveModel(dat, modes), valid_index))
    def test_temperature_should_not_be_editable_when_rate_is_zero(self):
        row_index = 1
        column_index = thermal_cycle_row.colTEMP
        valid_index = FakeIndex(row_index, column_index, True)
        dat = [[], [123, 321, 0, 132]]

        not_editable = QtCore.Qt.ItemFlags(QtCore.Qt.ItemIsEnabled)
        self.assertEqual(
            not_editable,
            thermal_cycle_flags.execute(FakeTermalCurveModel(dat),
                                        valid_index))
    def test_should_not_be_editable_when_you_are_in_the_first_row_and_column_different_from_time(
            self):
        row_index = 0
        column_index = thermal_cycle_row.colTIME
        valid_index = FakeIndex(row_index, column_index, True)
        dat = [[123, 1]]

        not_editable = QtCore.Qt.ItemFlags(QtCore.Qt.ItemIsEnabled)
        self.assertEqual(
            not_editable,
            thermal_cycle_flags.execute(FakeTermalCurveModel(dat),
                                        valid_index))
    def test_should_not_be_editable_when_you_are_in_the_temp_column_and_time_is_negative(
            self):
        row_index = 0
        column_index = 12386
        valid_index = FakeIndex(row_index, column_index, True)
        dat = [[-1]]

        not_editable = QtCore.Qt.ItemFlags(QtCore.Qt.ItemIsEnabled)
        self.assertEqual(
            not_editable,
            thermal_cycle_flags.execute(FakeTermalCurveModel(dat),
                                        valid_index))
    def test_rate_is_not_editable_when_not_int_rate_mode(self):
        row_index = 1
        column_index = thermal_cycle_row.colRATE
        valid_index = FakeIndex(row_index, column_index, True)
        dat = [[], [123, 321, 80, 132]]
        modes = ['any mode', 'points']

        not_editable = QtCore.Qt.ItemFlags(QtCore.Qt.ItemIsEnabled)

        self.assertEqual(
            not_editable,
            thermal_cycle_flags.execute(FakeTermalCurveModel(dat, modes),
                                        valid_index))
    def test_temperature_is_always_editable(self):
        row_index = 1
        column_index = thermal_cycle_row.colTEMP
        valid_index = FakeIndex(row_index, column_index, True)
        dat = [[], [123, 321, 80, 132]]
        modes = ['any mode', 'any mode']

        editable = QtCore.Qt.ItemFlags(QtCore.Qt.ItemIsSelectable
                                       | QtCore.Qt.ItemIsEditable
                                       | QtCore.Qt.ItemIsEnabled)

        self.assertEqual(
            editable,
            thermal_cycle_flags.execute(FakeTermalCurveModel(dat, modes),
                                        valid_index))
    def test_nothing_should_be_editalble_when_offline(self):
        row_index = 0
        column_index = thermal_cycle_row.colTEMP
        valid_index = FakeIndex(row_index, column_index, True)
        dat = [[123, 321, 0, 132]]

        not_editable = QtCore.Qt.ItemFlags(QtCore.Qt.ItemIsEnabled)
        is_live = False

        self.assertEqual(
            not_editable,
            thermal_cycle_flags.execute(FakeTermalCurveModel(
                dat, ['any mode']),
                                        valid_index,
                                        is_live=is_live))
    def test_should_not_be_editable_when_item_is_not_valid(self):
        not_valid_index = FakeIndex(None, None, False)

        not_editable = QtCore.Qt.ItemFlags(QtCore.Qt.ItemIsEnabled)
        self.assertEqual(
            not_editable, thermal_cycle_flags.execute(None, not_valid_index))
    def test_should_not_be_editable_when_item_is_not_valid(self):
        not_valid_index = FakeIndex(None, None, False)

        not_editable = QtCore.Qt.ItemFlags(QtCore.Qt.ItemIsEnabled)
        self.assertEqual(not_editable,
                         thermal_cycle_flags.execute(None, not_valid_index))