def test_check_profile_description(default_case):
    """
    Ensures that the ProfileDescription only accepts either XAndYDescription or a LengthAndElevationDescription

    Check 1: length_and_elevation and x_and_y are mutually exclusive
    """
    msg = (
        "length_and_elevation and x_and_y are mutually exclusive and you must configure only one of them, got "
        "length_and_elevation=LengthAndElevationDescription(length=Array(length, [0.0, 5.0, 7.0], m), elevation=Array(length, [1.0, 1.0, 1.0], m)) "
        "and x_and_y=XAndYDescription(x=Array(length, [1.0, 10.0, 100.0], m), y=Array(length, [42.0, 42.0, 42.0], m))"
    )
    with pytest.raises(ValueError, match=re.escape(msg)):
        case_description.ProfileDescription(
            length_and_elevation=case_description.
            LengthAndElevationDescription(length=Array([0.0, 5.0, 7.0], "m"),
                                          elevation=Array([1.0] * 3, "m")),
            x_and_y=case_description.XAndYDescription(
                x=Array([1.0, 10.0, 100.0], "m"), y=Array([42.0] * 3, "m")),
        )

    # Empty Profile is allowed.
    profile = case_description.ProfileDescription(length_and_elevation=None,
                                                  x_and_y=None)
    assert profile.length_and_elevation is None
    assert profile.x_and_y is None

    # Empty Array is allowed
    profile_2 = case_description.ProfileDescription(
        length_and_elevation=case_description.LengthAndElevationDescription(
            length=Array([], "m"), elevation=Array([], "m")),
        x_and_y=None,
    )
    assert profile_2.x_and_y is None
    assert profile_2.length_and_elevation.length.GetValues("m") == []
    assert profile_2.length_and_elevation.elevation.GetValues("m") == []
def default_well() -> case_description.WellDescription:
    """
    Minimum valid WellDescription
    """
    return case_description.WellDescription(
        name="Well 1",
        profile=case_description.ProfileDescription(
            length_and_elevation=case_description.LengthAndElevationDescription(
                length=Array([0.0] + [1000] * 2, "m"),
                elevation=Array([0.0] + [1.2] * 2, "m"),
            )
        ),
        stagnant_fluid="Lift Gas",
        top_node="Node 1",
        bottom_node="Node 2",
        annulus=case_description.AnnulusDescription(
            has_annulus_flow=False, top_node="Node 1"
        ),
        formation=case_description.FormationDescription(
            reference_y_coordinate=Scalar(0, "m")
        ),
        environment=case_description.EnvironmentDescription(
            thermal_model=constants.PipeThermalModelType.SteadyState
        ),
    )
def test_get_value_and_unit_from_length_and_elevation_description_and_xand_ydescription(
):
    """
    Ensure that GetValueAndUnit returns a pair of values along with their units.
    """
    length_and_elevation = case_description.LengthAndElevationDescription(
        length=Array([0.0, 5.0, 7.0], "m"), elevation=Array([1.0] * 3, "m"))
    assert list(length_and_elevation.iter_values_and_unit()) == [
        ((0.0, "m"), (1.0, "m")),
        ((5.0, "m"), (1.0, "m")),
        ((7.0, "m"), (1.0, "m")),
    ]
    x_and_y = case_description.XAndYDescription(x=Array([1.0, 10.0, 100.0],
                                                        "m"),
                                                y=Array([42.0] * 3, "m"))
    assert list(x_and_y.iter_values_and_unit()) == [
        ((1.0, "m"), (42.0, "m")),
        ((10.0, "m"), (42.0, "m")),
        ((100.0, "m"), (42.0, "m")),
    ]
    profile=PROFILE_DESCRIPTION_WITH_XY,
    pvt_model="gavea",
    segments=PIPE_WALL_DESCRIPTION,
    source="mass_source_node",
    target="pressure_node",
)
FORMATION_LAYER_DESCRIPTION = case_description.FormationLayerDescription(
    name="f", start=Scalar(1, "m"), material="Carbon Steel"
)
FORMATION_DESCRIPTION = case_description.FormationDescription(
    reference_y_coordinate=Scalar(1, "m"),
    layers=[FORMATION_LAYER_DESCRIPTION, FORMATION_LAYER_DESCRIPTION],
)

LENGTH_AND_ELEVATION_DESCRIPTION = case_description.LengthAndElevationDescription(
    length=Array([0, 1, 2], "m"), elevation=Array([0, 0.5, 1], "m")
)
PROFILE_DESCRIPTION_WITH_LENGTH_AND_ELEVATION_DESCRIPTION = (
    case_description.ProfileDescription(
        length_and_elevation=LENGTH_AND_ELEVATION_DESCRIPTION
    )
)
WELL_DESCRIPTION = case_description.WellDescription(
    name="Wellbore",
    pvt_model="gavea",
    stagnant_fluid="Lift Gas",
    profile=PROFILE_DESCRIPTION_WITH_LENGTH_AND_ELEVATION_DESCRIPTION,
    casing=CASING_DESCRIPTION,
    annulus=ANNULUS_DESCRIPTION,
    formation=FORMATION_DESCRIPTION,
    top_node="mass_source_node",