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()
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()
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'
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"
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'
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"