def react(self): """Performs the actual acid-base reaction. Returns ------- Products, EquilibriumProducts The products of the reaction. Notes ----- Current implementation is incomplete and only accurately describes a small fraction of acid-base reactions """ product_ratio, reactant_ratio = self._equilibrium() major, minor = self._calculate_products() if reactant_ratio == 0: return Products(major, minor) else: # This doesn't work at all how it should. Here for completeness return EquilibriumProducts(major, minor)
def test_hydroxide_hydronium(self): self.maxDiff = None parts = self.acidbase1.react() majors, minors = parts.major, parts.minor major = (Product( compounds.Compound({ "a1": "H", "a2": "O", "a3": "H" }, { "b1": ("a1", "a2", { 'order': 1, 'chirality': None }), "b2": ("a2", "a3", { 'order': 1, 'chirality': None }) }, {"id": "Conjugate acid of Hydroxide"}), 50), Product( compounds.Compound({ "a1": "H", "a2": "O", "a3": "H" }, { "b1": ("a1", "a2", { 'order': 1, 'chirality': None }), "b2": ("a2", "a3", { 'order': 1, 'chirality': None }) }, {"id": "Conjugate base of Hydronium"}), 50)) minor = () expected = Products(major, minor) exp_majors, exp_minors = expected.major, expected.minor self.assertEqual(exp_minors, minors) self.assertEqual(exp_majors, majors)
def test_minor_property_skips_NoneTypes(self): self.assertFalse(Products({}, {None: 1}))
def test_minor_property_raises_typerror3(self): with self.assertRaises(TypeError): Products(0, 0)
def test_minor_property_raises_typerror1(self): with self.assertRaises(TypeError): Products({}, {1: 1})
def test_major_property_raises_typerror2(self): with self.assertRaises(TypeError): Products(None, 0)