def m(self): m = ConcreteModel() m.meta_object = PropertyClassMetadata() def get_metadata(self): return m.meta_object m.get_metadata = types.MethodType(get_metadata, m) m.comp = Cation(default={"charge": +1}) return m
def test_not_electrolye(self): m = ConcreteModel() m.meta_object = PropertyClassMetadata() def get_metadata(self): return m.meta_object m.get_metadata = types.MethodType(get_metadata, m) with pytest.raises( PropertyPackageError, match="comp Ion Component types should only be used with " "Aqueous Phases"): m.comp = Cation(default={"_electrolyte": False})
def m(self): m = ConcreteModel() m.meta_object = PropertyClassMetadata() m.meta_object.add_default_units({ 'time': pyunits.s, 'length': pyunits.m, 'mass': pyunits.kg, 'amount': pyunits.mol, 'temperature': pyunits.K}) def get_metadata(self): return m.meta_object m.get_metadata = types.MethodType(get_metadata, m) m.cation_set = Set() m.comp = Cation(default={"charge": +1, "_electrolyte": True}) return m
def test_no_charge(self, m): with pytest.raises(ConfigurationError, match="cat was not provided with a value " "for charge."): m.cat = Cation()
def test_invalid_charge(self, m): with pytest.raises(ConfigurationError, match="cat received invalid value for charge " "configuration argument." " Cations must have a positive charge."): m.cat = Cation(default={"charge": -1})
def test_no_charge(self, m): with pytest.raises(ConfigurationError, match="cat was not provided with a value " "for charge."): m.cat = Cation(default={"_electrolyte": True})