def testEmptyArray(self): """Asserts error raise for empty array is input.""" with self.assertRaises(IndexError) as e: fileio.GetAngleFromPrm([]) self.assertEqual( str(e.exception), 'Insufficient columns to parse prm file row into Angle object: ')
def testBadEquilibriumBondAngle(self): """Asserts error raise for negative or non-numeric equilibrium angle.""" with self.assertRaises(ValueError) as e: fileio.GetAngleFromPrm( ['ANGLE', '9999', '2', '34', '0.1', '180.1']) self.assertEqual( str(e.exception), 'Equilibrium bond angle must be between 0.0 and 180.0: 180.1')
def testBadAngleSpringConstant(self): """Asserts error raise for non-positive numeric angle spring constant.""" with self.assertRaises(ValueError) as e: fileio.GetAngleFromPrm( ['ANGLE', '100', '101', '102', '-1.0', '1.0']) self.assertEqual( str(e.exception), 'Angle spring constant must be positive numeric value: -1.0')
def testShortArray(self): """Asserts error raise for not enough fields in input.""" with self.assertRaises(IndexError) as e: fileio.GetAngleFromPrm(['ANGLE', '1', '2', '3', '1.0']) self.assertEqual( str(e.exception), ('Insufficient columns to parse prm file row into Angle object: ' 'ANGLE 1 2 3 1.0'))
def testArbitrary(self): """Asserts correct Angle object for arbitrary input parameters.""" param = ['ANGLE', '62', '64', '67', '179.838', '17.76'] test.assertObjectEqual(self, fileio.GetAngleFromPrm(param), molecule.Angle(61, 63, 66, 179.838, 17.76))
def testSmallestValues(self): """Asserts correct Angle object for smallest allowed values.""" param = ['ANGLE', '1', '2', '3', '0.000001', '0.000001'] test.assertObjectEqual(self, fileio.GetAngleFromPrm(param), molecule.Angle(0, 1, 2, 0.000001, 0.000001))
def testBadIndex3(self): """Asserts error raise for non-positive-integer atomic index 3 input.""" with self.assertRaises(ValueError) as e: fileio.GetAngleFromPrm(['ANGLE', '2', '1', '1^', '1.0', '1.0']) self.assertEqual(str(e.exception), 'Angle atom3 index must be positive integer: 1^')