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

Ran linter and corrected typing. #2

Merged
merged 1 commit into from
Jul 3, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading