示例#1
0
    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
示例#2
0
def code(doc: element.Element) -> element.Element:
    code_node = doc.find('Codes')
    assert code_node is not None
    return code_node
示例#3
0
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
示例#4
0
def house(doc: element.Element) -> element.Element:
    house_node = doc.find('House')
    assert house_node is not None
    return house_node
示例#5
0
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>'
示例#6
0
def test_find_returns_none(fragment_node: element.Element) -> None:
    assert fragment_node.find('Baz') is None
示例#7
0
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'
示例#8
0
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