Esempio n. 1
0
def test_resource_to_struct_references_are_resolved_for_the_current_scope():
    root = _create_tree_resource_to_struct(actual="Struct", reference="Struct")
    assert_is_instance(root.find('.ns.Archive.resource.@Struct'),
                       refs.StructureReference)
    resolve_references(root)
    assert_is_instance(root.find('.ns.Archive.resource.@@ns@Struct'),
                       refs.StructureReference)
Esempio n. 2
0
def test_resource_to_field_references_are_resolved():
    root = _create_tree_with_explicit_reference("Archive.resource2")
    assert_is_instance(root.find('.ns.Archive.resource.@Struct@Field'),
                       refs.FieldReference)
    resolve_references(root)
    assert_is_instance(root.find('.ns.Archive.resource.@@ns@Struct@Field'),
                       refs.FieldReference)
Esempio n. 3
0
def _assert_missing_symbol_is_thrown(root, message):
    try:
        resolve_references(root)
    except errors.MissingSymbol as e:
        assert_equal(message, str(e))
    else:
        assert_false(True, "MissingSymbol was not thrown")
Esempio n. 4
0
def test_resource_to_archive_references_are_resolved():
    root = _create_tree_resource_to_archive()
    assert_is_instance(root.find('.ns.Archive.resource.@RefArchive'),
                       refs.ArchiveReference)
    resolve_references(root)
    assert_is_instance(root.find('.ns.Archive.resource.@@ns@RefArchive'),
                       refs.ArchiveReference)
Esempio n. 5
0
def test_resource_to_resource_references_are_resolved_for_parent_scope():
    root = _create_tree_with_explicit_reference("resource2")
    assert_is_instance(root.find('.ns.Archive.resource.@resource2'),
                       refs.ResourceReference)
    resolve_references(root)
    assert_is_instance(
        root.find('.ns.Archive.resource.@@ns@Archive@resource2'),
        refs.ResourceReference)
Esempio n. 6
0
def test_resource_to_struct_references_are_verified_if_global_path_is_specified(
):
    root = _create_tree_resource_to_struct_with_extra_folding(
        "Struct", ".ns.fold.Struct")
    assert_is_instance(root.find('.ns.Archive.resource.@@ns@fold@Struct'),
                       refs.StructureReference)
    resolve_references(root)
    assert_is_instance(root.find('.ns.Archive.resource.@@ns@fold@Struct'),
                       refs.StructureReference)
Esempio n. 7
0
def test_implicit_references_structure_is_resolved():
    root = Root().insert(
        nodes.Namespace("n").insert(
            Archive("A").insert(
                res.Vector("r1"), res.Vector("r2"),
                res.BoundResource("b").insert(
                    refs.ResourceReference("A.r1"),
                    refs.ResourceReference("A.r2")))))
    resolve_references(root)
    assert_equal("@@n@A@r1", root.find('.n.A.b').children[0].name)
    assert_equal("@@n@A@r2", root.find('.n.A.b').children[1].name)
Esempio n. 8
0
def test_resolved_references_appear_in_original_order():
    root = _create_tree_with_two_struct_references()
    resolve_references(root)
    assert_equal("@@ns@S1", root.find('.ns.Archive.resource').children[0].name)
    assert_equal("@@ns@S2", root.find('.ns.Archive.resource').children[1].name)