mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-10 06:00:51 +00:00
New demo module to teach developers how to hack on the BlenderBIM Add-on.
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
# ############################################################################ #
|
||||
|
||||
# Hey there! Welcome to the BlenderBIM Add-on code. Please feel free to reach
|
||||
# out if you have any questions or need further guidance. Happy hacking!
|
||||
|
||||
# ############################################################################ #
|
||||
|
||||
# This allows us to write full integration tests that test how all systems work
|
||||
# as a whole. Whilst other tests focus on portions of the software, these tests
|
||||
# simulate what happens when a user opens Blender, presses buttons, and does
|
||||
# things.
|
||||
|
||||
# These tests read like english. You can see all the possible sentences defined
|
||||
# in test_feature.py. Most of the time, there is already a sentence defined for
|
||||
# what you want to test.
|
||||
|
||||
@demo
|
||||
Feature: Demo
|
||||
|
||||
# Every operator has at least one scenario associated with it to test it.
|
||||
Scenario: Demonstrate hello world
|
||||
Given an empty IFC project
|
||||
When I press "bim.demonstrate_hello_world"
|
||||
# Blender doesn't have a way of testing that things are visible in the
|
||||
# interface and layout. We can check properties, and whats in the 3D
|
||||
# scenegraph, but not layout. There is no "DOM" like in web applications.
|
||||
# Too bad, we can't check the results, but we still write the test, that way
|
||||
# we can still check for errors like crashes or Python errors, like a "smoke
|
||||
# test".
|
||||
Then nothing happens
|
||||
|
||||
# This operator has two scenarios because there are two possibilities of a user
|
||||
# interacting with it.
|
||||
Scenario: Demonstrate rename project - with a name provided
|
||||
Given an empty IFC project
|
||||
When I set "scene.BIMDemoProperties.name" to "Foobar"
|
||||
And I press "bim.demonstrate_rename_project"
|
||||
Then the object "IfcProject/Foobar" is an "IfcProject"
|
||||
|
||||
# This is the other possible scenario for the rename project operator.
|
||||
Scenario: Demonstrate rename project - with no name
|
||||
Given an empty IFC project
|
||||
When I set "scene.BIMDemoProperties.name" to ""
|
||||
And I press "bim.demonstrate_rename_project"
|
||||
Then the object "IfcProject/My Project" is an "IfcProject"
|
||||
@@ -209,6 +209,19 @@ def i_set_prop_to_value(prop, value):
|
||||
exec(f"bpy.context.{prop} = {value}")
|
||||
|
||||
|
||||
@given(parsers.parse('I set "{prop}" to ""'))
|
||||
@when(parsers.parse('I set "{prop}" to ""'))
|
||||
def i_set_prop_to_value(prop):
|
||||
try:
|
||||
eval(f"bpy.context.{prop}")
|
||||
except:
|
||||
assert False, "Property does not exist"
|
||||
try:
|
||||
exec(f'bpy.context.{prop} = r""')
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
@when(parsers.parse('I am on frame "{number}"'))
|
||||
def i_am_on_frame_number(number):
|
||||
bpy.context.scene.frame_set(int(number))
|
||||
|
||||
Reference in New Issue
Block a user