Esempio n. 1
0
def fixture_with_leaves():
    area = Area("house", [
        PV("pv1", panel_count=1, config=create_config()),
        PV("pv2", panel_count=4, config=create_config()),
        HomeMeter("home meter", home_meter_profile="some_path.csv", config=create_config()),
    ])
    return area_to_string(area)
Esempio n. 2
0
def test_area_with_children_roundtrip():
    child1 = Area("child1")
    child2 = Area("child2")
    parent = Area("parent", [child1, child2])
    string = area_to_string(parent)
    recovered = area_from_string(string)
    assert recovered.name == "parent"
    assert recovered.children[0].name == "child1"
    assert recovered.children[1].name == "child2"
Esempio n. 3
0
def appliance_fixture():
    child1 = Area('child1', appliance=PVAppliance(initially_on=False))
    child2 = Area('child2', appliance=PVAppliance())
    return area_to_string(Area('parent', [child1, child2]))
Esempio n. 4
0
def test_non_attr_param():
    area1 = Area('area1', [], None, PVStrategy())
    recovered1 = area_from_string(area_to_string(area1))
    assert recovered1.strategy.max_panel_power_W is None
    assert recovered1.strategy.offer_update.final_rate[area1.config.start_date] == \
        ConstSettings.PVSettings.SELLING_RATE_RANGE.final
Esempio n. 5
0
def test_strategy_roundtrip_with_params():
    area = Area('area', [], None, PVStrategy(panel_count=42))
    area_str = area_to_string(area)
    recovered = area_from_string(area_str)
    assert recovered.strategy.panel_count == 42
Esempio n. 6
0
def test_strategy_appliance_roundtrip():
    area = Area("child", [], None, PVStrategy(), PVAppliance())
    recovered = area_from_string(area_to_string(area))
    assert type(recovered.strategy) is PVStrategy
    assert type(recovered.appliance) is PVAppliance
Esempio n. 7
0
def test_encode_strategy_appliance():
    area = Area("child", [], None, PVStrategy(), PVAppliance())
    area_dict = json.loads(area_to_string(area))
    assert 'children' not in area_dict
    assert area_dict['strategy']['type'] == 'PVStrategy'
    assert area_dict['appliance']['type'] == 'PVAppliance'
Esempio n. 8
0
def budget_keeper_fixture():
    child = Area('child', appliance=PVAppliance())
    budget_keeper = BudgetKeeper(budget=100.0, days_per_period=30)
    return area_to_string(Area('parent', [child], budget_keeper=budget_keeper))
Esempio n. 9
0
def fixture_with_leaves():
    area = Area("house", [PV("pv1", panel_count=1), PV("pv2", panel_count=4)])
    return area_to_string(area)
Esempio n. 10
0
def test_non_attr_param():
    area1 = Area('area1', [], PVStrategy())
    recovered1 = area_from_string(area_to_string(area1))
    assert recovered1.strategy.min_selling_rate == ConstSettings.PVSettings.MIN_SELLING_RATE
Esempio n. 11
0
def test_strategy_roundtrip_with_params():
    area = Area('area', [], PVStrategy(panel_count=42, risk=1))
    area_str = area_to_string(area)
    assert json.loads(area_str)['strategy']['kwargs']['risk'] == 1
    recovered = area_from_string(area_str)
    assert recovered.strategy.panel_count == 42