Skip to content

Commit

Permalink
unit test lookup assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
JacksonJ-KC committed Dec 20, 2024
1 parent 73f7d58 commit 4d85253
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 6 deletions.
12 changes: 9 additions & 3 deletions rct229/rulesets/ashrae9012019/data_fns/table_7_8_fns.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,19 @@ def table_7_8_lookup(
# Validate equipment type
valid_equipment_types = [
"Electric storage water heater",
"Gas storage water heater"
"Gas storage water heater",
]
assert_(equipment_type in valid_equipment_types, f"Invalid equipment type. Must be one of {valid_equipment_types}")
assert_(
equipment_type in valid_equipment_types,
f"Invalid equipment type. Must be one of {valid_equipment_types}",
)

# Validate draw pattern
valid_draw_patterns = ["", "Very Small", "Low", "Medium", "High"]
assert_(draw_pattern in valid_draw_patterns, f"Invalid draw pattern. Must be one of {valid_draw_patterns}")
assert_(
draw_pattern in valid_draw_patterns,
f"Invalid draw pattern. Must be one of {valid_draw_patterns}",
)

# Filter entries by capacity thresholds
capacity_matched = find_capacity_matched_entries(
Expand Down
15 changes: 15 additions & 0 deletions rct229/rulesets/ashrae9012019/data_fns/table_7_8_fns_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import pytest
import re
from rct229.rulesets.ashrae9012019.data_fns.table_7_8_fns import table_7_8_lookup
from rct229.schema.config import ureg
from rct229.utils.assertions import RCTFailureException


# Testing table_7_8------------------------------------------
Expand Down Expand Up @@ -69,3 +72,15 @@ def test__table_7_8_lookup_gas_over105kbtuh():
"metric": "STANDBY_LOSS_ENERGY",
},
]


def test__table_7_8_invalid_draw_pattern():
expected_message = "Invalid draw pattern. Must be one of ['', 'Very Small', 'Low', 'Medium', 'High']"
with pytest.raises(RCTFailureException, match=re.escape(expected_message)):
table_7_8_lookup("Gas storage water heater", 106.0 * ureg("kBtu/h"), "Invalid")


def test__table_7_8_invalid_equipment_type():
expected_message = "Invalid equipment type. Must be one of ['Electric storage water heater', 'Gas storage water heater']"
with pytest.raises(RCTFailureException, match=re.escape(expected_message)):
table_7_8_lookup("Storage water heater", 106.0 * ureg("kBtu/h"), "High")
12 changes: 9 additions & 3 deletions rct229/rulesets/ashrae9012019/data_fns/table_F_2_fns.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,19 @@ def table_f_2_lookup(
# Validate equipment type
valid_equipment_types = [
"Electric storage water heater",
"Gas storage water heater"
"Gas storage water heater",
]
assert_(equipment_type in valid_equipment_types, f"Invalid equipment type. Must be one of {valid_equipment_types}")
assert_(
equipment_type in valid_equipment_types,
f"Invalid equipment type. Must be one of {valid_equipment_types}",
)

# Validate draw pattern
valid_draw_patterns = ["Very Small", "Low", "Medium", "High"]
assert_(draw_pattern in valid_draw_patterns, f"Invalid draw pattern. Must be one of {valid_draw_patterns}")
assert_(
draw_pattern in valid_draw_patterns,
f"Invalid draw pattern. Must be one of {valid_draw_patterns}",
)

# Filter entries by capacity thresholds
capacity_matched = find_capacity_matched_entries(
Expand Down
17 changes: 17 additions & 0 deletions rct229/rulesets/ashrae9012019/data_fns/table_F_2_fns_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import pytest
import re
from rct229.rulesets.ashrae9012019.data_fns.table_F_2_fns import table_f_2_lookup
from rct229.schema.config import ureg
from rct229.utils.assertions import RCTFailureException


# Testing table_7_8------------------------------------------
Expand Down Expand Up @@ -121,3 +124,17 @@ def test__table_f_2_lookup_elec_over100gal():
)
== []
)


def test__table_7_8_invalid_draw_pattern():
expected_message = (
"Invalid draw pattern. Must be one of ['Very Small', 'Low', 'Medium', 'High']"
)
with pytest.raises(RCTFailureException, match=re.escape(expected_message)):
table_f_2_lookup("Gas storage water heater", 106.0 * ureg("kBtu/h"), "Invalid")


def test__table_7_8_invalid_equipment_type():
expected_message = "Invalid equipment type. Must be one of ['Electric storage water heater', 'Gas storage water heater']"
with pytest.raises(RCTFailureException, match=re.escape(expected_message)):
table_f_2_lookup("Storage water heater", 106.0 * ureg("kBtu/h"), "High")

0 comments on commit 4d85253

Please sign in to comment.