Skip to content

Commit

Permalink
temp fix until PV PR is merged
Browse files Browse the repository at this point in the history
  • Loading branch information
ed-p-may committed Sep 29, 2024
1 parent a973a11 commit 0a7af8e
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
# - name: install python dependencies
# run: |
# python -m pip install --upgrade pip
# pip install .[dev]
# pip install '.[dev]'
# - name: run tests
# run: python -m pytest tests/

Expand Down
10 changes: 9 additions & 1 deletion honeybee_energy_revive/_extend_honeybee_energy_revive.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,20 @@
OpaqueConstructionProperties,
PeopleProperties,
ProcessProperties,
PVPropertiesProperties,
ServiceHotWaterProperties,
ShadeConstructionProperties,
WindowConstructionProperties,
WindowConstructionShadeProperties,
)

try:
from honeybee_energy.properties.extension import PVPropertiesProperties
except ImportError:
# -- Until Chris merges the PR, we need to use the MockPVPropertiesProperties
# -- https://github.com/ladybug-tools/honeybee-energy
from honeybee_energy_revive.properties.generator.pv import MockPVPropertiesProperties as PVPropertiesProperties


from honeybee_energy.schedule.ruleset import ScheduleRulesetProperties

# -- Constructions
Expand Down
6 changes: 6 additions & 0 deletions honeybee_energy_revive/properties/generator/pv.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,9 @@ def __repr__(self):

def ToString(self):
return str(self)


class MockPVPropertiesProperties(object):

def __init__(self):
pass
Empty file.
88 changes: 88 additions & 0 deletions tests/test_honeybee_energy_revive/properties/generator/test_pv.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
from unittest.mock import Mock

import pytest

from honeybee_energy_revive.properties.generator.pv import (
PVPropertiesReviveProperties,
PVPropertiesReviveProperties_FromDictError,
)


@pytest.fixture
def mock_host():
return Mock(display_name="Test PvProperties")


def test_pv_revive_properties_init(mock_host):
props = PVPropertiesReviveProperties(mock_host)
assert props.host == mock_host
assert props.id_num == 0


def test_pv_revive_properties_host_name(mock_host):
props = PVPropertiesReviveProperties(mock_host)
assert props.host_name == "Test PvProperties"

props_no_host = PVPropertiesReviveProperties()
assert props_no_host.host_name == "No Host"


def test_pv_revive_properties_duplicate(mock_host):
props = PVPropertiesReviveProperties(mock_host)
props.id_num = 5

new_host = Mock(display_name="Test PvProperties")
new_props = props.duplicate(new_host)
assert new_props.host == new_host
assert new_props.id_num == 5


def test_pv_revive_properties_to_dict(mock_host):
props = PVPropertiesReviveProperties(mock_host)
props.id_num = 5

expected_dict = {
"revive": {
"type": "PVPropertiesReviveProperties",
"id_num": 5,
"cost": 0.0,
"labor_fraction": 0.0,
"lifetime_years": 0,
}
}
assert props.to_dict() == expected_dict

expected_abridged_dict = {
"revive": {
"type": "PVPropertiesRevivePropertiesAbridged",
"id_num": 5,
"cost": 0.0,
"labor_fraction": 0.0,
"lifetime_years": 0,
}
}
assert props.to_dict(abridged=True) == expected_abridged_dict


def test_pv_revive_properties_from_dict(mock_host):
input_dict = {
"type": "PVPropertiesReviveProperties",
"id_num": 5,
"cost": 0.0,
"labor_fraction": 0.0,
"lifetime_years": 0,
}
props = PVPropertiesReviveProperties.from_dict(input_dict, mock_host)
assert props.host == mock_host
assert props.id_num == 5

with pytest.raises(PVPropertiesReviveProperties_FromDictError):
invalid_dict = {"type": "InvalidType", "id_num": 5}
PVPropertiesReviveProperties.from_dict(invalid_dict, mock_host)


def test_pv_revive_properties_str_repr(mock_host):
props = PVPropertiesReviveProperties(mock_host)
expected_str = "HBE-PVPropertiesRevive Phius REVIVE Property: [host: Test PvProperties]"
assert str(props) == expected_str
assert repr(props) == expected_str

0 comments on commit 0a7af8e

Please sign in to comment.