diff --git a/src/bonsai/pytest.ini b/src/bonsai/pytest.ini index 009a359717..eee9c46ded 100644 --- a/src/bonsai/pytest.ini +++ b/src/bonsai/pytest.ini @@ -14,6 +14,7 @@ markers = geometry georeference library + light material misc model diff --git a/src/bonsai/test/bim/feature/light.feature b/src/bonsai/test/bim/feature/light.feature new file mode 100644 index 0000000000..86dbdbf633 --- /dev/null +++ b/src/bonsai/test/bim/feature/light.feature @@ -0,0 +1,56 @@ +@light +Feature: Light + +Scenario: Viewing default solar settings + Given an empty IFC project + And I look at the "Solar Access / Shadow" panel + Then I see "Etc/GMT" + And I see "Sunrise: 06:02:50" + +Scenario: Changing the month + Given an empty IFC project + And I look at the "Solar Access / Shadow" panel + When I set the "January" property to "3" + Then I see "March" + And I see "Sunrise: 06:08:54" + +Scenario: Changing the date + Given an empty IFC project + And I look at the "Solar Access / Shadow" panel + When I set the "Date" property to "3" + Then I see "Sunrise: 06:00:31" + +Scenario: Changing the time + Given an empty IFC project + And I look at the "Solar Access / Shadow" panel + When I set the "Hour" property to "13" + And I set the "Minute" property to "30" + Then I see "Local Time: 13:30:00" + +Scenario: Automatic timezone detection based on lat / long + Given an empty IFC project + And I look at the "Solar Access / Shadow" panel + When I set the "Latitude" property to "10.0" + And I set the "Longitude" property to "20.0" + Then I see "Africa/Ndjamena" + And I see "Sunrise: 05:29:43" + +Scenario: Display the sun path + Given an empty IFC project + And I look at the "Solar Access / Shadow" panel + When I click "Display Sun Path" + And I set the "Sun Path Size" property to "100.0" + Then nothing happens + +Scenario: Display shadows + Given an empty IFC project + And I look at the "Solar Access / Shadow" panel + When I click "Display Shadows" + And I set the "Shadow Intensity" property to "1.0" + Then nothing happens + +Scenario: View from sun + Given an empty IFC project + And I look at the "Solar Access / Shadow" panel + When I click "View From Sun" + Then nothing happens diff --git a/src/bonsai/test/bim/test_feature.py b/src/bonsai/test/bim/test_feature.py index 4fe5d5bfcb..8d476ab80b 100644 --- a/src/bonsai/test/bim/test_feature.py +++ b/src/bonsai/test/bim/test_feature.py @@ -69,7 +69,7 @@ class PanelSpy: return self def __call__(self, *args, **kwargs): - if self.spied_attr in ("row", "column"): + if self.spied_attr in ("row", "column", "box"): return self elif self.spied_attr == "label": self.spied_labels.append(kwargs["text"]) @@ -79,6 +79,8 @@ class PanelSpy: text = kwargs.get("text", props.bl_rna.properties[name].name) icon = kwargs.get("icon", None) value = getattr(props, name) + if text: + self.spied_labels.append(text) spied_prop = {"props": props, "name": name, "text": text, "icon": icon, "value": value} self.spied_props.append(spied_prop) elif self.spied_attr == "operator": @@ -89,6 +91,8 @@ class PanelSpy: bl_label = getattr(bpy.types, bl_idname).bl_label text = kwargs.get("text", bl_label) icon = kwargs.get("icon", None) + if text: + self.spied_labels.append(text) spied_operator = {"operator": operator, "icon": icon, "text": text, "kwargs": {}} self.spied_operators.append(spied_operator) return OperatorSpy(spied_operator) @@ -243,7 +247,19 @@ def i_set_the_prop_property_to_value(prop, value): panel_spy.refresh_spy() for spied_prop in panel_spy.spied_props: if prop in (spied_prop["name"], spied_prop["text"], spied_prop["icon"]): - setattr(spied_prop["props"], spied_prop["name"], value) + if value == "TRUE": + setattr(spied_prop["props"], spied_prop["name"], True) + elif value == "FALSE": + setattr(spied_prop["props"], spied_prop["name"], False) + else: + try: + setattr(spied_prop["props"], spied_prop["name"], value) + except: + try: + setattr(spied_prop["props"], spied_prop["name"], int(value)) + except: + setattr(spied_prop["props"], spied_prop["name"], float(value)) + panel_spy.is_spy_dirty = True return assert False, f"Property {prop} not found in {panel_spy.spied_props}" @@ -377,6 +393,12 @@ def i_click_button(button): spied_operator["operator"](**spied_operator["kwargs"]) panel_spy.is_spy_dirty = True return + # Users can also "click" on booleans to toggle them + for spied_prop in panel_spy.spied_props: + if button in (spied_prop["name"], spied_prop["text"], spied_prop["icon"]): + val = getattr(spied_prop["props"], spied_prop["name"]) + setattr(spied_prop["props"], spied_prop["name"], not bool(val)) + return assert False, f"Could not find {button} in {panel_spy.spied_operators}"