def testDeprecated(self): date = InputParameters() date.addParam('year', 'doco') self.assertIn('year', date) self.assertEqual('doco', date.parameter('year').doc) date.addParam('day', 1, 'doco') self.assertIn('day', date) self.assertEqual(date.getValue('day'), 1) self.assertEqual('doco', date.parameter('year').doc) date.addRequiredParam('month', 1, "doco") self.assertEqual(date.isRequired('day'), False) self.assertEqual(date.isRequired('month'), True) self.assertEqual(date['month'], 1) date['month'] = 2 self.assertEqual(date['month'], 2)
def testSetRequired(self): date = InputParameters() date.add('year') self.assertEqual(date.isRequired('year'), False) date.setValue('year', 1980) date.setRequired('year', True) self.assertEqual(date.isRequired('year'), True) date.validate() with self.assertRaises(MooseException) as e: date.setRequired('year', True) self.assertIn( "The parameter 'year' has already been validated, the required state cannot be changed.", str(e.exception)) date.setValue('_error_mode', InputParameters.ErrorMode.ERROR) with self.assertLogs(level='ERROR') as log: value = date.isRequired('wrong') self.assertEqual(value, False) self.assertEqual(len(log.output), 1) self.assertIn("The parameter 'wrong' does not exist.", log.output[0])