Beispiel #1
0
 def test_validate_required_success(self):
     """
     Tests when the object is required and it is there
     """
     f = Field('f', required=True)
     resp = validate_required(f, 1)
     self.assertEqual(resp, 1)
 def test_validate_required_success(self):
     """
     Tests when the object is required and it is there
     """
     f = Field('f', required=True)
     resp = validate_required(f, 1)
     self.assertEqual(resp, 1)
 def test_validate_required_non_required_field(self):
     """
     Tests the the field is validated if the field
     is not required and the object is None
     """
     f = Field('f', required=False)
     resp = validate_required(f, None, skip_required=False)
     self.assertEqual(resp, None)
 def test_validate_required_skipped(self):
     """
     Tests when the item is None and the validation is skipped
     because skip_required is True
     """
     f = Field('f', required=True)
     resp = validate_required(f, None, skip_required=True)
     self.assertEqual(resp, None)
Beispiel #5
0
 def test_validate_required_non_required_field(self):
     """
     Tests the the field is validated if the field
     is not required and the object is None
     """
     f = Field('f', required=False)
     resp = validate_required(f, None, skip_required=False)
     self.assertEqual(resp, None)
Beispiel #6
0
 def test_validate_required_skipped(self):
     """
     Tests when the item is None and the validation is skipped
     because skip_required is True
     """
     f = Field('f', required=True)
     resp = validate_required(f, None, skip_required=True)
     self.assertEqual(resp, None)
Beispiel #7
0
    def _validate_required(self, obj, skip_required=False):
        """
        Deteremines whether validation should be skipped because
        the input is None and the field is not required.

        :param object obj:
        :param bool skip_required: This validation
            will be skipped if skip_required is ``True``
        :return: The original object unmodified
        :rtype: object
        """
        return validate_required(self, obj, skip_required=skip_required)
Beispiel #8
0
 def _validate(self, obj, skip_required=False):
     return validate_required(self, obj, skip_required=skip_required)
Beispiel #9
0
 def _validate(self, obj, skip_required=False):
     return validate_required(self, obj, skip_required=skip_required)