def test_link_dxf_object_to_dictionary():
    from ezdxf.entities import DXFObject

    dictionary = Dictionary.new(handle="ABBA")
    obj = DXFObject.new(handle="FEFE")
    dictionary.link_dxf_object("MyEntry", obj)
    assert "MyEntry" in dictionary
    assert obj.dxf.owner == "ABBA"
 def test_fully_manual_dictionary_copy(self, source: Dictionary):
     doc = source.doc
     # manual copy procedure:
     copy = source.copy()
     factory.bind(copy, doc)
     doc.objects.add_object(copy)
     # this is all done automatically if you use:
     # doc.entitydb.duplicate_entity(source)
     assert copy in doc.objects
     assert factory.is_bound(copy, doc)
    def test_copy_sub_dictionary(self, source: Dictionary):
        doc = source.doc
        source = doc.entitydb.duplicate_entity(source)
        sub_dict = source.add_new_dict("SUBDICT", hard_owned=True)
        sub_dict.add_dict_var("SUBDICTVAR", "SubVarContent")
        copy = doc.entitydb.duplicate_entity(source)

        sub_dict_copy = copy["SUBDICT"]
        assert sub_dict is not sub_dict_copy
        assert sub_dict["SUBDICTVAR"] is not sub_dict_copy["SUBDICTVAR"]
        assert factory.is_bound(sub_dict_copy, doc) is True
        assert factory.is_bound(sub_dict_copy["SUBDICTVAR"], doc) is True
 def test_objects_are_not_owned_by_copy(self, source: Dictionary):
     copy = source.copy()
     assert copy["DICTVAR"].dxf.owner != copy.dxf.handle
     assert copy["XRECORD"].dxf.owner != copy.dxf.handle
 def test_objects_are_not_copied(self, source: Dictionary):
     copy = source.copy()
     assert copy["DICTVAR"] is source["DICTVAR"]
     assert copy["XRECORD"] is source["XRECORD"]
 def test_objects_exist(self, source: Dictionary):
     copy = source.copy()
     assert isinstance(copy["DICTVAR"], DictionaryVar)
     assert isinstance(copy["XRECORD"], XRecord)
 def test_keys_are_copied(self, source: Dictionary):
     copy = source.copy()
     assert "DICTVAR" in copy
     assert "XRECORD" in copy
 def test_copied_objects_are_not_bound_to_document(self,
                                                   source: Dictionary):
     copy = source.copy()
     assert factory.is_bound(copy["DICTVAR"], source.doc) is False
     assert factory.is_bound(copy["XRECORD"], source.doc) is False
 def dxfdict(self):
     d = Dictionary.from_text(ROOTDICT, doc=MockDoc())
     return d
def test_dictionary_loads_owner_tag():
    d = Dictionary.from_text(WITH_OWNER_TAG)
    assert d.dxf.owner == "FEFE"
def test_do_not_recover_owner_tag_at_loading_stage():
    # this is the task of the audit process and breaks otherwise the
    # recover mode for test file: "ProE_AC1018.dxf"
    d = Dictionary.from_text(WITHOUT_OWNER_TAG)
    assert d.dxf.hasattr("owner") is False
 def dxfdict(self):
     return Dictionary.from_text(EMPTY_DICT, doc=MockDoc())