-
Notifications
You must be signed in to change notification settings - Fork 5
Testing
There are more than 150 automated tests supplied with the bpypolyskel library. The tests are located in two directories:
- tests: the tests generated out of OpenStreetMap footprints with the hipped roof; the OSM footprints are located at misc/testing/osm/tests
- tests_special: the tests created manually to test rectangular footprints
It's required to install pytest and a couple of plugins for it to run the automated tests
pip install -U pytest
pip install pytest-timeout
pip install pytest-dependency
cd path/to/bpypolyskel
python -m pytest tests
python -m pytest tests_special
The process can be divided into 3 parts:
- Getting OSM id of the footprints
- Downloading OSM footprints for the given ids
- Actually generating the automated tests for the OSM footprints
The open source Blender-OSM addon for Blender is required to generate the automated tests out of OpenStreetMap footprints.
The automated tests in the tests directory were generated for the OpenStreetMap footprints with the hipped roof for which the bpypolyskel library failed during the course of its development.
Check Enable experimental features in preferences of the Blender-OSM addon. Set the path to blender-osm/setup/test_hipped.py in the field Setup script at the bottom of the Blender-OSM panel. Set an area for the OSM server or the path to an OSM file and press the button import. A log file will be written to D:\tmp\log.txt for the OSM footprints with the hipped roof for which the bpypolyskel library failed. A log file has the following structure:
<osm-id>|<way or relation>|<problem description>
For example:
729516527|way|Duplicated indices
733383913|way|Duplicated indices
3803883|relation|ZeroDivisionError-float division by zero
6013146|relation|IndexError-list index out of range
It's possible to add osm ids manually to the log file using the structure above. Use the string custom as the problem description.
To download OSM footprints for the ids in the log file execute:
python path/to/bpypolyskel/misc/get_osm_files.py --log path/to/log/file --outputDir path/to/output/directory/for/osm/files
A separate OSM file will be downloaded for each id in the log file.
It is required to run Blender with the Bledner-OSM addon in the command line mode to finish the task. Some changes are also required in the code of the Blender-OSM addon. One can revert the changes in the code after accomplishing the task.
Uncomment the following lines in the modules action/volume/roof_hipped.py and action/volume/roof_hipped_multi.py of the Blender-OSM addon:
from util.debug import dumpInputHippedRoof
in the beginning of the modules and
dumpInputHippedRoof(verts, firstVertIndex, numPolygonVerts, None, unitVector)
return
in the middle of the modules.
Paste the following line to a new text file and edit the entries for blosmPath, osmFilesDir, outputDir, assetsDir. Note that double backslash \\
must be used as the path separator on Windows.
{
"blosmPath": "path/to/blender-osm",
"osmFilesDir": "path/to/osm/files",
"outputDir": "path/to/output/directory/for/automated/tests",
"assetsDir": "path/to/assets/directory/for/blender-osm",
"outputTemplate": "test_bpypolyskel.py.template",
"outputFileNamePrefix": "test_"
}
Save the resulting file under the name config_generate_pytest_scripts.txt somewhere on your hard drive.
Open a command line application and cd to the directory where the file config_generate_pytest_scripts.txt was saved.
Execute the command:
blender -b -P path/to/bpypolyskel/misc/generate_pytest_scripts.py
The resulting automated tests will be generated in the directory specified for the entry outputDir in the file config_generate_pytest_scripts.txt.
Note that it's also possible to generate scripts for debugging rather than automated tests. The entries outputTemplate and outputFileNamePrefix in the file config_generate_pytest_scripts.txt should have the following values for that:
"outputTemplate": "debug_bpypolyskel.py.template",
"outputFileNamePrefix": ""