ENZYME-APD / tapir-archicad-automation

The easiest way to use the JSON/Python API from Archicad without knowing how to code.
MIT License
57 stars 17 forks source link

Autotesting examples #171

Closed tlorantfy closed 2 months ago

tlorantfy commented 2 months ago

test_example.py executes all example scripts and compares the results with the expected outputs (stored in files). It opens TestProject.pla before executing each script. TestProject.pla is placed to the same folder as test_example.py.

@kovacsv, TestProject.pla should be uploaded to somewhere (now available at https://we.tl/t-QV30o0QXQ1 but that link will expire soon). Do you have any permanent storage? Are we able to upload it to github? I found Git LFS. It enables "storing" large files in git repo. So I was able to push TestProject.pla, the reference project for the test framework.

Note, I fixed all example scripts and found some issues in commands. I also changed the schemas of some commands to be more uniform.

tlorantfy commented 2 months ago

This is how test output looks like:

PS C:\Users\loran\GitRepos\tapir-archicad-automation> & python c:/Users/loran/GitRepos/tapir-archicad-automation/archicad-addon/Test/test_examples.py
Found 19 tests
1/19 change_gdlparameters.py
Reopening project TestProject.pla ... 5.561s
Executing script change_gdlparameters.py ... 0.277s
Comparing output ... 0.011s
PASSED
2/19 create_building_materials.py
Reopening project TestProject.pla ... 5.427s
Executing script create_building_materials.py ... 0.364s
Comparing output ... 0.000s
PASSED
3/19 create_composites.py
Reopening project TestProject.pla ... 5.312s
Executing script create_composites.py ... 0.266s
Comparing output ... 0.000s
PASSED
4/19 filter_elements.py
Reopening project TestProject.pla ... 5.640s
Executing script filter_elements.py ... 2.596s
Comparing output ... 0.000s
PASSED
5/19 get_building_material_physical_properties.py
Reopening project TestProject.pla ... 5.388s
Executing script get_building_material_physical_properties.py ... 0.198s
Comparing output ... 0.008s
PASSED
6/19 get_classifications_of_mainelements_and_subelements.py
Reopening project TestProject.pla ... 5.496s
Executing script get_classifications_of_mainelements_and_subelements.py ... 0.235s
Comparing output ... 0.016s
PASSED
7/19 get_current_window.py
Reopening project TestProject.pla ... 5.405s
Executing script get_current_window.py ... 0.125s
Comparing output ... 0.016s
PASSED
8/19 get_details_of_elements.py
Reopening project TestProject.pla ... 5.362s
Executing script get_details_of_elements.py ... 0.196s
Comparing output ... 0.016s
PASSED
9/19 get_libraries.py
Reopening project TestProject.pla ... 5.424s
Executing script get_libraries.py ... 0.160s
Comparing output ... 0.000s
PASSED
10/19 get_selected_elements.py
Reopening project TestProject.pla ... 5.371s
Executing script get_selected_elements.py ... 0.516s
Comparing output ... 0.016s
PASSED
11/19 highlight_elements.py
Reopening project TestProject.pla ... 6.038s
Executing script highlight_elements.py ... 5.269s
Comparing output ... 0.010s
PASSED
12/19 issue_management.py
Reopening project TestProject.pla ... 6.160s
Executing script issue_management.py ... 2.039s
Comparing output ... 0.012s
PASSED
13/19 manipulate_layers.py
Reopening project TestProject.pla ... 6.601s
Executing script manipulate_layers.py ... 1.369s
Comparing output ... 0.000s
PASSED
14/19 move_walls.py
Reopening project TestProject.pla ... 7.635s
Executing script move_walls.py ... 0.303s
Comparing output ... 0.003s
PASSED
15/19 reload_libraries.py
Reopening project TestProject.pla ... 6.661s
Executing script reload_libraries.py ... 1.517s
Comparing output ... 0.001s
PASSED
16/19 set_classifications_of_all_curtainwallframes.py
Reopening project TestProject.pla ... 5.642s
Executing script set_classifications_of_all_curtainwallframes.py ... 0.274s
Comparing output ... 0.007s
PASSED
17/19 set_project_info.py
Reopening project TestProject.pla ... 5.943s
Executing script set_project_info.py ... 0.777s
Comparing output ... 0.010s
PASSED
18/19 set_properties_of_subelements.py
Reopening project TestProject.pla ... 5.488s
Executing script set_properties_of_subelements.py ... 0.359s
Comparing output ... 0.017s
PASSED
19/19 quit_archicad.py
Reopening project TestProject.pla ... 5.384s
Executing script quit_archicad.py ... 0.708s
Comparing output ... 0.019s
PASSED
All (19) tests PASSED

And one of the expected ouputs:

Command: GetDetailsOfElements
Parameters:
{
    "elements": [
        {
            "elementId": {
                "guid": "<GUID>"
            }
        },
        {
            "elementId": {
                "guid": "<GUID>"
            }
        },
        {
            "elementId": {
                "guid": "<GUID>"
            }
        },
        {
            "elementId": {
                "guid": "<GUID>"
            }
        },
        {
            "elementId": {
                "guid": "<GUID>"
            }
        }
    ]
}
Response:
{
    "detailsOfElements": [
        {
            "type": "Wall",
            "floorIndex": 0,
            "layerIndex": 33,
            "drawIndex": 7,
            "details": {
                "geometryType": "Straight",
                "begCoordinate": {
                    "x": 0,
                    "y": 0
                },
                "endCoordinate": {
                    "x": 1.234,
                    "y": 0
                },
                "height": 3,
                "bottomOffset": 0,
                "offset": 0
            }
        },
        {
            "type": "Wall",
            "floorIndex": 1,
            "layerIndex": 33,
            "drawIndex": 7,
            "details": {
                "geometryType": "Trapezoid",
                "begThickness": 0.2,
                "endThickness": 0.25,
                "begCoordinate": {
                    "x": 0,
                    "y": 0.4
                },
                "endCoordinate": {
                    "x": 1.234,
                    "y": 0.4
                },
                "height": 2.8,
                "bottomOffset": 0.2,
                "offset": 0
            }
        },
        {
            "type": "Wall",
            "floorIndex": 1,
            "layerIndex": 33,
            "drawIndex": 7,
            "details": {
                "geometryType": "Polygonal",
                "polygonOutline": [
                    {
                        "x": 1.35,
                        "y": 0.4
                    },
                    {
                        "x": 2.584,
                        "y": 0.4
                    },
                    {
                        "x": 2.584,
                        "y": 0.65
                    },
                    {
                        "x": 1.35,
                        "y": 0.6
                    }
                ],
                "begCoordinate": {
                    "x": 1.35,
                    "y": 0.4
                },
                "endCoordinate": {
                    "x": 2.584,
                    "y": 0.4
                },
                "height": 2.5,
                "bottomOffset": 0,
                "offset": 0
            }
        },
        {
            "type": "Column",
            "floorIndex": 0,
            "layerIndex": 33,
            "drawIndex": 7,
            "details": {
                "origin": {
                    "x": 0,
                    "y": 1
                },
                "height": 2.5,
                "bottomOffset": 0.3
            }
        },
        {
            "type": "Column",
            "floorIndex": 0,
            "layerIndex": 33,
            "drawIndex": 7,
            "details": {
                "origin": {
                    "x": 1,
                    "y": 1
                },
                "height": 2.8,
                "bottomOffset": 0
            }
        }
    ]
}