def _get_output_size(cls, node: element.Element) -> float: capacity_node = node.find('Type1/*/Specifications/OutputCapacity') assert capacity_node is not None try: units = capacity_node.get('@uiUnits', str) capacity_value = capacity_node.get('@value', float) except ElementGetValueError as exc: raise InvalidEmbeddedDataTypeError( Heating, 'Invalid/missing attribute values') from exc capacity: typing.Optional[float] if units == 'kW': capacity = capacity_value elif units == 'btu/hr' or units == 'btu/h': capacity = capacity_value / cls._KWH_TO_BTU else: raise InvalidEmbeddedDataTypeError( Heating, f'Unknown capacity units: {units}') assert capacity is not None return capacity
def code(doc: element.Element) -> element.Element: code_node = doc.find('Codes') assert code_node is not None return code_node
def energy_upgrades(doc: element.Element) -> element.Element: energy_upgrades_node = doc.find('EnergyUpgrades') assert energy_upgrades_node is not None return energy_upgrades_node
def house(doc: element.Element) -> element.Element: house_node = doc.find('House') assert house_node is not None return house_node
def test_to_string(fragment_node: element.Element) -> None: bar_node = fragment_node.find('Bar') assert bar_node assert bar_node.to_string() == '<Bar id="1">baz</Bar>'
def test_find_returns_none(fragment_node: element.Element) -> None: assert fragment_node.find('Baz') is None
def test_find(fragment_node: element.Element) -> None: bar_node = fragment_node.find('Bar') assert bar_node assert bar_node.tag == 'Bar' assert bar_node.attrib['id'] == '1'
def test_attrib(fragment_node: element.Element) -> None: bar_node = fragment_node.find('Bar') assert bar_node assert bar_node.attrib['id'] == '1' assert 'baz' not in bar_node.attrib