Exemple #1
0
def test_sets_prfeix_suffix_on_widget():
    widget = widget=NumberWidget().createWidget(None)
    wrapper = NumberWidget(widget)
    wrapper.initWidget(widget, {})
    wrapper.config = config
    assert widget.prefix == config['prefix']
    assert widget.suffix == config['suffix']
Exemple #2
0
def test_should_return_same_value():
    widget = NumberWidget().createWidget(None)
    wrapper = NumberWidget(widget=widget)
    wrapper.setvalue(1)
    assert wrapper.value() == 1
    wrapper.setvalue(None)
    assert wrapper.value() == 0
Exemple #3
0
def test_should_return_same_value_doublewidget():
    widget = widget=DoubleNumberWidget().createWidget(None)
    wrapper = NumberWidget(widget=widget)
    wrapper.setvalue(1)
    assert wrapper.value() == 1
    wrapper.setvalue(None)
    assert wrapper.value() == 0
Exemple #4
0
def test_sets_prfeix_suffix_on_widget():
    widget = widget = NumberWidget().createWidget(None)
    wrapper = NumberWidget(widget)
    wrapper.initWidget(widget, {})
    wrapper.config = config
    assert widget.prefix == config['prefix']
    assert widget.suffix == config['suffix']
Exemple #5
0
def test_should_return_value_within_range():
    widget = widget = NumberWidget().createWidget(None)
    wrapper = NumberWidget(widget)
    wrapper.initWidget(widget, {})
    wrapper.config = config
    wrapper.setvalue(101)
    assert wrapper.value() == 100
    wrapper.setvalue(-1)
    assert wrapper.value() == 0
    wrapper.setvalue(1)
    assert wrapper.value() == 1
Exemple #6
0
def test_non_int_should_error():
    widget = widget = NumberWidget().createWidget(None)
    wrapper = NumberWidget(widget=widget)
    with pytest.raises(ValueError):
        wrapper.setvalue("Test")
Exemple #7
0
def test_should_return_value_within_range():
    widget = widget=NumberWidget().createWidget(None)
    wrapper = NumberWidget(widget)
    wrapper.initWidget(widget, {})
    wrapper.config = config
    wrapper.setvalue(101)
    assert wrapper.value() == 100
    wrapper.setvalue(-1)
    assert wrapper.value() == 0
    wrapper.setvalue(1)
    assert wrapper.value() == 1
Exemple #8
0
def test_non_int_should_error():
    widget = widget=NumberWidget().createWidget(None)
    wrapper = NumberWidget(widget=widget)
    with pytest.raises(ValueError):
        wrapper.setvalue("Test")