From bb46a1659d9c8a1cf3d506c59e1458998662d55e Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Fri, 7 Feb 2025 17:19:27 +1100 Subject: [PATCH] Fix light and georeference feature tests Not setting the year meant our date calc tests would fail every year :) --- src/bonsai/bonsai/bim/module/light/prop.py | 2 ++ src/bonsai/bonsai/bim/module/light/ui.py | 2 ++ src/bonsai/test/bim/feature/light.feature | 7 +++++-- src/bonsai/test/bim/test_feature.py | 4 ++-- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/bonsai/bonsai/bim/module/light/prop.py b/src/bonsai/bonsai/bim/module/light/prop.py index 90a27c0a5c..c8f249cefd 100644 --- a/src/bonsai/bonsai/bim/module/light/prop.py +++ b/src/bonsai/bonsai/bim/module/light/prop.py @@ -113,6 +113,7 @@ def update_sun_path(self): sun_props.sun_distance = self.sun_path_size sun_props.latitude = self.latitude sun_props.longitude = self.longitude + sun_props.year = self.year sun_props.month = self.month sun_props.day = self.day sun_props.time = self.hour + (self.minute / 60) @@ -382,6 +383,7 @@ class BIMSolarProperties(PropertyGroup): longitude: FloatProperty(name="Longitude", min=-180, max=180, update=update_latlong) timezone: StringProperty(name="Timezone", default="Etc/GMT") true_north: FloatProperty(name="True North", min=-180, max=180, update=update_true_north) + year: IntProperty(name="Year", min=1, max=9999, default=2025, update=update_date) month: IntProperty(name="Month", min=1, max=12, default=1, update=update_date) day: IntProperty(name="Date", min=1, max=31, default=1, update=update_date) hour: IntProperty(name="Hour", min=0, max=23, default=12, update=update_hourminute) diff --git a/src/bonsai/bonsai/bim/module/light/ui.py b/src/bonsai/bonsai/bim/module/light/ui.py index 97d29c041f..37aa632372 100644 --- a/src/bonsai/bonsai/bim/module/light/ui.py +++ b/src/bonsai/bonsai/bim/module/light/ui.py @@ -172,6 +172,8 @@ class BIM_PT_solar(bpy.types.Panel): if SolarData.data["true_north"] is not None: row.operator("bim.import_true_north", icon="IMPORT", text="") + row = self.layout.row() + row.prop(props, "year") row = self.layout.row(align=True) row.prop( props, diff --git a/src/bonsai/test/bim/feature/light.feature b/src/bonsai/test/bim/feature/light.feature index 831d6f25bb..d98a230b59 100644 --- a/src/bonsai/test/bim/feature/light.feature +++ b/src/bonsai/test/bim/feature/light.feature @@ -9,14 +9,16 @@ Scenario: Viewing default solar settings 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" + When I set the "Year" property to "2024" + And 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" + When I set the "Year" property to "2024" + And I set the "Date" property to "3" Then I see "Sunrise: 06:00:31" Scenario: Changing the time @@ -29,6 +31,7 @@ Scenario: Changing the time Scenario: Automatic timezone detection based on lat / long Given an empty IFC project And I look at the "Solar Access / Shadow" panel + And I set the "Year" property to "2024" When I set the "Latitude" property to "10.0" And I set the "Longitude" property to "20.0" Then I see "Africa/Ndjamena" diff --git a/src/bonsai/test/bim/test_feature.py b/src/bonsai/test/bim/test_feature.py index eade8ad366..17bfaf7824 100644 --- a/src/bonsai/test/bim/test_feature.py +++ b/src/bonsai/test/bim/test_feature.py @@ -274,8 +274,8 @@ def i_see_the_prop_property(prop): @then(parsers.parse('I don\'t see the "{prop}" property')) def i_dont_see_the_prop_property(prop): panel_spy.refresh_spy() - assert [ - p for p in panel_spy.spied_props if prop not in (p["name"], p["text"], p["icon"]) + assert not [ + p for p in panel_spy.spied_props if prop in (p["name"], p["text"], p["icon"]) ], f"Property {prop} not found in {panel_spy.spied_props}"