def test_no_date_no_time(self):
        callback = Mock()
        editor = TimeVariableEditor(self.parent, TimeVariable("var"), callback)
        self.assertEqual(editor.value, 0)
        self.assertEqual(self.editor._edit.dateTime(), _datetime(1970, 1, 1))
        self.callback.assert_not_called()

        datetime = QDateTime(QDate(2001, 9, 9), QTime(1, 2, 3))
        editor._edit.setDateTime(datetime)
        self.assertEqual(editor._edit.dateTime(), datetime)
        self.assertEqual(editor.value, 999993600 + 3723)
        callback.assert_called_once()
    def test_have_time(self):
        callback = Mock()
        editor = TimeVariableEditor(self.parent,
                                    TimeVariable("var", have_time=1), callback)
        self.assertEqual(editor.value, 0)
        self.assertEqual(self.editor._edit.dateTime(),
                         QDateTime(QDate(1970, 1, 1), QTime(0, 0, 0)))
        self.callback.assert_not_called()

        datetime = QDateTime(QDate(1900, 1, 1), QTime(1, 2, 3))
        editor._edit.setDateTime(datetime)
        self.assertEqual(editor._edit.dateTime(), datetime)
        self.assertEqual(editor.value, 3723)
        callback.assert_called_once()
 def setUp(self):
     self.callback = Mock()
     self.editor = TimeVariableEditor(self.parent,
                                      TimeVariable("var", have_date=1),
                                      self.callback)