BIM: add first iteration of unit tests

This commit is contained in:
Furgo
2025-05-08 21:22:19 +02:00
committed by Yorik van Havre
parent e9d0f287f2
commit 0e22d16a56
26 changed files with 1160 additions and 193 deletions

View File

@@ -198,11 +198,31 @@ SET(nativeifc_SRCS
)
SET(bimtests_SRCS
bimtests/TestArch.py
bimtests/TestArchAxis.py
bimtests/TestArchBase.py
bimtests/TestArchComponent.py
bimtests/TestArchBuildingPart.py
bimtests/TestArchRoof.py
bimtests/TestArchSpace.py
bimtests/TestArchWall.py
bimtests/TestArchMaterial.py
bimtests/TestArchPanel.py
bimtests/TestArchWindow.py
bimtests/TestArchStairs.py
bimtests/TestArchPipe.py
bimtests/TestArchCurtainWall.py
bimtests/TestArchProfile.py
bimtests/TestArchProject.py
bimtests/TestArchSectionPlane.py
bimtests/TestArchRebar.py
bimtests/TestArchGrid.py
bimtests/TestArchFence.py
bimtests/TestArchEquipment.py
bimtests/TestArchFrame.py
bimtests/TestArchReference.py
bimtests/TestArchSchedule.py
bimtests/TestArchTruss.py
)
SOURCE_GROUP("" FILES ${Arch_SRCS})

View File

@@ -23,198 +23,28 @@
# ***************************************************************************
# Unit test for the Arch module
import os
import unittest
import FreeCAD as App
import Arch
import Draft
import Part
import Sketcher
import TechDraw
import WorkingPlane
from bimtests.TestArchRoof import TestArchRoof
from bimtests.TestArchSpace import TestArchSpace
from bimtests.TestArchWall import TestArchWall
from bimtests.TestArchBuildingPart import TestArchBuildingPart
from bimtests.TestArchAxis import TestArchAxis
from bimtests.TestArch import TestArch
from bimtests.TestArchMaterial import TestArchMaterial
from bimtests.TestArchPanel import TestArchPanel
from bimtests.TestArchWindow import TestArchWindow
from bimtests.TestArchStairs import TestArchStairs
from bimtests.TestArchPipe import TestArchPipe
from bimtests.TestArchCurtainWall import TestArchCurtainWall
from bimtests.TestArchProfile import TestArchProfile
from bimtests.TestArchProject import TestArchProject
from bimtests.TestArchSectionPlane import TestArchSectionPlane
from bimtests.TestArchRebar import TestArchRebar
from bimtests.TestArchGrid import TestArchGrid
from bimtests.TestArchFence import TestArchFence
from bimtests.TestArchEquipment import TestArchEquipment
from bimtests.TestArchFrame import TestArchFrame
from bimtests.TestArchReference import TestArchReference
from bimtests.TestArchSchedule import TestArchSchedule
from bimtests.TestArchTruss import TestArchTruss
from bimtests.TestArchComponent import TestArchComponent
from draftutils.messages import _msg
class ArchTest(unittest.TestCase):
def setUp(self):
# setting a new document to hold the tests
if App.ActiveDocument:
if App.ActiveDocument.Name != "ArchTest":
App.newDocument("ArchTest")
else:
App.newDocument("ArchTest")
App.setActiveDocument("ArchTest")
def testStructure(self):
App.Console.PrintLog ('Checking BIM Structure...\n')
s = Arch.makeStructure(length=2,width=3,height=5)
self.assertTrue(s,"BIM Structure failed")
def testFloor(self):
App.Console.PrintLog ('Checking Arch Floor...\n')
s = Arch.makeStructure(length=2,width=3,height=5)
f = Arch.makeFloor([s])
self.assertTrue(f,"Arch Floor failed")
def testBuilding(self):
App.Console.PrintLog ('Checking Arch Building...\n')
s = Arch.makeStructure(length=2,width=3,height=5)
f = Arch.makeFloor([s])
b = Arch.makeBuilding([f])
self.assertTrue(b,"Arch Building failed")
def testSite(self):
App.Console.PrintLog ('Checking Arch Site...\n')
s = Arch.makeStructure(length=2,width=3,height=5)
f = Arch.makeFloor([s])
b = Arch.makeBuilding([f])
si = Arch.makeSite([b])
self.assertTrue(si,"Arch Site failed")
def testWindow(self):
operation = "Arch Window"
_msg(" Test '{}'".format(operation))
line = Draft.makeLine(App.Vector(0, 0, 0), App.Vector(3000, 0, 0))
wall = Arch.makeWall(line)
sk = App.ActiveDocument.addObject("Sketcher::SketchObject", "Sketch001")
sk.Placement.Rotation = App.Rotation(App.Vector(1, 0, 0), 90)
sk.addGeometry(Part.LineSegment(App.Vector( 500, 800, 0), App.Vector(1500, 800, 0)))
sk.addGeometry(Part.LineSegment(App.Vector(1500, 800, 0), App.Vector(1500, 2000, 0)))
sk.addGeometry(Part.LineSegment(App.Vector(1500, 2000, 0), App.Vector( 500, 2000, 0)))
sk.addGeometry(Part.LineSegment(App.Vector( 500, 2000, 0), App.Vector( 500, 800, 0)))
sk.addConstraint(Sketcher.Constraint('Coincident', 0, 2, 1, 1))
sk.addConstraint(Sketcher.Constraint('Coincident', 1, 2, 2, 1))
sk.addConstraint(Sketcher.Constraint('Coincident', 2, 2, 3, 1))
sk.addConstraint(Sketcher.Constraint('Coincident', 3, 2, 0, 1))
App.ActiveDocument.recompute()
win = Arch.makeWindow(sk)
Arch.removeComponents(win, host=wall)
App.ActiveDocument.recompute()
self.assertTrue(win, "'{}' failed".format(operation))
def testAxis(self):
App.Console.PrintLog ('Checking Arch Axis...\n')
a = Arch.makeAxis()
self.assertTrue(a,"Arch Axis failed")
def testSection(self):
App.Console.PrintLog ('Checking Arch Section...\n')
s = Arch.makeSectionPlane([])
self.assertTrue(s,"Arch Section failed")
def testStairs(self):
App.Console.PrintLog ('Checking Arch Stairs...\n')
s = Arch.makeStairs()
self.assertTrue(s,"Arch Stairs failed")
def testFrame(self):
App.Console.PrintLog ('Checking Arch Frame...\n')
l=Draft.makeLine(App.Vector(0,0,0),App.Vector(-2,0,0))
p = Draft.makeRectangle(length=.5,height=.5)
f = Arch.makeFrame(l,p)
self.assertTrue(f,"Arch Frame failed")
def testEquipment(self):
App.Console.PrintLog ('Checking Arch Equipment...\n')
box = App.ActiveDocument.addObject("Part::Box", "Box")
box.Length = 500
box.Width = 2000
box.Height = 600
equip = Arch.makeEquipment(box)
self.assertTrue(equip,"Arch Equipment failed")
def testPipe(self):
App.Console.PrintLog ('Checking Arch Pipe...\n')
pipe = Arch.makePipe(diameter=120, length=3000)
self.assertTrue(pipe,"Arch Pipe failed")
def testAdd(self):
App.Console.PrintLog ('Checking Arch Add...\n')
l=Draft.makeLine(App.Vector(0,0,0),App.Vector(2,0,0))
w = Arch.makeWall(l,width=0.2,height=2)
sb = Part.makeBox(1,1,1)
b = App.ActiveDocument.addObject('Part::Feature','Box')
b.Shape = sb
App.ActiveDocument.recompute()
Arch.addComponents(b,w)
App.ActiveDocument.recompute()
r = (w.Shape.Volume > 1.5)
self.assertTrue(r,"Arch Add failed")
def testRemove(self):
App.Console.PrintLog ('Checking Arch Remove...\n')
l=Draft.makeLine(App.Vector(0,0,0),App.Vector(2,0,0))
w = Arch.makeWall(l,width=0.2,height=2,align="Right")
sb = Part.makeBox(1,1,1)
b = App.ActiveDocument.addObject('Part::Feature','Box')
b.Shape = sb
App.ActiveDocument.recompute()
Arch.removeComponents(b,w)
App.ActiveDocument.recompute()
r = (w.Shape.Volume < 0.75)
self.assertTrue(r,"Arch Remove failed")
def testViewGeneration(self):
"""Tests the whole TD view generation workflow"""
operation = "View generation"
_msg(" Test '{}'".format(operation))
# Create a few objects
points = [App.Vector(0.0, 0.0, 0.0), App.Vector(2000.0, 0.0, 0.0)]
line = Draft.make_wire(points)
wall = Arch.makeWall(line, height=2000)
wpl = App.Placement(App.Vector(500,0,1500), App.Vector(1,0,0),-90)
win = Arch.makeWindowPreset('Fixed', width=1000.0, height=1000.0, h1=50.0, h2=50.0, h3=50.0, w1=100.0, w2=50.0, o1=0.0, o2=50.0, placement=wpl)
win.Hosts = [wall]
profile = Arch.makeProfile([169, 'HEA', 'HEA100', 'H', 100.0, 96.0, 5.0, 8.0])
column = Arch.makeStructure(profile, height=2000.0)
column.Profile = "HEA100"
column.Placement.Base = App.Vector(500.0, 600.0, 0.0)
level = Arch.makeFloor()
level.addObjects([wall, column])
App.ActiveDocument.recompute()
# Create a drawing view
section = Arch.makeSectionPlane(level)
drawing = Arch.make2DDrawing()
view = Draft.make_shape2dview(section)
cut = Draft.make_shape2dview(section)
cut.InPlace = False
cut.ProjectionMode = "Cutfaces"
drawing.addObjects([view, cut])
App.ActiveDocument.recompute()
# Create a TD page
tpath = os.path.join(App.getResourceDir(),"Mod","TechDraw","Templates","A3_Landscape_blank.svg")
page = App.ActiveDocument.addObject("TechDraw::DrawPage", "Page")
template = App.ActiveDocument.addObject("TechDraw::DrawSVGTemplate", "Template")
template.Template = tpath
page.Template = template
view = App.ActiveDocument.addObject("TechDraw::DrawViewDraft", "DraftView")
view.Source = drawing
page.addView(view)
view.Scale = 1.0
view.X = "20cm"
view.Y = "15cm"
App.ActiveDocument.recompute()
assert True
def tearDown(self):
App.closeDocument("ArchTest")
pass
# Use the modules so that code checkers don't complain (flake8)
True if TestArchSpace else False
True if TestArchRoof else False
True if TestArchWall else False
True if TestArchComponent else False

View File

@@ -0,0 +1,171 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
# ***************************************************************************
# * *
# * Copyright (c) 2013 Yorik van Havre <yorik@uncreated.net> *
# * Copyright (c) 2025 Furgo *
# * *
# * This file is part of FreeCAD. *
# * *
# * FreeCAD is free software: you can redistribute it and/or modify it *
# * under the terms of the GNU Lesser General Public License as *
# * published by the Free Software Foundation, either version 2.1 of the *
# * License, or (at your option) any later version. *
# * *
# * FreeCAD is distributed in the hope that it will be useful, but *
# * WITHOUT ANY WARRANTY; without even the implied warranty of *
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
# * Lesser General Public License for more details. *
# * *
# * You should have received a copy of the GNU Lesser General Public *
# * License along with FreeCAD. If not, see *
# * <https://www.gnu.org/licenses/>. *
# * *
# ***************************************************************************
import os
import FreeCAD as App
import Arch
import Draft
import Part
import Sketcher
import Arch
from bimtests import TestArchBase
from draftutils.messages import _msg
# TODO: move these tests to their relevant modules, remove this file
class TestArch(TestArchBase.TestArchBase):
def testStructure(self):
App.Console.PrintLog ('Checking BIM Structure...\n')
s = Arch.makeStructure(length=2,width=3,height=5)
self.assertTrue(s,"BIM Structure failed")
def testWindow(self):
operation = "Arch Window"
_msg(" Test '{}'".format(operation))
line = Draft.makeLine(App.Vector(0, 0, 0), App.Vector(3000, 0, 0))
wall = Arch.makeWall(line)
sk = App.ActiveDocument.addObject("Sketcher::SketchObject", "Sketch001")
sk.Placement.Rotation = App.Rotation(App.Vector(1, 0, 0), 90)
sk.addGeometry(Part.LineSegment(App.Vector( 500, 800, 0), App.Vector(1500, 800, 0)))
sk.addGeometry(Part.LineSegment(App.Vector(1500, 800, 0), App.Vector(1500, 2000, 0)))
sk.addGeometry(Part.LineSegment(App.Vector(1500, 2000, 0), App.Vector( 500, 2000, 0)))
sk.addGeometry(Part.LineSegment(App.Vector( 500, 2000, 0), App.Vector( 500, 800, 0)))
sk.addConstraint(Sketcher.Constraint('Coincident', 0, 2, 1, 1))
sk.addConstraint(Sketcher.Constraint('Coincident', 1, 2, 2, 1))
sk.addConstraint(Sketcher.Constraint('Coincident', 2, 2, 3, 1))
sk.addConstraint(Sketcher.Constraint('Coincident', 3, 2, 0, 1))
App.ActiveDocument.recompute()
win = Arch.makeWindow(sk)
Arch.removeComponents(win, host=wall)
App.ActiveDocument.recompute()
self.assertTrue(win, "'{}' failed".format(operation))
def testAxis(self):
App.Console.PrintLog ('Checking Arch Axis...\n')
a = Arch.makeAxis()
self.assertTrue(a,"Arch Axis failed")
def testSection(self):
App.Console.PrintLog ('Checking Arch Section...\n')
s = Arch.makeSectionPlane([])
self.assertTrue(s,"Arch Section failed")
def testStairs(self):
App.Console.PrintLog ('Checking Arch Stairs...\n')
s = Arch.makeStairs()
self.assertTrue(s,"Arch Stairs failed")
def testFrame(self):
App.Console.PrintLog ('Checking Arch Frame...\n')
l=Draft.makeLine(App.Vector(0,0,0),App.Vector(-2,0,0))
p = Draft.makeRectangle(length=.5,height=.5)
f = Arch.makeFrame(l,p)
self.assertTrue(f,"Arch Frame failed")
def testEquipment(self):
App.Console.PrintLog ('Checking Arch Equipment...\n')
box = App.ActiveDocument.addObject("Part::Box", "Box")
box.Length = 500
box.Width = 2000
box.Height = 600
equip = Arch.makeEquipment(box)
self.assertTrue(equip,"Arch Equipment failed")
def testPipe(self):
App.Console.PrintLog ('Checking Arch Pipe...\n')
pipe = Arch.makePipe(diameter=120, length=3000)
self.assertTrue(pipe,"Arch Pipe failed")
def testAdd(self):
App.Console.PrintLog ('Checking Arch Add...\n')
l=Draft.makeLine(App.Vector(0,0,0),App.Vector(2,0,0))
w = Arch.makeWall(l,width=0.2,height=2)
sb = Part.makeBox(1,1,1)
b = App.ActiveDocument.addObject('Part::Feature','Box')
b.Shape = sb
App.ActiveDocument.recompute()
Arch.addComponents(b,w)
App.ActiveDocument.recompute()
r = (w.Shape.Volume > 1.5)
self.assertTrue(r,"Arch Add failed")
def testRemove(self):
App.Console.PrintLog ('Checking Arch Remove...\n')
l=Draft.makeLine(App.Vector(0,0,0),App.Vector(2,0,0))
w = Arch.makeWall(l,width=0.2,height=2,align="Right")
sb = Part.makeBox(1,1,1)
b = App.ActiveDocument.addObject('Part::Feature','Box')
b.Shape = sb
App.ActiveDocument.recompute()
Arch.removeComponents(b,w)
App.ActiveDocument.recompute()
r = (w.Shape.Volume < 0.75)
self.assertTrue(r,"Arch Remove failed")
def testViewGeneration(self):
"""Tests the whole TD view generation workflow"""
operation = "View generation"
_msg(" Test '{}'".format(operation))
# Create a few objects
points = [App.Vector(0.0, 0.0, 0.0), App.Vector(2000.0, 0.0, 0.0)]
line = Draft.make_wire(points)
wall = Arch.makeWall(line, height=2000)
wpl = App.Placement(App.Vector(500,0,1500), App.Vector(1,0,0),-90)
win = Arch.makeWindowPreset('Fixed', width=1000.0, height=1000.0, h1=50.0, h2=50.0, h3=50.0, w1=100.0, w2=50.0, o1=0.0, o2=50.0, placement=wpl)
win.Hosts = [wall]
profile = Arch.makeProfile([169, 'HEA', 'HEA100', 'H', 100.0, 96.0, 5.0, 8.0])
column = Arch.makeStructure(profile, height=2000.0)
column.Profile = "HEA100"
column.Placement.Base = App.Vector(500.0, 600.0, 0.0)
level = Arch.makeFloor()
level.addObjects([wall, column])
App.ActiveDocument.recompute()
# Create a drawing view
section = Arch.makeSectionPlane(level)
drawing = Arch.make2DDrawing()
view = Draft.make_shape2dview(section)
cut = Draft.make_shape2dview(section)
cut.InPlace = False
cut.ProjectionMode = "Cutfaces"
drawing.addObjects([view, cut])
App.ActiveDocument.recompute()
# Create a TD page
tpath = os.path.join(App.getResourceDir(),"Mod","TechDraw","Templates","A3_Landscape_blank.svg")
page = App.ActiveDocument.addObject("TechDraw::DrawPage", "Page")
template = App.ActiveDocument.addObject("TechDraw::DrawSVGTemplate", "Template")
template.Template = tpath
page.Template = template
view = App.ActiveDocument.addObject("TechDraw::DrawViewDraft", "DraftView")
view.Source = drawing
page.addView(view)
view.Scale = 1.0
view.X = "20cm"
view.Y = "15cm"
App.ActiveDocument.recompute()
assert True

View File

@@ -0,0 +1,62 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
# ***************************************************************************
# * *
# * Copyright (c) 2025 Furgo *
# * *
# * This file is part of FreeCAD. *
# * *
# * FreeCAD is free software: you can redistribute it and/or modify it *
# * under the terms of the GNU Lesser General Public License as *
# * published by the Free Software Foundation, either version 2.1 of the *
# * License, or (at your option) any later version. *
# * *
# * FreeCAD is distributed in the hope that it will be useful, but *
# * WITHOUT ANY WARRANTY; without even the implied warranty of *
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
# * Lesser General Public License for more details. *
# * *
# * You should have received a copy of the GNU Lesser General Public *
# * License along with FreeCAD. If not, see *
# * <https://www.gnu.org/licenses/>. *
# * *
# ***************************************************************************
import FreeCAD as App
import Arch
from bimtests import TestArchBase
class TestArchAxis(TestArchBase.TestArchBase):
def test_make_axis_default(self):
axis = Arch.makeAxis()
self.assertIsNotNone(axis, "Failed to create a default axis")
def test_make_axis_custom(self):
axis = Arch.makeAxis(num=3, size=2000)
self.assertEqual(len(axis.Distances), 3, "Incorrect number of axes created")
self.assertEqual(axis.Distances[1], 2000, "Axis size is incorrect")
def test_axis_properties(self):
axis = Arch.makeAxis()
self.assertEqual(axis.Label, "Axes", "Default label is incorrect")
def test_makeAxis(self):
"""Test the makeAxis function."""
operation = "Testing makeAxis function"
self.printTestMessage(operation)
axis = Arch.makeAxis(num=2, size=500)
self.assertIsNotNone(axis, "makeAxis failed to create an axis object.")
self.assertEqual(axis.Label, "Axes", "Axis label is incorrect.")
def test_makeAxisSystem(self):
"""Test the makeAxisSystem function."""
operation = "Testing makeAxisSystem function"
self.printTestMessage(operation)
axis1 = Arch.makeAxis(num=1, size=1000)
axis2 = Arch.makeAxis(num=1, size=2000)
axis_system = Arch.makeAxisSystem([axis1, axis2], name="TestAxisSystem")
self.assertIsNotNone(axis_system, "makeAxisSystem failed to create an axis system.")
self.assertEqual(axis_system.Label, "TestAxisSystem", "Axis system label is incorrect.")

View File

@@ -30,6 +30,7 @@ import FreeCAD
class TestArchBase(unittest.TestCase):
def setUp(self):
print(f"Initializing: {self.__class__.__name__}")
self.document = FreeCAD.newDocument(self.__class__.__name__)
def tearDown(self):

View File

@@ -0,0 +1,111 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
# ***************************************************************************
# * *
# * Copyright (c) 2013 Yorik van Havre <yorik@uncreated.net> *
# * Copyright (c) 2025 Furgo *
# * *
# * This file is part of FreeCAD. *
# * *
# * FreeCAD is free software: you can redistribute it and/or modify it *
# * under the terms of the GNU Lesser General Public License as *
# * published by the Free Software Foundation, either version 2.1 of the *
# * License, or (at your option) any later version. *
# * *
# * FreeCAD is distributed in the hope that it will be useful, but *
# * WITHOUT ANY WARRANTY; without even the implied warranty of *
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
# * Lesser General Public License for more details. *
# * *
# * You should have received a copy of the GNU Lesser General Public *
# * License along with FreeCAD. If not, see *
# * <https://www.gnu.org/licenses/>. *
# * *
# ***************************************************************************
import FreeCAD as App
import Arch
from bimtests import TestArchBase
class TestArchBuildingPart(TestArchBase.TestArchBase):
def testMakeFloorEmpty(self):
floor = Arch.makeFloor()
self.assertIsNotNone(floor, "Failed to create an empty floor")
def testMakeFloorWithObjects(self):
obj = App.ActiveDocument.addObject("Part::Box", "Box")
floor = Arch.makeFloor([obj])
self.assertIn(obj, floor.Group, "Object not added to the floor")
def testFloorProperties(self):
floor = Arch.makeFloor()
self.assertEqual(floor.Label, "Level", "Default label is incorrect")
def testFloor(self):
App.Console.PrintLog ('Checking Arch Floor...\n')
structure = Arch.makeStructure(length=2, width=3, height=5)
floor = Arch.makeFloor([structure])
self.assertTrue(floor,"Arch Floor failed")
def testBuilding(self):
App.Console.PrintLog ('Checking Arch Building...\n')
structure = Arch.makeStructure(length=2, width=3, height=5)
floor = Arch.makeFloor([structure])
building = Arch.makeBuilding([floor])
self.assertTrue(building, "Arch Building failed")
def testSite(self):
App.Console.PrintLog('Checking Arch Site...\n')
structure = Arch.makeStructure(length=2, width=3, height=5)
floor = Arch.makeFloor([structure])
building = Arch.makeBuilding([floor])
site = Arch.makeSite([building])
self.assertTrue(site, "Arch Site failed")
def test_makeBuildingPart(self):
"""Test the makeBuildingPart function."""
operation = "Testing makeBuildingPart function"
self.printTestMessage(operation)
part = Arch.makeBuildingPart(name="TestBuildingPart")
self.assertIsNotNone(part, "makeBuildingPart failed to create a building part.")
self.assertEqual(part.Label, "TestBuildingPart", "Building part label is incorrect.")
def test_makeFloor(self):
"""Test the makeFloor function."""
operation = "Testing makeFloor function"
self.printTestMessage(operation)
floor = Arch.makeFloor(name="TestFloor")
self.assertIsNotNone(floor, "makeFloor failed to create a floor object.")
self.assertEqual(floor.Label, "TestFloor", "Floor label is incorrect.")
def test_makeBuilding(self):
"""Test the makeBuilding function."""
operation = "Testing makeBuilding function"
self.printTestMessage(operation)
building = Arch.makeBuilding(name="TestBuilding")
self.assertIsNotNone(building, "makeBuilding failed to create a building object.")
self.assertEqual(building.Label, "TestBuilding", "Building label is incorrect.")
def test_convertFloors(self):
"""Test the convertFloors function."""
operation = "Testing convertFloors..."
self.printTestMessage(operation)
# Create a mock floor object
floor = Arch.makeFloor()
Arch.convertFloors(floor)
self.assertEqual(floor.IfcType, "Building Storey", "convertFloors failed to set IfcType correctly")
def test_make2DDrawing(self):
"""Test the make2DDrawing function."""
operation = "Testing make2DDrawing..."
self.printTestMessage(operation)
obj = Arch.make2DDrawing()
self.assertIsNotNone(obj, "make2DDrawing failed to create an object")
self.assertEqual(obj.Label, "Drawing", "Incorrect default label for 2D Drawing")

View File

@@ -0,0 +1,37 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
# ***************************************************************************
# * *
# * Copyright (c) 2025 Furgo *
# * *
# * This file is part of FreeCAD. *
# * *
# * FreeCAD is free software: you can redistribute it and/or modify it *
# * under the terms of the GNU Lesser General Public License as *
# * published by the Free Software Foundation, either version 2.1 of the *
# * License, or (at your option) any later version. *
# * *
# * FreeCAD is distributed in the hope that it will be useful, but *
# * WITHOUT ANY WARRANTY; without even the implied warranty of *
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
# * Lesser General Public License for more details. *
# * *
# * You should have received a copy of the GNU Lesser General Public *
# * License along with FreeCAD. If not, see *
# * <https://www.gnu.org/licenses/>. *
# * *
# ***************************************************************************
import Arch
from bimtests import TestArchBase
class TestArchCurtainWall(TestArchBase.TestArchBase):
def test_makeCurtainWall(self):
"""Test the makeCurtainWall function."""
operation = "Testing makeCurtainWall function"
self.printTestMessage(operation)
curtain_wall = Arch.makeCurtainWall(name="TestCurtainWall")
self.assertIsNotNone(curtain_wall, "makeCurtainWall failed to create a curtain wall object.")
self.assertEqual(curtain_wall.Label, "TestCurtainWall", "Curtain wall label is incorrect.")

View File

@@ -0,0 +1,37 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
# ***************************************************************************
# * *
# * Copyright (c) 2025 Furgo *
# * *
# * This file is part of FreeCAD. *
# * *
# * FreeCAD is free software: you can redistribute it and/or modify it *
# * under the terms of the GNU Lesser General Public License as *
# * published by the Free Software Foundation, either version 2.1 of the *
# * License, or (at your option) any later version. *
# * *
# * FreeCAD is distributed in the hope that it will be useful, but *
# * WITHOUT ANY WARRANTY; without even the implied warranty of *
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
# * Lesser General Public License for more details. *
# * *
# * You should have received a copy of the GNU Lesser General Public *
# * License along with FreeCAD. If not, see *
# * <https://www.gnu.org/licenses/>. *
# * *
# ***************************************************************************
import Arch
from bimtests import TestArchBase
class TestArchEquipment(TestArchBase.TestArchBase):
def test_makeEquipment(self):
"""Test the makeEquipment function."""
operation = "Testing makeEquipment..."
self.printTestMessage(operation)
obj = Arch.makeEquipment()
self.assertIsNotNone(obj, "makeEquipment failed to create an object")
self.assertEqual(obj.Label, "Equipment", "Incorrect default label for Equipment")

View File

@@ -0,0 +1,43 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
# ***************************************************************************
# * *
# * Copyright (c) 2025 Furgo *
# * *
# * This file is part of FreeCAD. *
# * *
# * FreeCAD is free software: you can redistribute it and/or modify it *
# * under the terms of the GNU Lesser General Public License as *
# * published by the Free Software Foundation, either version 2.1 of the *
# * License, or (at your option) any later version. *
# * *
# * FreeCAD is distributed in the hope that it will be useful, but *
# * WITHOUT ANY WARRANTY; without even the implied warranty of *
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
# * Lesser General Public License for more details. *
# * *
# * You should have received a copy of the GNU Lesser General Public *
# * License along with FreeCAD. If not, see *
# * <https://www.gnu.org/licenses/>. *
# * *
# ***************************************************************************
import FreeCAD as App
import Arch
import Draft
from bimtests import TestArchBase
class TestArchFence(TestArchBase.TestArchBase):
def test_makeFence(self):
# Create section, post, and path objects
section = Draft.makeRectangle(100, 10)
post = Draft.makeRectangle(10, 10)
path = Draft.makeLine(App.Vector(0, 0, 0), App.Vector(1000, 0, 0))
# Create a fence
fence = Arch.makeFence(section, post, path)
self.assertIsNotNone(fence, "Failed to create fence")
self.assertEqual(fence.Section, section, "Fence section is incorrect")
self.assertEqual(fence.Post, post, "Fence post is incorrect")
self.assertEqual(fence.Path, path, "Fence path is incorrect")

View File

@@ -0,0 +1,37 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
# ***************************************************************************
# * *
# * Copyright (c) 2025 Furgo *
# * *
# * This file is part of FreeCAD. *
# * *
# * FreeCAD is free software: you can redistribute it and/or modify it *
# * under the terms of the GNU Lesser General Public License as *
# * published by the Free Software Foundation, either version 2.1 of the *
# * License, or (at your option) any later version. *
# * *
# * FreeCAD is distributed in the hope that it will be useful, but *
# * WITHOUT ANY WARRANTY; without even the implied warranty of *
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
# * Lesser General Public License for more details. *
# * *
# * You should have received a copy of the GNU Lesser General Public *
# * License along with FreeCAD. If not, see *
# * <https://www.gnu.org/licenses/>. *
# * *
# ***************************************************************************
import Arch
from bimtests import TestArchBase
class TestArchFrame(TestArchBase.TestArchBase):
def test_makeFrame(self):
"""Test the makeFrame function."""
operation = "Testing makeFrame..."
self.printTestMessage(operation)
obj = Arch.makeFrame(None, None)
self.assertIsNotNone(obj, "makeFrame failed to create an object")
self.assertEqual(obj.Label, "Frame", "Incorrect default label for Frame")

View File

@@ -0,0 +1,40 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
# ***************************************************************************
# * *
# * Copyright (c) 2025 Furgo *
# * *
# * This file is part of FreeCAD. *
# * *
# * FreeCAD is free software: you can redistribute it and/or modify it *
# * under the terms of the GNU Lesser General Public License as *
# * published by the Free Software Foundation, either version 2.1 of the *
# * License, or (at your option) any later version. *
# * *
# * FreeCAD is distributed in the hope that it will be useful, but *
# * WITHOUT ANY WARRANTY; without even the implied warranty of *
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
# * Lesser General Public License for more details. *
# * *
# * You should have received a copy of the GNU Lesser General Public *
# * License along with FreeCAD. If not, see *
# * <https://www.gnu.org/licenses/>. *
# * *
# ***************************************************************************
import FreeCAD as App
import Arch
import Draft
from bimtests import TestArchBase
class TestArchGrid(TestArchBase.TestArchBase):
def test_makeGrid(self):
"""Test the makeGrid function."""
operation = "Testing makeGrid..."
self.printTestMessage(operation)
# Call makeGrid with only the name parameter
grid = Arch.makeGrid(name="TestGrid")
self.assertIsNotNone(grid, "makeGrid failed to create a grid object.")
self.assertEqual(grid.Label, "TestGrid", "Grid label is incorrect.")

View File

@@ -0,0 +1,63 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
# ***************************************************************************
# * *
# * Copyright (c) 2025 Furgo *
# * *
# * This file is part of FreeCAD. *
# * *
# * FreeCAD is free software: you can redistribute it and/or modify it *
# * under the terms of the GNU Lesser General Public License as *
# * published by the Free Software Foundation, either version 2.1 of the *
# * License, or (at your option) any later version. *
# * *
# * FreeCAD is distributed in the hope that it will be useful, but *
# * WITHOUT ANY WARRANTY; without even the implied warranty of *
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
# * Lesser General Public License for more details. *
# * *
# * You should have received a copy of the GNU Lesser General Public *
# * License along with FreeCAD. If not, see *
# * <https://www.gnu.org/licenses/>. *
# * *
# ***************************************************************************
import Arch
from bimtests import TestArchBase
class TestArchMaterial(TestArchBase.TestArchBase):
def test_makeMaterial(self):
"""Test the makeMaterial function."""
operation = "Testing makeMaterial function"
self.printTestMessage(operation)
material = Arch.makeMaterial(name="TestMaterial")
self.assertIsNotNone(material, "makeMaterial failed to create a material object.")
self.assertEqual(material.Label, "TestMaterial", "Material label is incorrect.")
def test_makeMultiMaterial(self):
"""Test the makeMultiMaterial function."""
operation = "Testing makeMultiMaterial function"
self.printTestMessage(operation)
multi_material = Arch.makeMultiMaterial(name="TestMultiMaterial")
self.assertIsNotNone(multi_material, "makeMultiMaterial failed to create a multi-material object.")
self.assertEqual(multi_material.Label, "TestMultiMaterial", "Multi-material label is incorrect.")
def test_getMaterialContainer(self):
"""Test the getMaterialContainer function."""
operation = "Testing getMaterialContainer function"
self.printTestMessage(operation)
container = Arch.getMaterialContainer()
self.assertIsNotNone(container, "getMaterialContainer failed to retrieve or create a material container.")
self.assertEqual(container.Label, "Materials", "Material container label is incorrect.")
def test_getDocumentMaterials(self):
"""Test the getDocumentMaterials function."""
operation = "Testing getDocumentMaterials function"
self.printTestMessage(operation)
materials = Arch.getDocumentMaterials()
self.assertIsInstance(materials, list, "getDocumentMaterials did not return a list.")

View File

@@ -0,0 +1,58 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
# ***************************************************************************
# * *
# * Copyright (c) 2025 Furgo *
# * *
# * This file is part of FreeCAD. *
# * *
# * FreeCAD is free software: you can redistribute it and/or modify it *
# * under the terms of the GNU Lesser General Public License as *
# * published by the Free Software Foundation, either version 2.1 of the *
# * License, or (at your option) any later version. *
# * *
# * FreeCAD is distributed in the hope that it will be useful, but *
# * WITHOUT ANY WARRANTY; without even the implied warranty of *
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
# * Lesser General Public License for more details. *
# * *
# * You should have received a copy of the GNU Lesser General Public *
# * License along with FreeCAD. If not, see *
# * <https://www.gnu.org/licenses/>. *
# * *
# ***************************************************************************
import Arch
from bimtests import TestArchBase
class TestArchPanel(TestArchBase.TestArchBase):
def test_makePanel(self):
"""Test the makePanel function."""
operation = "Testing makePanel function"
self.printTestMessage(operation)
panel = Arch.makePanel(name="TestPanel")
self.assertIsNotNone(panel, "makePanel failed to create a panel object.")
self.assertEqual(panel.Label, "TestPanel", "Panel label is incorrect.")
# TODO: remove NOT_ prefix once it is understood why Arch.makePanelCut fails
def NOT_test_makePanelCut(self):
"""Test the makePanelCut function."""
operation = "Testing makePanelCut function"
self.printTestMessage(operation)
panel = Arch.makePanel(name="TestPanel")
panel_cut = Arch.makePanelCut(panel, name="TestPanelCut")
self.assertIsNotNone(panel_cut, "makePanelCut failed to create a panel cut object.")
self.assertEqual(panel_cut.Label, "TestPanelCut", "Panel cut label is incorrect.")
# TODO: remove NOT_ prefix once it is understood why Arch.makePanelSheet fails
def NOT_test_makePanelSheet(self):
"""Test the makePanelSheet function."""
operation = "Testing makePanelSheet function"
self.printTestMessage(operation)
panel_sheet = Arch.makePanelSheet(name="TestPanelSheet")
self.assertIsNotNone(panel_sheet, "makePanelSheet failed to create a panel sheet object.")
self.assertEqual(panel_sheet.Label, "TestPanelSheet", "Panel sheet label is incorrect.")

View File

@@ -0,0 +1,48 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
# ***************************************************************************
# * *
# * Copyright (c) 2025 Furgo *
# * *
# * This file is part of FreeCAD. *
# * *
# * FreeCAD is free software: you can redistribute it and/or modify it *
# * under the terms of the GNU Lesser General Public License as *
# * published by the Free Software Foundation, either version 2.1 of the *
# * License, or (at your option) any later version. *
# * *
# * FreeCAD is distributed in the hope that it will be useful, but *
# * WITHOUT ANY WARRANTY; without even the implied warranty of *
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
# * Lesser General Public License for more details. *
# * *
# * You should have received a copy of the GNU Lesser General Public *
# * License along with FreeCAD. If not, see *
# * <https://www.gnu.org/licenses/>. *
# * *
# ***************************************************************************
import Arch
from bimtests import TestArchBase
class TestArchPipe(TestArchBase.TestArchBase):
def test_makePipe(self):
"""Test the makePipe function."""
operation = "Testing makePipe function"
self.printTestMessage(operation)
pipe = Arch.makePipe(diameter=200, length=1000, name="TestPipe")
self.assertIsNotNone(pipe, "makePipe failed to create a pipe object.")
self.assertEqual(pipe.Label, "TestPipe", "Pipe label is incorrect.")
def test_makePipeConnector(self):
"""Test the makePipeConnector function."""
operation = "Testing makePipeConnector function"
self.printTestMessage(operation)
pipe1 = Arch.makePipe(diameter=200, length=1000, name="Pipe1")
pipe2 = Arch.makePipe(diameter=200, length=1000, name="Pipe2")
connector = Arch.makePipeConnector([pipe1, pipe2], radius=100, name="TestConnector")
self.assertIsNotNone(connector, "makePipeConnector failed to create a pipe connector object.")
self.assertEqual(connector.Label, "TestConnector", "Pipe connector label is incorrect.")

View File

@@ -0,0 +1,37 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
# ***************************************************************************
# * *
# * Copyright (c) 2025 Furgo *
# * *
# * This file is part of FreeCAD. *
# * *
# * FreeCAD is free software: you can redistribute it and/or modify it *
# * under the terms of the GNU Lesser General Public License as *
# * published by the Free Software Foundation, either version 2.1 of the *
# * License, or (at your option) any later version. *
# * *
# * FreeCAD is distributed in the hope that it will be useful, but *
# * WITHOUT ANY WARRANTY; without even the implied warranty of *
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
# * Lesser General Public License for more details. *
# * *
# * You should have received a copy of the GNU Lesser General Public *
# * License along with FreeCAD. If not, see *
# * <https://www.gnu.org/licenses/>. *
# * *
# ***************************************************************************
import Arch
from bimtests import TestArchBase
class TestArchProfile(TestArchBase.TestArchBase):
def test_makeProfile(self):
"""Test the makeProfile function."""
operation = "Testing makeProfile function"
self.printTestMessage(operation)
profile = Arch.makeProfile(profile=[0, 'REC', 'REC100x100', 'R', 100, 100])
self.assertIsNotNone(profile, "makeProfile failed to create a profile object.")
self.assertEqual(profile.Label, "REC100x100_", "Profile label is incorrect.")

View File

@@ -0,0 +1,37 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
# ***************************************************************************
# * *
# * Copyright (c) 2025 Furgo *
# * *
# * This file is part of FreeCAD. *
# * *
# * FreeCAD is free software: you can redistribute it and/or modify it *
# * under the terms of the GNU Lesser General Public License as *
# * published by the Free Software Foundation, either version 2.1 of the *
# * License, or (at your option) any later version. *
# * *
# * FreeCAD is distributed in the hope that it will be useful, but *
# * WITHOUT ANY WARRANTY; without even the implied warranty of *
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
# * Lesser General Public License for more details. *
# * *
# * You should have received a copy of the GNU Lesser General Public *
# * License along with FreeCAD. If not, see *
# * <https://www.gnu.org/licenses/>. *
# * *
# ***************************************************************************
import Arch
from bimtests import TestArchBase
class TestArchProject(TestArchBase.TestArchBase):
def test_makeProject(self):
"""Test the makeProject function."""
operation = "Testing makeProject function"
self.printTestMessage(operation)
project = Arch.makeProject(name="TestProject")
self.assertIsNotNone(project, "makeProject failed to create a project object.")
self.assertEqual(project.Label, "TestProject", "Project label is incorrect.")

View File

@@ -0,0 +1,39 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
# ***************************************************************************
# * *
# * Copyright (c) 2025 Furgo *
# * *
# * This file is part of FreeCAD. *
# * *
# * FreeCAD is free software: you can redistribute it and/or modify it *
# * under the terms of the GNU Lesser General Public License as *
# * published by the Free Software Foundation, either version 2.1 of the *
# * License, or (at your option) any later version. *
# * *
# * FreeCAD is distributed in the hope that it will be useful, but *
# * WITHOUT ANY WARRANTY; without even the implied warranty of *
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
# * Lesser General Public License for more details. *
# * *
# * You should have received a copy of the GNU Lesser General Public *
# * License along with FreeCAD. If not, see *
# * <https://www.gnu.org/licenses/>. *
# * *
# ***************************************************************************
import Arch
from bimtests import TestArchBase
class TestArchRebar(TestArchBase.TestArchBase):
# TODO: remove NOT_ prefix once it is understood why Arch.makeRebar fails
# Check https://wiki.freecad.org/Arch_Rebar#Scripting
def NOT_test_makeRebar(self):
"""Test the makeRebar function."""
operation = "Testing makeRebar function"
self.printTestMessage(operation)
rebar = Arch.makeRebar(diameter=16, amount=5, name="TestRebar")
self.assertIsNotNone(rebar, "makeRebar failed to create a rebar object.")
self.assertEqual(rebar.Label, "TestRebar", "Rebar label is incorrect.")

View File

@@ -0,0 +1,37 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
# ***************************************************************************
# * *
# * Copyright (c) 2025 Furgo *
# * *
# * This file is part of FreeCAD. *
# * *
# * FreeCAD is free software: you can redistribute it and/or modify it *
# * under the terms of the GNU Lesser General Public License as *
# * published by the Free Software Foundation, either version 2.1 of the *
# * License, or (at your option) any later version. *
# * *
# * FreeCAD is distributed in the hope that it will be useful, but *
# * WITHOUT ANY WARRANTY; without even the implied warranty of *
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
# * Lesser General Public License for more details. *
# * *
# * You should have received a copy of the GNU Lesser General Public *
# * License along with FreeCAD. If not, see *
# * <https://www.gnu.org/licenses/>. *
# * *
# ***************************************************************************
import Arch
from bimtests import TestArchBase
class TestArchReference(TestArchBase.TestArchBase):
def test_makeReference(self):
"""Test the makeReference function."""
operation = "Testing makeReference..."
self.printTestMessage(operation)
obj = Arch.makeReference()
self.assertIsNotNone(obj, "makeReference failed to create an object")
self.assertEqual(obj.Label, "External Reference", "Incorrect default label for Reference")

View File

@@ -25,7 +25,6 @@
# Unit tests for the Arch wall module
import os
import unittest
import Arch
import Draft
import Part
@@ -147,3 +146,12 @@ class TestArchRoof(TestArchBase.TestArchBase):
roof.recompute()
self.assertFalse(roof.Shape.isNull(), "'{}' failed".format(operation))
self.assertTrue(roof.Shape.isValid(), "'{}' failed".format(operation))
def test_makeRoof(self):
"""Test the makeRoof function."""
operation = "Testing makeRoof function"
self.printTestMessage(operation)
roof = Arch.makeRoof(name="TestRoof")
self.assertIsNotNone(roof, "makeRoof failed to create a roof object.")
self.assertEqual(roof.Label, "TestRoof", "Roof label is incorrect.")

View File

@@ -0,0 +1,37 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
# ***************************************************************************
# * *
# * Copyright (c) 2025 Furgo *
# * *
# * This file is part of FreeCAD. *
# * *
# * FreeCAD is free software: you can redistribute it and/or modify it *
# * under the terms of the GNU Lesser General Public License as *
# * published by the Free Software Foundation, either version 2.1 of the *
# * License, or (at your option) any later version. *
# * *
# * FreeCAD is distributed in the hope that it will be useful, but *
# * WITHOUT ANY WARRANTY; without even the implied warranty of *
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
# * Lesser General Public License for more details. *
# * *
# * You should have received a copy of the GNU Lesser General Public *
# * License along with FreeCAD. If not, see *
# * <https://www.gnu.org/licenses/>. *
# * *
# ***************************************************************************
import Arch
from bimtests import TestArchBase
class TestArchSchedule(TestArchBase.TestArchBase):
def test_makeSchedule(self):
"""Test the makeSchedule function."""
operation = "Testing makeSchedule..."
self.printTestMessage(operation)
obj = Arch.makeSchedule()
self.assertIsNotNone(obj, "makeSchedule failed to create an object")
self.assertEqual(obj.Label, "Schedule", "Incorrect default label for Schedule")

View File

@@ -0,0 +1,37 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
# ***************************************************************************
# * *
# * Copyright (c) 2025 Furgo *
# * *
# * This file is part of FreeCAD. *
# * *
# * FreeCAD is free software: you can redistribute it and/or modify it *
# * under the terms of the GNU Lesser General Public License as *
# * published by the Free Software Foundation, either version 2.1 of the *
# * License, or (at your option) any later version. *
# * *
# * FreeCAD is distributed in the hope that it will be useful, but *
# * WITHOUT ANY WARRANTY; without even the implied warranty of *
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
# * Lesser General Public License for more details. *
# * *
# * You should have received a copy of the GNU Lesser General Public *
# * License along with FreeCAD. If not, see *
# * <https://www.gnu.org/licenses/>. *
# * *
# ***************************************************************************
import Arch
from bimtests import TestArchBase
class TestArchSectionPlane(TestArchBase.TestArchBase):
def test_makeSectionPlane(self):
"""Test the makeSectionPlane function."""
operation = "Testing makeSectionPlane function"
self.printTestMessage(operation)
section_plane = Arch.makeSectionPlane(name="TestSectionPlane")
self.assertIsNotNone(section_plane, "makeSectionPlane failed to create a section plane object.")
self.assertEqual(section_plane.Label, "TestSectionPlane", "Section plane label is incorrect.")

View File

@@ -3,6 +3,7 @@
# ***************************************************************************
# * *
# * Copyright (c) 2013 Yorik van Havre <yorik@uncreated.net> *
# * Copyright (c) 2025 Furgo *
# * *
# * This file is part of FreeCAD. *
# * *
@@ -25,7 +26,6 @@
# Unit tests for the Arch space module
import os
import unittest
import Arch
import Draft
import Part

View File

@@ -0,0 +1,83 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
# ***************************************************************************
# * *
# * Copyright (c) 2025 Furgo *
# * *
# * This file is part of FreeCAD. *
# * *
# * FreeCAD is free software: you can redistribute it and/or modify it *
# * under the terms of the GNU Lesser General Public License as *
# * published by the Free Software Foundation, either version 2.1 of the *
# * License, or (at your option) any later version. *
# * *
# * FreeCAD is distributed in the hope that it will be useful, but *
# * WITHOUT ANY WARRANTY; without even the implied warranty of *
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
# * Lesser General Public License for more details. *
# * *
# * You should have received a copy of the GNU Lesser General Public *
# * License along with FreeCAD. If not, see *
# * <https://www.gnu.org/licenses/>. *
# * *
# ***************************************************************************
import Arch
from bimtests import TestArchBase
class TestArchStairs(TestArchBase.TestArchBase):
def test_makeStairs(self):
"""Test the makeStairs function."""
operation = "Testing makeStairs function"
self.printTestMessage(operation)
stairs = Arch.makeStairs(length=5000, width=1000, height=3000, steps=10, name="TestStairs")
self.assertIsNotNone(stairs, "makeStairs failed to create a stairs object.")
self.assertEqual(stairs.Label, "TestStairs", "Stairs label is incorrect.")
def test_makeRailing(self):
"""Test the makeRailing function."""
operation = "Testing makeRailing..."
self.printTestMessage(operation)
stairs = Arch.makeStairs(length=5000, width=1000, height=3000, steps=10, name="TestStairs")
self.assertIsNotNone(stairs, "makeStairs failed to create a stairs object.")
# Pass stairs as a list to makeRailing
obj = Arch.makeRailing([stairs])
self.assertIsNotNone(obj, "makeRailing failed to create an object")
self.assertEqual(obj.Label, "Railing", "Incorrect default label for Railing")
def test_makeRailing(self):
"""Test the makeRailing function."""
operation = "Testing makeRailing..."
self.printTestMessage(operation)
# Create stairs
stairs = Arch.makeStairs(width=800, height=2500, length=3500, steps=14)
self.document.recompute()
# Get object names before creation
pre_creation_names = {obj.Name for obj in self.document.Objects}
# Create railings
Arch.makeRailing([stairs])
self.document.recompute()
# Find new railings by name comparison and type checking
new_railings = [
obj for obj in self.document.Objects
if obj.Name not in pre_creation_names
and hasattr(obj, "Proxy")
and getattr(obj.Proxy, "Type", "") == "Pipe"
]
# Should create exactly 2 new railing objects
self.assertEqual(len(new_railings), 2)
# Verify properties exist
for railing in new_railings:
self.assertTrue(hasattr(railing, "Height"))
self.assertTrue(hasattr(railing, "Diameter"))
self.assertTrue(hasattr(railing, "Placement"))

View File

@@ -0,0 +1,37 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
# ***************************************************************************
# * *
# * Copyright (c) 2025 Furgo *
# * *
# * This file is part of FreeCAD. *
# * *
# * FreeCAD is free software: you can redistribute it and/or modify it *
# * under the terms of the GNU Lesser General Public License as *
# * published by the Free Software Foundation, either version 2.1 of the *
# * License, or (at your option) any later version. *
# * *
# * FreeCAD is distributed in the hope that it will be useful, but *
# * WITHOUT ANY WARRANTY; without even the implied warranty of *
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
# * Lesser General Public License for more details. *
# * *
# * You should have received a copy of the GNU Lesser General Public *
# * License along with FreeCAD. If not, see *
# * <https://www.gnu.org/licenses/>. *
# * *
# ***************************************************************************
import Arch
from bimtests import TestArchBase
class TestArchTruss(TestArchBase.TestArchBase):
def test_makeTruss(self):
"""Test the makeTruss function."""
operation = "Testing makeTruss..."
self.printTestMessage(operation)
obj = Arch.makeTruss()
self.assertIsNotNone(obj, "makeTruss failed to create an object")
self.assertEqual(obj.Label, "Truss", "Incorrect default label for Truss")

View File

@@ -25,7 +25,6 @@
# Unit tests for the Arch wall module
import os
import unittest
import Arch
import Draft
import Part
@@ -83,3 +82,24 @@ class TestArchWall(TestArchBase.TestArchBase):
ptMax = App.Vector(box.XMax, box.YMax, 0)
self.assertTrue(ptMax.isEqual(checkLst[i][1], 1e-8),
"Arch Wall with MultiMaterial and 3 alignments failed")
def test_makeWall(self):
"""Test the makeWall function."""
operation = "Testing makeWall function"
self.printTestMessage(operation)
wall = Arch.makeWall(length=5000, width=200, height=3000)
self.assertIsNotNone(wall, "makeWall failed to create a wall object.")
self.assertEqual(wall.Label, "Wall", "Wall label is incorrect.")
def test_joinWalls(self):
"""Test the joinWalls function."""
operation = "Testing joinWalls function"
self.printTestMessage(operation)
base_line1 = Draft.makeLine(App.Vector(0, 0, 0), App.Vector(5000, 0, 0))
base_line2 = Draft.makeLine(App.Vector(5000, 0, 0), App.Vector(5000, 3000, 0))
wall1 = Arch.makeWall(base_line1, width=200, height=3000)
wall2 = Arch.makeWall(base_line2, width=200, height=3000)
joined_wall = Arch.joinWalls([wall1, wall2])
self.assertIsNotNone(joined_wall, "joinWalls failed to join walls.")

View File

@@ -0,0 +1,37 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
# ***************************************************************************
# * *
# * Copyright (c) 2025 Furgo *
# * *
# * This file is part of FreeCAD. *
# * *
# * FreeCAD is free software: you can redistribute it and/or modify it *
# * under the terms of the GNU Lesser General Public License as *
# * published by the Free Software Foundation, either version 2.1 of the *
# * License, or (at your option) any later version. *
# * *
# * FreeCAD is distributed in the hope that it will be useful, but *
# * WITHOUT ANY WARRANTY; without even the implied warranty of *
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
# * Lesser General Public License for more details. *
# * *
# * You should have received a copy of the GNU Lesser General Public *
# * License along with FreeCAD. If not, see *
# * <https://www.gnu.org/licenses/>. *
# * *
# ***************************************************************************
import Arch
from bimtests import TestArchBase
class TestArchWindow(TestArchBase.TestArchBase):
def test_makeWindow(self):
"""Test the makeWindow function."""
operation = "Testing makeWindow function"
self.printTestMessage(operation)
window = Arch.makeWindow(width=1200, height=1000)
self.assertIsNotNone(window, "makeWindow failed to create a window object.")
self.assertEqual(window.Label, "Window", "Window label is incorrect.")