# Path: calliope/test/common/util.py
# def build_test_model(
#     override_dict=None,
#     scenario=None,
#     model_file="model.yaml",
#     timeseries_dataframes=None,
# ):
#     return calliope.Model(
#         os.path.join(os.path.dirname(__file__), "test_model", model_file),
#         override_dict=override_dict,
#         scenario=scenario,
#         timeseries_dataframes=timeseries_dataframes,
#     )
# 
# Path: calliope/test/common/util.py
# def check_error_or_warning(error_warning, test_string_or_strings):
#     if hasattr(error_warning, "list"):
#         output = ",".join(
#             str(error_warning.list[i]) for i in range(len(error_warning.list))
#         )
#     else:
#         output = str(error_warning.value)
# 
#     if isinstance(test_string_or_strings, list):
#         result = all(test_string in output for test_string in test_string_or_strings)
#     else:
#         result = test_string_or_strings in output
# 
#     return result


import pytest  # pylint: disable=unused-import
import pyomo.core as po
import calliope
import calliope.exceptions as exceptions
from pytest import approx
from calliope.test.common.util import build_test_model as build_model
from calliope.test.common.util import check_error_or_warning
                ("a", "test_supply_elec")
            ]
            == 30
        )

    def test_update_param_multiple_dim(self, model):
        """
        test that the function update_param works with multiple dimensions
        """
        time = model._backend_model.timesteps[1]
        model.backend.update_param(
            "resource",
            {("a", "test_demand_elec", time): -10},
        )

        assert (
            model._backend_model.resource.extract_values()[
                ("a", "test_demand_elec", time)
            ]
            == -10
        )

    def test_unknown_param(self, model):
        """
        Raise error on unknown param
        """

        with pytest.raises(exceptions.ModelError) as excinfo:
            model.backend.update_param("unknown_param", {("b", "test_supply_elec"): 20})


# Path: calliope/test/common/util.py
# def build_test_model(
#     override_dict=None,
#     scenario=None,
#     model_file="model.yaml",
#     timeseries_dataframes=None,
# ):
#     return calliope.Model(
#         os.path.join(os.path.dirname(__file__), "test_model", model_file),
#         override_dict=override_dict,
#         scenario=scenario,
#         timeseries_dataframes=timeseries_dataframes,
#     )
# 
# Path: calliope/test/common/util.py
# def check_error_or_warning(error_warning, test_string_or_strings):
#     if hasattr(error_warning, "list"):
#         output = ",".join(
#             str(error_warning.list[i]) for i in range(len(error_warning.list))
#         )
#     else:
#         output = str(error_warning.value)
# 
#     if isinstance(test_string_or_strings, list):
#         result = all(test_string in output for test_string in test_string_or_strings)
#     else:
#         result = test_string_or_strings in output
# 
#     return result


# Path: calliope/test/test_backend_pyomo_interface.py
import pytest  # pylint: disable=unused-import
import pyomo.core as po
import calliope
import calliope.exceptions as exceptions
from pytest import approx
from calliope.test.common.util import build_test_model as build_model
from calliope.test.common.util import check_error_or_warning

                ("a", "test_supply_elec")
            ]
            == 30
        )

    def test_update_param_multiple_dim(self, model):
        """
        test that the function update_param works with multiple dimensions
        """
        time = model._backend_model.timesteps[1]
        model.backend.update_param(
            "resource",
            {("a", "test_demand_elec", time): -10},
        )

        assert (
            model._backend_model.resource.extract_values()[
                ("a", "test_demand_elec", time)
            ]
            == -10
        )

    def test_unknown_param(self, model):
        """
        Raise error on unknown param
        """

        with pytest.raises(exceptions.ModelError) as excinfo:
            model.backend.update_param("unknown_param", {("b", "test_supply_elec"): 20})


        assert check_error_or_warning(