def test_similarity_must_return_expected_ratio_considering_annotation(): f = ElementType(name='ModelType') f.annotation = 'A simple documentation for type' f2 = ElementType(name='AnotherElementType') f2.annotation = 'A simple documentation for type' assert f2.similarity(f) > 0.8 # With a small change in documentation f2.annotation = 'A simple documentation' assert f2.similarity(f) > 0.7
def test_element_similarity_with_equal_elements_must_return_as_expected(): element_type = ElementType('xsd:string') name_elem = Element(name='Name', element_type=element_type) surname_elem = Element(name='Surname', element_type=element_type) first = ElementType(name='Contract', children=[name_elem, surname_elem]) first.annotation = 'foo' second = ElementType(name='Contract', children=[name_elem, surname_elem]) second.annotation = 'foo' assert first.similarity(second) == 1.0
def test_element_fill_with_must_copy_all_data_from_other_element(): 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]) f.annotation = 'A simple documentation for type' f2 = ElementType('') f2.fill_with(f) assert f2.name == f.name assert f2.children == f.children assert f2.annotation == 'A simple documentation for type' assert f2.children_original_order == f.children_original_order