예제 #1
0
def test_element_remove_child_must_remove_properly():
    element_type = ElementType('xsd:string')
    name_elem = Element(name='Name', element_type=element_type)
    surname_elem = Element(name='Surname', element_type=element_type)
    f = ElementType(name='ModelType', children=[name_elem, surname_elem])

    # Removing surname
    f.remove_child(surname_elem)

    assert f.children == [name_elem]

    # It's hash must be changed
    f_removed = ElementType(name='ModelType', children=[name_elem])
    assert f_removed == f
예제 #2
0
def test_element_children_original_order_must_keep_order_when_removed_child():
    element_type = ElementType('xsd:string')

    # A not alphabetical order...
    name = Element(name='Name', element_type=element_type)
    children = [
        Element(name='Surname', element_type=element_type),
        name,
        Element(name='City', element_type=element_type),
    ]

    f = ElementType(name='ModelType', children=children)

    f.remove_child(name)

    children.remove(name)

    assert f.children != children
    assert f.children_original_order == children