コード例 #1
0
def test_widget_base_element_attribute_dispatches_when_view_exists():
    view = FakeDispatchView({'name': 'attr', 'selector': '#id', 'attr': 'hello', 'value': 'world'})

    b_elem = BaseElement(id='id')
    b_elem.view = view
    b_elem._set_attribute('hello', 'world')
    view.verify()
コード例 #2
0
def test_widget_base_element_attribute_dispatches_when_view_exists():
    view = FakeDispatchView({
        'name': 'attr',
        'selector': '#id',
        'attr': 'hello',
        'value': 'world'
    })

    b_elem = BaseElement(id='id')
    b_elem.view = view
    b_elem._set_attribute('hello', 'world')
    view.verify()
コード例 #3
0
def test_widget_base_element_doesnt_set_attribute_when_none():
    b_elem = BaseElement(id='id')
    b_elem._set_attribute('hello', None)
    assert 'hello' not in b_elem._attributes, 'BaseElement._set_attribute should do nothing when attribute value is None'
コード例 #4
0
def test_widget_base_element_sets_attributes():
    b_elem = BaseElement(id='id')
    b_elem._set_attribute('hello', 'there')
    assert b_elem._attributes.get('hello') == 'there', "BaseElement._set_attribute should set the specified attribute in BaseElement._attributes"
コード例 #5
0
def test_widget_base_element_doesnt_set_attribute_when_none():
    b_elem = BaseElement(id='id')
    b_elem._set_attribute('hello', None)
    assert 'hello' not in b_elem._attributes, 'BaseElement._set_attribute should do nothing when attribute value is None'
コード例 #6
0
def test_widget_base_element_sets_attributes():
    b_elem = BaseElement(id='id')
    b_elem._set_attribute('hello', 'there')
    assert b_elem._attributes.get(
        'hello'
    ) == 'there', "BaseElement._set_attribute should set the specified attribute in BaseElement._attributes"