Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v 0.7.0 #246

Merged
merged 1 commit into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "gridworks-protocol"
version = "0.6.4"
version = "0.7.0"
description = "Gridworks Protocol"
authors = ["Jessica Millar <jmillar@gridworks-consulting.com>"]
license = "MIT"
Expand Down
1 change: 1 addition & 0 deletions src/gwproto/types/electric_meter_component_gt.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ def check_axiom_2(cls, v: dict) -> dict:
"Axiom 2: If EgaugeIoList has non-zero length then then the set of"
"output configs must equal ConfigList as a set"
)
return v

def as_dict(self) -> Dict[str, Any]:
"""
Expand Down
67 changes: 58 additions & 9 deletions tests/types/test_electric_meter_component_gt.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,54 @@

def test_electric_meter_component_gt_generated() -> None:
d = {
"ComponentId": "04ceb282-d7e8-4293-80b5-72455e1a5db3",
"ComponentAttributeClassId": "c1856e62-d8c0-4352-b79e-6ae05a5294c2",
"DisplayName": "Main power meter for Little orange house garage space heat",
"ConfigList": [],
"HwUid": "35941_308",
"ModbusHost": "eGauge4922.local",
"ComponentId": "2dfb0cb6-6015-4273-b02b-bd446cc785d7",
"ComponentAttributeClassId": "204832ef-0c88-408b-9640-264d2ee74914",
"DisplayName": "EGauge Power Meter",
"ConfigList": [
{
"AboutNodeName": "a.m.hp.outdoor.power",
"ReportOnChange": True,
"SamplePeriodS": 300,
"Exponent": 0,
"AsyncReportThreshold": 0.02,
"NameplateMaxValue": 3500,
"TypeName": "telemetry.reporting.config",
"Version": "000",
"TelemetryNameGtEnumSymbol": "af39eec9",
"UnitGtEnumSymbol": "f459a9c3",
}
],
"HwUid": "BP01349",
"ModbusHost": "eGauge6069.local",
"ModbusPort": 502,
"EgaugeIoList": [],
"EgaugeIoList": [
{
"InputConfig": {
"Address": 9006,
"Name": "",
"Description": "change in value",
"Type": "f32",
"Denominator": 1,
"Unit": "W",
"TypeName": "egauge.register.config",
"Version": "000",
},
"OutputConfig": {
"AboutNodeName": "a.m.hp.outdoor.power",
"ReportOnChange": True,
"SamplePeriodS": 300,
"Exponent": 0,
"AsyncReportThreshold": 0.02,
"NameplateMaxValue": 3500,
"TypeName": "telemetry.reporting.config",
"Version": "000",
"TelemetryNameGtEnumSymbol": "af39eec9",
"UnitGtEnumSymbol": "f459a9c3",
},
"TypeName": "egauge.io",
"Version": "000",
}
],
"TypeName": "electric.meter.component.gt",
"Version": "000",
}
Expand Down Expand Up @@ -102,8 +142,17 @@ def test_electric_meter_component_gt_generated() -> None:
Maker.dict_to_tuple(d2)

d2 = dict(d)
if "ModbusHost" in d2.keys():
del d2["ModbusHost"]
# Axiom 2: If EgaugeIoList has non-zero length then ModbusHost must exist!
del d2["ModbusHost"]
with pytest.raises(ValidationError):
Maker.dict_to_tuple(d2)

d2["ConfigList"] = []
# Axiom 2 part 2: If EgaugeIoList has non-zero length then it has the same length as ConfigList
with pytest.raises(ValidationError):
Maker.dict_to_tuple(d2)

d2["EgaugeIoList"] = []
Maker.dict_to_tuple(d2)

d2 = dict(d)
Expand Down