Skip to content

Commit

Permalink
Updating marks on some tests (#857)
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Lee authored May 20, 2022
1 parent 0dd7d3e commit e276cde
Show file tree
Hide file tree
Showing 14 changed files with 44 additions and 38 deletions.
3 changes: 0 additions & 3 deletions idaes/models/properties/cubic_eos/tests/test_BT_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@

# -----------------------------------------------------------------------------
# Run test harness
@pytest.mark.unit
class TestBasicLV(PropertyTestHarness):
def configure(self):
self.prop_pack = BT_PR.BTParameterBlock
Expand All @@ -51,7 +50,6 @@ def configure(self):
self.has_density_terms = True


@pytest.mark.unit
class TestBasicL(PropertyTestHarness):
def configure(self):
self.prop_pack = BT_PR.BTParameterBlock
Expand All @@ -60,7 +58,6 @@ def configure(self):
self.has_density_terms = True


@pytest.mark.unit
class TestBasicV(PropertyTestHarness):
def configure(self):
self.prop_pack = BT_PR.BTParameterBlock
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ def _as_quantity(x):
return value(x) * unit._get_pint_unit()


@pytest.mark.unit
class TestASUPR(PropertyTestHarness):
def configure(self):
self.prop_pack = GenericParameterBlock
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ def _as_quantity(x):
return value(x) * unit._get_pint_unit()


@pytest.mark.unit
class TestASUPR(PropertyTestHarness):
def configure(self):
self.prop_pack = GenericParameterBlock
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ def _as_quantity(x):
return value(x) * unit._get_pint_unit()


@pytest.mark.unit
class TestBTIdeal(PropertyTestHarness):
def configure(self):
self.prop_pack = GenericParameterBlock
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ def _as_quantity(x):
}


@pytest.mark.unit
class TestBTIdeal_FPhx(PropertyTestHarness):
def configure(self):
self.prop_pack = GenericParameterBlock
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ def _as_quantity(x):
}


@pytest.mark.unit
class TestBTIdeal_FcPh(PropertyTestHarness):
def configure(self):
self.prop_pack = GenericParameterBlock
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ def _as_quantity(x):
}


@pytest.mark.unit
class TestBTIdeal_FcTP(PropertyTestHarness):
def configure(self):
self.prop_pack = GenericParameterBlock
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
solver.options["max_iter"] = 50


@pytest.mark.unit
class TestBTPR(PropertyTestHarness):
def configure(self):
self.prop_pack = GenericParameterBlock
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ def model(self):

return model

@pytest.mark.unit
@pytest.mark.integration
def test_build(self, model):
# Check state variable values and bounds
assert isinstance(model.props[1].flow_mol, Var)
Expand Down Expand Up @@ -287,23 +287,23 @@ def test_build(self, model):
def test_unit_consistency(self, model):
assert_units_consistent(model)

@pytest.mark.unit
@pytest.mark.integration
def test_define_state_vars(self, model):
sv = model.props[1].define_state_vars()

assert len(sv) == 4
for i in sv:
assert i in ["flow_mol", "mole_frac_comp", "temperature", "pressure"]

@pytest.mark.unit
@pytest.mark.integration
def test_define_port_members(self, model):
sv = model.props[1].define_state_vars()

assert len(sv) == 4
for i in sv:
assert i in ["flow_mol", "mole_frac_comp", "temperature", "pressure"]

@pytest.mark.unit
@pytest.mark.integration
def test_define_display_vars(self, model):
sv = model.props[1].define_display_vars()

Expand Down Expand Up @@ -379,6 +379,6 @@ def test_solution(self, model):
0.77026, abs=1e-4
)

@pytest.mark.unit
@pytest.mark.integration
def test_report(self, model):
model.props[1].report()
32 changes: 28 additions & 4 deletions idaes/models/properties/tests/test_harness.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,66 +74,76 @@ def frame(self):

m.fs.params = self.prop_pack(default=self.param_args)

m.fs.props = m.fs.params.build_state_block(
[1], default={"defined_state": True, **m.prop_args}
)

return m

@pytest.mark.unit
def test_param_block(self, frame):
if not isinstance(frame.fs.params, PhysicalParameterBlock):
raise TypeError(
"Parameter Block does not inherit from PhysicalParameterBlock"
)

@pytest.mark.unit
def test_component_list(self, frame):
if not isinstance(frame.fs.params.component_list, Set):
raise TypeError(
"Parameter block does not have a component_list, or "
"component_list is not a Pyomo Set."
)

@pytest.mark.unit
def test_phase_list(self, frame):
if not isinstance(frame.fs.params.phase_list, Set):
raise TypeError(
"Parameter block does not have a phase_list, or "
"phase_list is not a Pyomo Set."
)

@pytest.mark.unit
def test_state_block_class(self, frame):
if not hasattr(frame.fs.params, "state_block_class"):
raise AttributeError("Parameter block does not specify state_block_class.")

@pytest.mark.unit
def test_properties_meta_data(self, frame):
if frame.fs.params.get_metadata().properties is None:
raise AttributeError(
"Parameter block has not specified properties metadata."
)

@pytest.mark.unit
def test_default_units_meta_data(self, frame):
if frame.fs.params.get_metadata().default_units is None:
raise AttributeError(
"Parameter block has not specified default_units metadata."
)

@pytest.mark.unit
def test_state_block_construction(self, frame):
frame.fs.props = frame.fs.params.build_state_block(
[1], default={"defined_state": True, **frame.prop_args}
)

if not isinstance(frame.fs.props[1], StateBlockData):
raise TypeError("State Block does not inherit from StateBlockData.")

@pytest.mark.unit
def test_state_block_temperature(self, frame):
if not isinstance(frame.fs.props[1].temperature, (Var, Expression)):
raise AttributeError(
"State Block does not contain temperature, or temperature is "
"not a Pyomo Var or Expression."
)

@pytest.mark.unit
def test_state_block_pressure(self, frame):
if not isinstance(frame.fs.props[1].pressure, (Var, Expression)):
raise AttributeError(
"State Block does not contain pressure, or pressure is "
"not a Pyomo Var or Expression."
)

@pytest.mark.unit
def test_state_block_mole_frac_phase_comp(self, frame):
if not isinstance(frame.fs.props[1].mole_frac_phase_comp, (Var, Expression)):
raise AttributeError(
Expand All @@ -158,6 +168,7 @@ def test_state_block_mole_frac_phase_comp(self, frame):
"mole_frac_phase_comp is not indexed by phase and component."
)

@pytest.mark.unit
def test_get_material_flow_terms(self, frame):
try:
for p, j in frame.fs.params._phase_component_set:
Expand All @@ -174,6 +185,7 @@ def test_get_material_flow_terms(self, frame):
"State block has not implemented get_material_flow_terms " "method."
)

@pytest.mark.unit
def test_get_enthalpy_flow_terms(self, frame):
try:
for p in frame.fs.params.phase_list:
Expand All @@ -187,6 +199,7 @@ def test_get_enthalpy_flow_terms(self, frame):
"State block has not implemented get_enthalpy_flow_terms " "method."
)

@pytest.mark.unit
def test_get_material_density_terms(self, frame):
if frame.has_density_terms:
try:
Expand All @@ -206,6 +219,7 @@ def test_get_material_density_terms(self, frame):
"get_material_density_terms method."
)

@pytest.mark.unit
def test_get_energy_density_terms(self, frame):
if frame.has_density_terms:
try:
Expand All @@ -222,18 +236,22 @@ def test_get_energy_density_terms(self, frame):
"get_enthalpy_density_terms method."
)

@pytest.mark.unit
def test_default_material_balance_type(self, frame):
if frame.fs.props[1].default_material_balance_type() not in MaterialBalanceType:
raise ValueError("Invalid value for default_material_balance_type.")

@pytest.mark.unit
def test_default_energy_balance_type(self, frame):
if frame.fs.props[1].default_energy_balance_type() not in EnergyBalanceType:
raise ValueError("Invalid value for default_energy_balance_type.")

@pytest.mark.unit
def test_get_material_flow_basis(self, frame):
if frame.fs.props[1].get_material_flow_basis() not in MaterialFlowBasis:
raise ValueError("Invalid value for get_material_flow_basis.")

@pytest.mark.unit
def test_define_state_vars(self, frame):
try:
sv = frame.fs.props[1].define_state_vars()
Expand All @@ -252,9 +270,11 @@ def test_define_state_vars(self, frame):
"be Pyomo Vars.".format(v)
)

@pytest.mark.component
def test_unit_consistency(self, frame):
assert_units_consistent(frame)

@pytest.mark.component
def test_initialize(self, frame):
frame._init_dof = degrees_of_freedom(frame.fs.props[1])

Expand All @@ -273,6 +293,7 @@ def test_initialize(self, frame):
"degrees of freedom."
)

@pytest.mark.component
def test_release_state(self, frame):
if not hasattr(frame.fs.props, "release_state") or not callable(
frame.fs.props.release_state
Expand All @@ -289,6 +310,7 @@ def test_release_state(self, frame):
"degrees of freedom."
)

@pytest.mark.component
def test_initialize_failure(self, frame):
if not frame.skip_initialization_raises_exception_test:
for n, v in frame.fs.props[1].define_state_vars().items():
Expand All @@ -308,6 +330,7 @@ def test_initialize_failure(self, frame):
for i in v:
frame.fs.props[1].del_component("_init_test_" + str(v) + str(i))

@pytest.mark.component
def test_CV_integration(self, frame):
frame.fs.cv = ControlVolume0DBlock(
default={"property_package": frame.fs.params}
Expand All @@ -323,6 +346,7 @@ def test_CV_integration(self, frame):

frame.fs.cv.add_momentum_balances()

@pytest.mark.component
def test_default_scaling_factors(self, frame):
# check that the calculate_scaling_factors method successfully copies
# the default scaling factors to the scaling suffixes. If there are
Expand Down
5 changes: 0 additions & 5 deletions idaes/models/properties/tests/test_iapws95_with_harness.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@
import pytest
import idaes.models.properties.iapws95 as iapws95
from idaes.models.properties.tests.test_harness import PropertyTestHarness
import pyomo.environ as pyo


@pytest.mark.unit
class TestBasicMix(PropertyTestHarness):
def configure(self):
self.prop_pack = iapws95.Iapws95ParameterBlock
Expand All @@ -30,7 +28,6 @@ def configure(self):
self.skip_initialization_raises_exception_test = True


@pytest.mark.unit
class TestBasicLV(PropertyTestHarness):
def configure(self):
self.prop_pack = iapws95.Iapws95ParameterBlock
Expand All @@ -41,7 +38,6 @@ def configure(self):
self.skip_initialization_raises_exception_test = True


@pytest.mark.unit
class TestBasicL(PropertyTestHarness):
def configure(self):
self.prop_pack = iapws95.Iapws95ParameterBlock
Expand All @@ -52,7 +48,6 @@ def configure(self):
self.skip_initialization_raises_exception_test = True


@pytest.mark.unit
class TestBasicV(PropertyTestHarness):
def configure(self):
self.prop_pack = iapws95.Iapws95ParameterBlock
Expand Down
5 changes: 0 additions & 5 deletions idaes/models/properties/tests/test_swco2_with_harness.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@
import pytest
import idaes.models.properties.swco2 as swco2
from idaes.models.properties.tests.test_harness import PropertyTestHarness
import pyomo.environ as pyo


@pytest.mark.unit
class TestBasicMix(PropertyTestHarness):
def configure(self):
self.prop_pack = swco2.SWCO2ParameterBlock
Expand All @@ -30,7 +28,6 @@ def configure(self):
self.skip_initialization_raises_exception_test = True


@pytest.mark.unit
class TestBasicLV(PropertyTestHarness):
def configure(self):
self.prop_pack = swco2.SWCO2ParameterBlock
Expand All @@ -41,7 +38,6 @@ def configure(self):
self.skip_initialization_raises_exception_test = True


@pytest.mark.unit
class TestBasicL(PropertyTestHarness):
def configure(self):
self.prop_pack = swco2.SWCO2ParameterBlock
Expand All @@ -52,7 +48,6 @@ def configure(self):
self.skip_initialization_raises_exception_test = True


@pytest.mark.unit
class TestBasicV(PropertyTestHarness):
def configure(self):
self.prop_pack = swco2.SWCO2ParameterBlock
Expand Down
Loading

0 comments on commit e276cde

Please sign in to comment.