Ejemplo n.º 1
0
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"
Ejemplo n.º 2
0
 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)
Ejemplo n.º 3
0
    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
Ejemplo n.º 4
0
 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
Ejemplo n.º 5
0
 def test_objects_are_not_copied(self, source: Dictionary):
     copy = source.copy()
     assert copy["DICTVAR"] is source["DICTVAR"]
     assert copy["XRECORD"] is source["XRECORD"]
Ejemplo n.º 6
0
 def test_objects_exist(self, source: Dictionary):
     copy = source.copy()
     assert isinstance(copy["DICTVAR"], DictionaryVar)
     assert isinstance(copy["XRECORD"], XRecord)
Ejemplo n.º 7
0
 def test_keys_are_copied(self, source: Dictionary):
     copy = source.copy()
     assert "DICTVAR" in copy
     assert "XRECORD" in copy
Ejemplo n.º 8
0
 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
Ejemplo n.º 9
0
 def dxfdict(self):
     d = Dictionary.from_text(ROOTDICT, doc=MockDoc())
     return d
Ejemplo n.º 10
0
def test_dictionary_loads_owner_tag():
    d = Dictionary.from_text(WITH_OWNER_TAG)
    assert d.dxf.owner == "FEFE"
Ejemplo n.º 11
0
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
Ejemplo n.º 12
0
 def dxfdict(self):
     return Dictionary.from_text(EMPTY_DICT, doc=MockDoc())