Skip to content

Commit

Permalink
Merge pull request #2 from AdamFinkle/add_greenbutton
Browse files Browse the repository at this point in the history
Ran linter and corrected typing.
  • Loading branch information
AdamFinkle authored Jul 3, 2024
2 parents a52ebab + 999aab3 commit cf0346d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 20 deletions.
6 changes: 3 additions & 3 deletions rules-engine/src/rules_engine/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
NaturalGasBillingInput,
NaturalGasBillingRecordInput,
ElectricBillingInput,
ElectricBillingRecordInput
ElectricBillingRecordInput,
)


Expand Down Expand Up @@ -209,7 +209,7 @@ def _parse_gas_bill_xml(path: str) -> NaturalGasBillingInput:
return NaturalGasBillingInput(records=records)


def _parse_electric_bill_xml(path: str) -> NaturalGasBillingInput:
def _parse_electric_bill_xml(path: str) -> ElectricBillingInput:
"""
Return a list of gas bill data parsed from a Green Button XML
received as a string.
Expand All @@ -230,4 +230,4 @@ def _parse_electric_bill_xml(path: str) -> NaturalGasBillingInput:
)
)

return ElectricBillingInput(records=records)
return ElectricBillingInput(records=records)
36 changes: 20 additions & 16 deletions rules-engine/tests/test_rules_engine/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from rules_engine import parser
from rules_engine.pydantic_models import (
NaturalGasBillingRecordInput,
ElectricBillingRecordInput
ElectricBillingRecordInput,
)

ROOT_DIR = pathlib.Path(__file__).parent / "cases" / "examples"
Expand All @@ -29,22 +29,26 @@ def _read_gas_bill_national_grid() -> str:

def _get_gas_bill_xml_path() -> pathlib.Path:
"""Return the path of a test natural gas XML bill"""
return (pathlib.Path(__file__).parent
/ "cases"
/ "parsing"
/ "xml"
/ "natural_gas"
/ "ngma_natural_gas_billing_billing_data_Service 1_1_2021-05-26_to_2024-04-25.xml")
return (
pathlib.Path(__file__).parent
/ "cases"
/ "parsing"
/ "xml"
/ "natural_gas"
/ "ngma_natural_gas_billing_billing_data_Service 1_1_2021-05-26_to_2024-04-25.xml"
)


def _get_electric_bill_xml_path() -> pathlib.Path:
"""Return the path of a test natural gas XML bill"""
return (pathlib.Path(__file__).parent
/ "cases"
/ "parsing"
/ "xml"
/ "electricicity"
/ "TestGBDataHourlyNineDaysBinnedDaily.xml")
return (
pathlib.Path(__file__).parent
/ "cases"
/ "parsing"
/ "xml"
/ "electricicity"
/ "TestGBDataHourlyNineDaysBinnedDaily.xml"
)


def _validate_eversource(result):
Expand Down Expand Up @@ -141,14 +145,14 @@ def test_parse_gas_bill_national_grid():

def test_parse_gas_bill_xml():
"""Tests parsing a natural gas bill from a Green Button XML."""
_validate_gas_bill_xml(
parser._parse_gas_bill_xml(_get_gas_bill_xml_path()))
_validate_gas_bill_xml(parser._parse_gas_bill_xml(_get_gas_bill_xml_path()))


def test_parse_electric_bill_xml():
"""Tests parsing an electricicity bill from a Green Button XML."""
_validate_electric_bill_xml(
parser._parse_electric_bill_xml(_get_electric_bill_xml_path()))
parser._parse_electric_bill_xml(_get_electric_bill_xml_path())
)


def test_detect_natural_gas_company():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
NaturalGasBillingInput,
NaturalGasBillingRecordInput,
ElectricBillingInput,
ElectricBillingRecordInput
ElectricBillingRecordInput,
)

_EXAMPLE_VALID_RECORDS_NATURAL_GAS = NaturalGasBillingInput(
Expand Down

0 comments on commit cf0346d

Please sign in to comment.