Tests for external svg references

This commit is contained in:
Andrej730
2023-06-02 12:01:02 +05:00
parent 1488ae40ee
commit fa4e19eba7
5 changed files with 122 additions and 9 deletions
+70 -2
View File
@@ -217,12 +217,80 @@ class TestOpenSchedule:
class TestUpdateScheduleName:
def test_do_not_update_if_name_unchanged(self, ifc, drawing):
drawing.get_name("schedule").should_be_called().will_return("name")
subject.update_schedule_name(ifc, drawing, schedule="schedule", name="name")
subject.update_document_name(ifc, drawing, document="schedule", name="name")
def test_run(self, ifc, drawing):
drawing.get_name("schedule").should_be_called().will_return("oldname")
ifc.run("document.edit_information", information="schedule", attributes={"Name": "name"}).should_be_called()
subject.update_schedule_name(ifc, drawing, schedule="schedule", name="name")
subject.update_document_name(ifc, drawing, document="schedule", name="name")
class TestLoadReferences:
def test_run(self, drawing):
drawing.import_documents("REFERENCE").should_be_called()
drawing.enable_editing_references().should_be_called()
subject.load_references(drawing)
class TestDisableEditingReferences:
def test_run(self, drawing):
drawing.disable_editing_references().should_be_called()
subject.disable_editing_references(drawing)
class TestAddReference:
def test_run(self, ifc, drawing):
ifc.run("document.add_information").should_be_called().will_return("reference")
drawing.get_path_filename("uri").should_be_called().will_return("UNTITLED")
ifc.run("document.add_reference", information="reference").should_be_called().will_return("reference")
ifc.get_schema().should_be_called().will_return("IFC4")
ifc.run(
"document.edit_information",
information="reference",
attributes={"Identification": "X", "Name": "UNTITLED", "Scope": "REFERENCE"},
).should_be_called()
ifc.run("document.edit_reference", reference="reference", attributes={"Location": "uri"}).should_be_called()
drawing.import_documents("REFERENCE").should_be_called()
subject.add_document(ifc, drawing, "REFERENCE", uri="uri")
def test_using_a_document_id_in_ifc2x3(self, ifc, drawing):
ifc.run("document.add_information").should_be_called().will_return("reference")
drawing.get_path_filename("uri").should_be_called().will_return("UNTITLED")
ifc.run("document.add_reference", information="reference").should_be_called().will_return("reference")
ifc.get_schema().should_be_called().will_return("IFC2X3")
ifc.run(
"document.edit_information",
information="reference",
attributes={"DocumentId": "X", "Name": "UNTITLED", "Scope": "REFERENCE"},
).should_be_called()
ifc.run("document.edit_reference", reference="reference", attributes={"Location": "uri"}).should_be_called()
drawing.import_documents("REFERENCE").should_be_called()
subject.add_document(ifc, drawing, "REFERENCE", uri="uri")
class TestRemoveReference:
def test_run(self, ifc, drawing):
ifc.run("document.remove_information", information="reference").should_be_called()
drawing.import_documents("REFERENCE").should_be_called()
subject.remove_document(ifc, drawing, "REFERENCE", document="reference")
class TestOpenReference:
def test_run(self, drawing):
drawing.get_document_uri("reference").should_be_called().will_return("uri")
drawing.open_svg("uri").should_be_called()
subject.open_reference(drawing, reference="reference")
class TestUpdateReferenceName:
def test_do_not_update_if_name_unchanged(self, ifc, drawing):
drawing.get_name("reference").should_be_called().will_return("name")
subject.update_document_name(ifc, drawing, document="reference", name="name")
def test_run(self, ifc, drawing):
drawing.get_name("reference").should_be_called().will_return("oldname")
ifc.run("document.edit_information", information="reference", attributes={"Name": "name"}).should_be_called()
subject.update_document_name(ifc, drawing, document="reference", name="name")
class TestLoadDrawings:
+43
View File
@@ -120,6 +120,13 @@ class TestDisableEditingSchedules(NewFile):
assert bpy.context.scene.DocProperties.is_editing_schedules == False
class TestDisableEditingReferences(NewFile):
def test_run(self):
bpy.context.scene.DocProperties.is_editing_references = True
subject.disable_editing_references()
assert bpy.context.scene.DocProperties.is_editing_references == False
class TestDisableEditingSheets(NewFile):
def test_run(self):
bpy.context.scene.DocProperties.is_editing_sheets = True
@@ -165,6 +172,13 @@ class TestEnableEditingSchedules(NewFile):
assert bpy.context.scene.DocProperties.is_editing_schedules == True
class TestEnableEditingReferences(NewFile):
def test_run(self):
bpy.context.scene.DocProperties.is_editing_references = False
subject.enable_editing_references()
assert bpy.context.scene.DocProperties.is_editing_references == True
class TestEnableEditingSheets(NewFile):
def test_run(self):
bpy.context.scene.DocProperties.is_editing_sheets = False
@@ -497,6 +511,30 @@ class TestImportSchedules(NewFile):
assert props.schedules[0].name == "FOOBAR"
class TestImportReferences(NewFile):
def test_run(self):
ifc = ifcopenshell.file()
tool.Ifc.set(ifc)
ifc.createIfcDocumentInformation(Identification="Y", Name="FOOBAZ")
document = ifc.createIfcDocumentInformation(Identification="X", Name="FOOBAR", Scope="REFERENCE")
subject.import_documents("REFERENCE")
props = bpy.context.scene.DocProperties
assert props.references[0].ifc_definition_id == document.id()
assert props.references[0].identification == "X"
assert props.references[0].name == "FOOBAR"
def test_run_ifc2x3(self):
ifc = ifcopenshell.file(schema="IFC2X3")
tool.Ifc.set(ifc)
ifc.createIfcDocumentInformation(DocumentId="Y", Name="FOOBAZ")
document = ifc.createIfcDocumentInformation(DocumentId="X", Name="FOOBAR", Scope="REFERENCE")
subject.import_documents("REFERENCE")
props = bpy.context.scene.DocProperties
assert props.references[0].ifc_definition_id == document.id()
assert props.references[0].identification == "X"
assert props.references[0].name == "FOOBAR"
class TestImportSheets(NewFile):
def test_run(self):
ifc = ifcopenshell.file()
@@ -570,6 +608,11 @@ class TestOpenSchedule(NewFile):
pass
class TestOpenReference(NewFile):
def open_svg(self):
pass
class TestOpenSvg(NewFile):
def test_nothing(self):
pass