def test_list_max_yes_identifier_no_target_raises(schema, composite):
    with pytest.raises(ValueError):
        CrossSectionalMaximum(schema, {},
                              list_in_root,
                              target_int,
                              argument=int_in_list,
                              identifier=text_in_list)
def test_keyed_list_explicit_identifier_raises(schema):
    with pytest.raises(ValueError):
        CrossSectionalMaximum(schema, {},
                              kl_in_root,
                              target_decimal,
                              argument=decimal_in_kl,
                              identifier=text_in_kl)
def test_keyed_list_max_no_id_target(schema, composite):
    change: Change = CrossSectionalMaximum(schema, {},
                                           kl_in_root,
                                           target_decimal,
                                           argument=decimal_in_kl)
    expected: Dict = copy.deepcopy(composite.content)
    expected["populated"]["targets"] = {"target_decimal": 100.6}
    change(composite)
    assert composite.content == expected
def test_disable_identifier_list_max(schema, composite):
    change: Change = CrossSectionalMaximum(schema, {},
                                           list_in_root,
                                           target_int,
                                           argument=int_in_list)

    expected: Dict = copy.deepcopy(composite.content)
    expected["populated"]["targets"] = {"target_integer": 75}
    change(composite)
    assert composite.content == expected
def test_empty_keyed_list_keyed_list_max(schema, composite):
    change: Change = CrossSectionalMaximum(schema, {},
                                           kl_in_root,
                                           target_decimal,
                                           argument=decimal_in_kl,
                                           identifier_target=target_text)
    composite.content["populated"]["the_keyed_list"] = {}
    expected: Dict = copy.deepcopy(composite.content)
    change(composite)
    assert composite.content == expected
def test_all_values_missing_keyed_list_max(schema, composite):
    change: Change = CrossSectionalMaximum(schema, {},
                                           kl_in_root,
                                           target_decimal,
                                           argument=decimal_in_kl,
                                           identifier_target=target_text)
    tkl: Dict = composite.content["populated"]["the_keyed_list"]
    for key in tkl.keys():
        tkl[key] = {}
    expected: Dict = copy.deepcopy(composite.content)
    change(composite)
    assert composite.content == expected
def test_empty_list_list_max(schema, composite):
    change: Change = CrossSectionalMaximum(schema, {},
                                           list_in_root,
                                           target_int,
                                           argument=int_in_list,
                                           identifier=text_in_list,
                                           identifier_target=target_text)
    del composite.content["populated"]["the_list"]

    expected: Dict = copy.deepcopy(composite.content)
    change(composite)
    assert composite.content == expected
def test_keyed_list_max(schema, composite):
    change: Change = CrossSectionalMaximum(schema, {},
                                           kl_in_root,
                                           target_decimal,
                                           argument=decimal_in_kl,
                                           identifier_target=target_text)
    expected: Dict = copy.deepcopy(composite.content)
    expected["populated"]["targets"] = {
        "target_decimal": 100.6,
        "target_text": "green"
    }
    change(composite)
    assert composite.content == expected
def test_all_values_missing_list_max(schema, composite):
    change: Change = CrossSectionalMaximum(schema, {},
                                           list_in_root,
                                           target_int,
                                           argument=int_in_list,
                                           identifier=text_in_list,
                                           identifier_target=target_text)
    for i in range(3):
        del composite.content["populated"]["the_list"][i]["the_integer"]

    expected: Dict = copy.deepcopy(composite.content)
    change(composite)
    assert composite.content == expected
def test_identifier_missing_list_max(schema, composite):
    change: Change = CrossSectionalMaximum(schema, {},
                                           list_in_root,
                                           target_int,
                                           argument=int_in_list,
                                           identifier=text_in_list,
                                           identifier_target=target_text)
    del composite.content["immutable"]["the_list"][0]["the_text"]

    expected: Dict = copy.deepcopy(composite.content)
    expected["immutable"]["targets"] = {"target_integer": 75}
    change(composite)
    assert composite.content == expected
def test_list_max(schema, composite):
    change: Change = CrossSectionalMaximum(schema, {},
                                           list_in_root,
                                           target_int,
                                           argument=int_in_list,
                                           identifier=text_in_list,
                                           identifier_target=target_text)
    change(composite)

    expected: Dict = copy.deepcopy(composite.content)
    expected["populated"]["targets"] = {
        "target_integer": 75,
        "target_text": "a"
    }
    assert composite.content == expected
def test_one_value_missing_keyed_list_max(schema, composite):
    change: Change = CrossSectionalMaximum(schema, {},
                                           kl_in_root,
                                           target_decimal,
                                           argument=decimal_in_kl,
                                           identifier_target=target_text)
    del composite.content["populated"]["the_keyed_list"]["green"][
        "the_decimal"]
    expected: Dict = copy.deepcopy(composite.content)
    expected["populated"]["targets"] = {
        "target_decimal": 0.7,
        "target_text": "red"
    }
    change(composite)
    assert composite.content == expected
def test_one_value_none_list_max(schema, composite):
    change: Change = CrossSectionalMaximum(schema, {},
                                           list_in_root,
                                           target_int,
                                           argument=int_in_list,
                                           identifier=text_in_list,
                                           identifier_target=target_text)
    composite.content["populated"]["the_list"][0]["the_integer"] = None

    expected: Dict = copy.deepcopy(composite.content)
    expected["populated"]["targets"] = {
        "target_integer": 0,
        "target_text": "b"
    }
    change(composite)
    assert composite.content == expected