def test_validation_missing_required_param(self): try: params = {'param1': 1} name = 'param2' required = True param_type = int expected = { 'message': 'the required parameter "' + name + '" was not provided', 'type': 'input', 'code': 'missing', 'info': { 'key': name } } result, err = Validation.check_param(params, name, required, param_type) self.assertIsNone(result) self.assertIsNotNone(err) self.assertIsInstance(err, dict) self.assertDictEqual(err, expected) except Exception as ex: self.assertTrue(False)
def test_validation_missing_optional_param(self): try: params = {'param1': 1} name = 'param2' required = False param_type = int result, err = Validation.check_param(params, name, required, param_type) self.assertIsNone(err) self.assertIsNone(result) except Exception as ex: self.assertTrue(False)