def test_widget_date_returns_correctly(): qtwidget = createwidget(TYPE) wrapper = widgetwrapper(TYPE, qtwidget, config, layer=None, label=None, field=None) assert wrapper.validate() is False wrapper.datewidget.setDate(QDate(2017, 7, 24)) wrapper.datewidget.setTime(QTime(15, 46, 29)) expected = "2017-07-24T15:46:29" assert wrapper.value() == expected
def test_invalid_date_marks_widget_as_invalid(): qtwidget = createwidget(TYPE) wrapper = widgetwrapper(TYPE, qtwidget, config, layer=None, label=None, field=None) assert wrapper._is_valid is False with pytest.raises(ValueError): wrapper.setvalue("2008-12") assert wrapper._is_valid is False assert wrapper.validate() is False
def test_iso_date_returns_valid(): qtwidget = createwidget(TYPE) wrapper = widgetwrapper(TYPE, qtwidget, config, layer=None, label=None, field=None) input = "2017-07-24T15:46:29" wrapper.setvalue(input) expected = "2017-07-24T15:46:29" assert wrapper.value() == expected assert wrapper.validate() is True input = "2017-07-24" wrapper.setvalue(input) expected = "2017-07-24T00:00:00" assert wrapper.value() == expected assert wrapper.validate() is True
def initWidget(self, widget, config): if not widget.layout(): widget.setLayout(QVBoxLayout()) widget.layout().setContentsMargins(0, 0, 0, 0) dbconfig = config['dboptions'] for i in xrange(dbconfig['maximages']): innerwidget = createwidget("Image") wrapper = widgetwrapper("Image", innerwidget, config, self.layer, self.label, self.field, self.context) wrapper.largewidgetrequest.connect(self.largewidgetrequest.emit) wrapper.photo_id = None wrapper.photo_number = i widget.layout().addWidget(innerwidget) self.widgets.append((innerwidget, wrapper))
def test_should_set_return_none_on_none(): qtwidget = createwidget(TYPE) wrapper = widgetwrapper(TYPE, qtwidget, config, layer=None, label=None, field=None) wrapper.setvalue(None) assert wrapper.value() is None