from idaes.power_generation.costing.power_plant_costing import \
    (get_sCO2_unit_cost,
     get_PP_costing,
     get_ASU_cost,
     build_flowsheet_cost_constraint,
     costing_initialization)
from idaes.core.util.model_statistics import (degrees_of_freedom)
import pyomo.environ as pyo
from idaes.generic_models.properties import iapws95
from idaes.generic_models.properties import swco2
from idaes.core import FlowsheetBlock

solver_available = pyo.SolverFactory('ipopt').available()
prop_available = iapws95.iapws95_available()
prop2_available = swco2.swco2_available()


@pytest.mark.component
@pytest.mark.solver
@pytest.mark.skipif(not prop_available, reason="IAPWS not available")
@pytest.mark.skipif(not solver_available, reason="Solver not available")
def test_PP_costing():
    # Create a Concrete Model as the top level object
    m = pyo.ConcreteModel()

    # Add a flowsheet object to the model
    m.fs = FlowsheetBlock(default={"dynamic": False})
    m.fs.get_costing(year='2018')

    # check that the model solved properly and has 0 degrees of freedom
import pytest
from pyomo.environ import ConcreteModel, value, SolverFactory, units as pyunits
import idaes.generic_models.properties.swco2 as swco2
from idaes.generic_models.unit_models import Compressor
from idaes.core import FlowsheetBlock
import idaes

if SolverFactory('ipopt').available():
    solver = SolverFactory('ipopt')
    solver.options = {'tol': 1e-6}
else:
    solver = None


@pytest.mark.skipif(not swco2.swco2_available(),
                    reason="Library not available")
class TestIntegration(object):
    @pytest.fixture(scope="class")
    def compressor_model(self):
        m = ConcreteModel()
        m.fs = FlowsheetBlock(default={"dynamic": False})
        m.fs.properties = swco2.SWCO2ParameterBlock()
        m.fs.unit = Compressor(default={"property_package": m.fs.properties})
        return m

    @pytest.mark.solver
    @pytest.mark.skipif(solver is None, reason="Solver not available")
    @pytest.mark.unit
    def test_verify(self, compressor_model):
        model = compressor_model
from pyomo.common.fileutils import this_file_dir
import idaes.generic_models.properties.swco2 as swco2
from idaes.generic_models.properties.swco2 import swco2_available
from idaes.generic_models.unit_models import Compressor
from idaes.core import FlowsheetBlock
import csv
import os
import idaes

if SolverFactory('ipopt').available():
    solver = SolverFactory('ipopt')
    solver.options = {'tol': 1e-6}
else:
    solver = None

@pytest.mark.skipif(not swco2_available(), reason="Span-Wagner lib not available")
class TestSWCO2(object):

    @pytest.fixture(scope="class")
    def model2(self):
        model = ConcreteModel()
        model.prop_param = swco2.SWCO2ParameterBlock()
        model.prop_in = swco2.SWCO2StateBlock(
            default={"parameters": model.prop_param}
        )
        return model

    @pytest.mark.unit
    def test_transport(self, model2):
        """Transport property tests
        """