def test_link_from_ref__name_prefix_suffix_no_id(context_mock): ref = TypeRef("lang") ref.name = "MyType" ref.prefix = "const " ref.suffix = " &" assert link_from_ref(ref, context_mock) == "const MyType &" context_mock.assert_not_called()
def test_link_from_ref__strip_surrounding_whitespace(context_mock): ref = TypeRef("lang") ref.name = "MyType" ref.prefix = " const " ref.suffix = " & " ref.id = "lang-tomtom_1_MyType" assert link_from_ref(ref, context_mock) == "const xref:lang-tomtom_1_MyType[MyType] &" context_mock.link_to_element.assert_called_once_with(ref.id, ref.name)
def test_link_from_ref__nested_types(context_mock): nested_type_with_id = TypeRef("lang") nested_type_with_id.name = "Nested1" nested_type_with_id.id = "lang-nested1" nested_type_without_id = TypeRef("lang") nested_type_without_id.name = "Nested2" ref = TypeRef("lang") ref.name = "MyType" ref.prefix = "const " ref.suffix = " &" ref.id = "lang-tomtom_1_MyType" ref.nested = [nested_type_with_id, nested_type_without_id] assert (link_from_ref(ref, context_mock) == "const xref:lang-tomtom_1_MyType[MyType]<xref:lang-nested1[Nested1], Nested2> &") context_mock.link_to_element.assert_has_calls( [call(nested_type_with_id.id, nested_type_with_id.name), call(ref.id, ref.name)])
def test_link_from_ref__name_only(context_mock): ref = TypeRef("lang") ref.name = "MyType" assert link_from_ref(ref, context_mock) == "MyType" context_mock.assert_not_called()
def test_link_from_ref__none(context_mock): assert link_from_ref(None, context_mock) == "" context_mock.assert_not_called()
def test_link_from_ref__empty(context_mock): ref = TypeRef("lang") assert link_from_ref(ref, context_mock) == "" context_mock.assert_not_called()