File size: 3,989 Bytes
985c397
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# 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"))