Fix more failing tests.

This commit is contained in:
Dion Moult
2023-08-24 23:03:36 +10:00
parent 7b52e359f2
commit feec0e2437
6 changed files with 48 additions and 20 deletions
+1
View File
@@ -241,6 +241,7 @@ class Drawing:
def activate_drawing(cls, camera): pass
def add_literal_to_annotation(cls, obj, Literal='Literal', Path='RIGHT', BoxAlignment='bottom-left'): pass
def copy_representation(cls, source, dest): pass
def create_annotation_context(cls, target_view, object_type=None): pass
def create_annotation_object(cls, drawing, object_type): pass
def create_camera(cls, name, matrix): pass
def create_svg_schedule(cls, schedule): pass
+1 -1
View File
@@ -475,7 +475,7 @@ class Drawing(blenderbim.core.tool.Drawing):
m[2][2] = -1
m.translation = (x, y, z + 1.6)
return m
return mathutils.Matrix(((-1, 0, 0, 0), (0, 1, 0, 0), (0, 0, -1, 0), (0, 0, 0, 1)))
return mathutils.Matrix(((1, 0, 0, 0), (0, 1, 0, 0), (0, 0, -1, 0), (0, 0, 0, 1)))
elif target_view == "ELEVATION_VIEW":
if location_hint == "NORTH":
return mathutils.Matrix(((-1, 0, 0, x), (0, 0, 1, y), (0, 1, 0, z), (0, 0, 0, 1)))
+8 -8
View File
@@ -32,16 +32,16 @@ subprocess.call([py_exec, "-m", "pip", "install", "--upgrade", "pip"])
sys_paths = [p for p in sys.path if "site-packages" in p]
if sys_paths:
print("Detected installation directory:", sys_paths[-1])
subprocess.call([py_exec, "-m", "pip", "install", f"--target={sys_paths[-1]}", "pytest"])
subprocess.call([py_exec, "-m", "pip", "install", f"--target={sys_paths[-1]}", "pytest-bdd"])
subprocess.call([py_exec, "-m", "pip", "install", f"--target={sys_paths[-1]}", "pytest-blender"])
subprocess.call([py_exec, "-m", "pip", "install", f"--target={sys_paths[-1]}", "pygments"])
subprocess.call([py_exec, "-m", "pip", "install", f"--target={sys_paths[-1]}", "--upgrade", "pytest"])
subprocess.call([py_exec, "-m", "pip", "install", f"--target={sys_paths[-1]}", "--upgrade", "pytest-bdd"])
subprocess.call([py_exec, "-m", "pip", "install", f"--target={sys_paths[-1]}", "--upgrade", "pytest-blender"])
subprocess.call([py_exec, "-m", "pip", "install", f"--target={sys_paths[-1]}", "--upgrade", "pygments"])
else:
print("Could not detect installation directory. Good luck.")
subprocess.call([py_exec, "-m", "pip", "install", "pytest"])
subprocess.call([py_exec, "-m", "pip", "install", "pytest-bdd"])
subprocess.call([py_exec, "-m", "pip", "install", "pytest-blender"])
subprocess.call([py_exec, "-m", "pip", "install", "pygments"])
subprocess.call([py_exec, "-m", "pip", "install", "--upgrade", "pytest"])
subprocess.call([py_exec, "-m", "pip", "install", "--upgrade", "pytest-bdd"])
subprocess.call([py_exec, "-m", "pip", "install", "--upgrade", "pytest-blender"])
subprocess.call([py_exec, "-m", "pip", "install", "--upgrade", "pygments"])
try:
import pytest
+20 -3
View File
@@ -490,7 +490,7 @@ class TestUpdateDrawingName:
)
ifc.resolve_uri("relative_layout_uri").should_be_called().will_return("absolute_layout_uri")
drawing.does_file_exist("absolute_layout_uri").should_be_called().will_return(True)
drawing.update_embedded_svg_location("absolute_layout_uri", "old_location", "new_location").should_be_called()
drawing.update_embedded_svg_location("absolute_layout_uri", "reference_with_old_location", "new_uri").should_be_called()
drawing.is_editing_sheets().should_be_called().will_return(True)
drawing.import_sheets().should_be_called()
@@ -500,9 +500,9 @@ class TestUpdateDrawingName:
class TestAddAnnotation:
def test_run(self, ifc, collector, drawing):
drawing.show_decorations().should_be_called()
drawing.get_drawing_target_view("drawing").should_be_called().will_return("target_view")
drawing.get_annotation_context("target_view", "object_type").should_be_called().will_return("context")
drawing.show_decorations().should_be_called()
drawing.create_annotation_object("drawing", "object_type").should_be_called().will_return("obj")
ifc.get_entity("obj").should_be_called().will_return(None)
drawing.get_ifc_representation_class("object_type").should_be_called().will_return("ifc_representation_class")
@@ -520,7 +520,24 @@ class TestAddAnnotation:
drawing.enable_editing("obj").should_be_called()
subject.add_annotation(ifc, collector, drawing, drawing="drawing", object_type="object_type")
def test_do_not_add_without_an_annotation_context(self, ifc, collector, drawing):
def test_create_a_missing_annotation_context_on_the_fly(self, ifc, collector, drawing):
drawing.get_drawing_target_view("drawing").should_be_called().will_return("target_view")
drawing.get_annotation_context("target_view", "object_type").should_be_called().will_return(None)
drawing.create_annotation_context("target_view", "object_type").should_be_called().will_return("context")
drawing.show_decorations().should_be_called()
drawing.create_annotation_object("drawing", "object_type").should_be_called().will_return("obj")
ifc.get_entity("obj").should_be_called().will_return(None)
drawing.get_ifc_representation_class("object_type").should_be_called().will_return("ifc_representation_class")
drawing.run_root_assign_class(
obj="obj",
ifc_class="IfcAnnotation",
predefined_type="object_type",
should_add_representation=True,
context="context",
ifc_representation_class="ifc_representation_class",
).should_be_called().will_return("element")
drawing.get_drawing_group("drawing").should_be_called().will_return("group")
ifc.run("group.assign_group", group="group", products=["element"]).should_be_called()
collector.assign("obj").should_be_called()
drawing.enable_editing("obj").should_be_called()
subject.add_annotation(ifc, collector, drawing, drawing="drawing", object_type="object_type")
+14 -5
View File
@@ -376,7 +376,7 @@ class TestGenerateDrawingMatrix(NewFile):
def test_creating_an_rcp_at_the_origin(self):
assert subject.generate_drawing_matrix("REFLECTED_PLAN_VIEW", None) == mathutils.Matrix(
((-1, 0, 0, 0), (0, 1, 0, 0), (0, 0, -1, 0), (0, 0, 0, 1))
((1, 0, 0, 0), (0, 1, 0, 0), (0, 0, -1, 0), (0, 0, 0, 1))
)
def test_creating_an_rcp_at_the_cursor_at_a_storey(self):
@@ -389,7 +389,7 @@ class TestGenerateDrawingMatrix(NewFile):
obj.matrix_world[2][3] = 3
bpy.context.scene.cursor.location = (1.0, 2.0, 0.0)
assert subject.generate_drawing_matrix("REFLECTED_PLAN_VIEW", element.id()) == mathutils.Matrix(
((-1, 0, 0, 1), (0, 1, 0, 2), (0, 0, -1, 3 + 1.6), (0, 0, 0, 1))
((1, 0, 0, 1), (0, 1, 0, 2), (0, 0, -1, 3 + 1.6), (0, 0, 0, 1))
)
def test_creating_a_north_elevation_at_the_cursor(self):
@@ -485,9 +485,12 @@ class TestImportDrawings(NewFile):
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"TargetView": "PLAN_VIEW"})
subject.import_drawings()
props = bpy.context.scene.DocProperties
assert props.drawings[0].ifc_definition_id == drawing.id()
assert props.drawings[0].name == "FOOBAR"
assert props.drawings[0].target_view == "PLAN_VIEW"
for d in props.drawings:
d.is_expanded = True
subject.import_drawings()
assert props.drawings[1].target_view == "PLAN_VIEW"
assert props.drawings[2].ifc_definition_id == drawing.id()
assert props.drawings[2].name == "FOOBAR"
class TestImportSchedules(NewFile):
@@ -668,6 +671,7 @@ class TestDrawingMaintainingSheetPosition(NewFile):
return drawing_data
def test_run(self):
props = bpy.context.scene.DocProperties
bpy.ops.bim.create_project()
ifc = tool.Ifc.get()
sheet_path = Path.cwd() / "layouts" / "A00 - UNTITLED.svg"
@@ -676,9 +680,14 @@ class TestDrawingMaintainingSheetPosition(NewFile):
bpy.ops.bim.add_sheet()
bpy.ops.bim.load_drawings()
for d in props.drawings:
d.is_expanded = True
bpy.ops.bim.add_drawing()
drawing = ifc.by_type("IfcAnnotation")[0]
for i, d in enumerate(props.drawings):
if d.ifc_definition_id == drawing.id():
props.active_drawing_index = i
bpy.ops.bim.activate_drawing(drawing=drawing.id())
bpy.ops.bim.create_drawing()
bpy.ops.bim.add_drawing_to_sheet()
+4 -3
View File
@@ -160,11 +160,12 @@ class TestSetObjectName(NewFile):
obj = bpy.data.objects.new("Object", bpy.data.meshes.new("Mesh"))
element = ifc.createIfcWall()
subject.set_object_name(obj, element)
assert obj.name == "IfcWall/Object"
assert obj.name == "IfcWall/Unnamed"
def test_existing_ifc_prefixes_are_not_repeated(self):
def test_existing_blender_names_are_ignored(self):
ifc = ifcopenshell.file()
obj = bpy.data.objects.new("IfcSlab/Object", bpy.data.meshes.new("Mesh"))
element = ifc.createIfcWall()
element.Name = "Foobar"
subject.set_object_name(obj, element)
assert obj.name == "IfcWall/Object"
assert obj.name == "IfcWall/Foobar"