Exemplo n.º 1
0
def test_sample_json_4(mock_discovery_response):
    # setup
    mock_discovery_response(SAMPLE_JSON_4)

    # execution
    actual = get_last_reading(requests.Session(), "someMeterId")

    # evaluation
    assert actual.imported == 7328426.0000
    assert actual.exported == 7591011.0000
    assert actual.power == 6131.2
Exemplo n.º 2
0
def test_sample_json_3(mock_discovery_response):
    # setup
    mock_discovery_response(SAMPLE_JSON_3)

    # execution
    actual = get_last_reading(requests.Session(), "someMeterId")

    # evaluation
    assert actual.imported == 4308346.0817
    assert actual.powers == [-345, 575, -230]
    assert actual.exported == 29424345.6924
    assert actual.power == 460
    assert actual.currents == [-1.5, 2.5, -1.0]
Exemplo n.º 3
0
def test_sample_json_1(mock_discovery_response):
    # setup
    mock_discovery_response(SAMPLE_JSON_1)

    # execution
    actual = get_last_reading(requests.Session(), "someMeterId")

    # evaluation
    assert actual.currents == [5.0, 11.3, -1.15]
    assert actual.imported == 1259576.1479
    assert actual.powers == [1167.0, 2650.98, -230.0]
    assert actual.exported == 2554564.9812
    assert actual.voltages == [233.4, 234.6, 200.0]
    assert actual.power == 1234.567
Exemplo n.º 4
0
def test_sample_json_2(mock_discovery_response):
    # setup
    mock_discovery_response(SAMPLE_JSON_2)

    # execution
    actual = get_last_reading(requests.Session(), "someMeterId")

    # evaluation
    assert actual.imported == 2855297.6196
    assert actual.powers == [81.31, 241.97, 162.6]
    assert actual.exported == 769024.8872
    assert actual.voltages == [225.5, 226.4, 226.8]
    assert actual.power == 485.89
    assert list(map(partial(round, ndigits=2),
                    actual.currents)) == [0.36, 1.07, 0.72]
Exemplo n.º 5
0
 def update(self, session: Session):
     self.__persister(get_last_reading(session, self.__meter_id))