當前位置: 首頁>>代碼示例>>Python>>正文


Python DwcaValidator.validate方法代碼示例

本文整理匯總了Python中dwcavalidator.validators.DwcaValidator.validate方法的典型用法代碼示例。如果您正苦於以下問題:Python DwcaValidator.validate方法的具體用法?Python DwcaValidator.validate怎麽用?Python DwcaValidator.validate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在dwcavalidator.validators.DwcaValidator的用法示例。


在下文中一共展示了DwcaValidator.validate方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_no_delimiter_error

# 需要導入模塊: from dwcavalidator.validators import DwcaValidator [as 別名]
# 或者: from dwcavalidator.validators.DwcaValidator import validate [as 別名]
 def test_no_delimiter_error(self):
     """raise Error when no delimiter field added
     """
     val = DwcaValidator(yaml.load(self.yaml_delimited5))
     document = {'sex' : 'male | female '}
     with self.assertRaises(ValueError):
         val.validate(document)
開發者ID:inbo,項目名稱:dwca-validator,代碼行數:9,代碼來源:test_validators.py

示例2: test_allowed_list

# 需要導入模塊: from dwcavalidator.validators import DwcaValidator [as 別名]
# 或者: from dwcavalidator.validators.DwcaValidator import validate [as 別名]
 def test_allowed_list(self):
     """test if the value is one of the allowed values
     """
     val = DwcaValidator(yaml.load(self.yaml_allow))
     document = {'rightsHolder' : 'INBO'}
     self.assertTrue(val.validate(document))
     document = {'rightsHolder' : 'ILVO'}
     self.assertFalse(val.validate(document))
開發者ID:inbo,項目名稱:dwca-validator,代碼行數:10,代碼來源:test_validators.py

示例3: test_number

# 需要導入模塊: from dwcavalidator.validators import DwcaValidator [as 別名]
# 或者: from dwcavalidator.validators.DwcaValidator import validate [as 別名]
 def test_number(self):
     """test if a field is a number
     """
     val = DwcaValidator(yaml.load(self.yaml_dtypes))
     document = {'percentage': 2.2}
     self.assertTrue(val.validate(document))
     document = {'percentage': 2}
     self.assertTrue(val.validate(document))
開發者ID:inbo,項目名稱:dwca-validator,代碼行數:10,代碼來源:test_validators.py

示例4: test_maxlength

# 需要導入模塊: from dwcavalidator.validators import DwcaValidator [as 別名]
# 或者: from dwcavalidator.validators.DwcaValidator import validate [as 別名]
 def test_maxlength(self):
     """test if the string has proper maximal length
     """
     val = DwcaValidator(yaml.load(self.yaml_length))
     document = {'coordinateSystem' : '31U'}
     self.assertTrue(val.validate(document))
     document = {'coordinateSystem' : '31UDS76C'}
     self.assertFalse(val.validate(document))
開發者ID:inbo,項目名稱:dwca-validator,代碼行數:10,代碼來源:test_validators.py

示例5: test_minmax_float

# 需要導入模塊: from dwcavalidator.validators import DwcaValidator [as 別名]
# 或者: from dwcavalidator.validators.DwcaValidator import validate [as 別名]
 def test_minmax_float(self):
     """test if the value has minimal value
     """
     val = DwcaValidator(yaml.load(self.yaml_value))
     document = {'percentage' : 9.}
     self.assertFalse(val.validate(document))
     document = {'percentage' : 2.1}
     self.assertFalse(val.validate(document))
開發者ID:inbo,項目名稱:dwca-validator,代碼行數:10,代碼來源:test_validators.py

示例6: test_minmax_int

# 需要導入模塊: from dwcavalidator.validators import DwcaValidator [as 別名]
# 或者: from dwcavalidator.validators.DwcaValidator import validate [as 別名]
 def test_minmax_int(self):
     """test if the value has minimal value
     """
     val = DwcaValidator(yaml.load(self.yaml_value))
     document = {'individualCount' : 9}
     self.assertFalse(val.validate(document))
     document = {'individualCount' : 2}
     self.assertFalse(val.validate(document))
開發者ID:inbo,項目名稱:dwca-validator,代碼行數:10,代碼來源:test_validators.py

示例7: test_numberformat_right

# 需要導入模塊: from dwcavalidator.validators import DwcaValidator [as 別名]
# 或者: from dwcavalidator.validators.DwcaValidator import validate [as 別名]
 def test_numberformat_right(self):
     val = DwcaValidator(yaml.load(self.yaml_numberformat1))
     document = {'size' : '1110.14372'} # True
     self.assertTrue(val.validate(document))
     document = {'size' : '.14372'} # True
     self.assertTrue(val.validate(document))
     document = {'size' : '0.1437'} # False
     self.assertFalse(val.validate(document))
開發者ID:inbo,項目名稱:dwca-validator,代碼行數:10,代碼來源:test_validators.py

示例8: test_numberformat_integer

# 需要導入模塊: from dwcavalidator.validators import DwcaValidator [as 別名]
# 或者: from dwcavalidator.validators.DwcaValidator import validate [as 別名]
 def test_numberformat_integer(self):
     val = DwcaValidator(yaml.load(self.yaml_numberformat3))
     document = {'size' : '1234.'} # True
     self.assertTrue(val.validate(document))
     document = {'size' : '1234.55555'} # True
     self.assertTrue(val.validate(document))
     document = {'size' : '1234'} # True
     self.assertTrue(val.validate(document))
開發者ID:inbo,項目名稱:dwca-validator,代碼行數:10,代碼來源:test_validators.py

示例9: test_no_number_usage

# 需要導入模塊: from dwcavalidator.validators import DwcaValidator [as 別名]
# 或者: from dwcavalidator.validators.DwcaValidator import validate [as 別名]
 def test_no_number_usage(self):
     """check the error statement providing info about datatype when coerce
     not possible
     """
     val = DwcaValidator(yaml.load(self.yaml_string))
     document = {'percentage': u'tien'}
     val.validate(document)
     self.assertIn('must be of number type', val.errors['percentage'])
開發者ID:inbo,項目名稱:dwca-validator,代碼行數:10,代碼來源:test_cerberus_additions.py

示例10: test_min_int_coerce

# 需要導入模塊: from dwcavalidator.validators import DwcaValidator [as 別名]
# 或者: from dwcavalidator.validators.DwcaValidator import validate [as 別名]
 def test_min_int_coerce(self):
     """test if the value has minimal value
     """
     val = DwcaValidator(yaml.load(self.yaml_value))
     document = {'code' : '6'}
     self.assertTrue(val.validate(document))
     document = {'code' : '2'}
     self.assertFalse(val.validate(document))
開發者ID:inbo,項目名稱:dwca-validator,代碼行數:10,代碼來源:test_validators.py

示例11: test_length

# 需要導入模塊: from dwcavalidator.validators import DwcaValidator [as 別名]
# 或者: from dwcavalidator.validators.DwcaValidator import validate [as 別名]
 def test_length(self):
     """test if the string has proper minimal length
     """
     val = DwcaValidator(yaml.load(self.yaml_length))
     document = {'verbatimCoordinateSystem' : '31UDS'}
     self.assertTrue(val.validate(document))
     document = {'verbatimCoordinateSystem' : '3'}
     self.assertFalse(val.validate(document))
開發者ID:inbo,項目名稱:dwca-validator,代碼行數:10,代碼來源:test_validators.py

示例12: test_empty_string

# 需要導入模塊: from dwcavalidator.validators import DwcaValidator [as 別名]
# 或者: from dwcavalidator.validators.DwcaValidator import validate [as 別名]
 def test_empty_string(self):
     """conversion empty string to None in document
     """
     val = DwcaValidator(yaml.load(self.yaml_string))
     document = {'abundance': ''}
     val.validate(document)
     self.assertEqual(val.document,
                 {'abundance': None},
                 msg="pre-conversion of empty strings to None not supported")
開發者ID:inbo,項目名稱:dwca-validator,代碼行數:11,代碼來源:test_cerberus_additions.py

示例13: test_bool_usage_coerce_fail

# 需要導入模塊: from dwcavalidator.validators import DwcaValidator [as 別名]
# 或者: from dwcavalidator.validators.DwcaValidator import validate [as 別名]
 def test_bool_usage_coerce_fail(self):
     """if failing this, the coerce addition failed to work
     """
     val = DwcaValidator(yaml.load(self.yaml_string))
     document = {'abundance': u'true'}
     val.validate(document)
     self.assertNotEqual(val.errors,
                         {'abundance': 'must be of boolean type'},
                         msg="addition of coerce to pre-interpret datatype boolean is failing")
開發者ID:inbo,項目名稱:dwca-validator,代碼行數:11,代碼來源:test_cerberus_additions.py

示例14: test_int_usage_coerce_fail

# 需要導入模塊: from dwcavalidator.validators import DwcaValidator [as 別名]
# 或者: from dwcavalidator.validators.DwcaValidator import validate [as 別名]
 def test_int_usage_coerce_fail(self):
     """if failing this, the coerce addition failed to work
     """
     val = DwcaValidator(yaml.load(self.yaml_string))
     document = {'individualCount': u'1'}
     val.validate(document)
     self.assertNotEqual(val.errors,
                         {'individualCount': 'must be of integer type'},
                         msg="addition of coerce to pre-interpret datatype integer is failing")
開發者ID:inbo,項目名稱:dwca-validator,代碼行數:11,代碼來源:test_cerberus_additions.py

示例15: test_float_usage_coerce_fail

# 需要導入模塊: from dwcavalidator.validators import DwcaValidator [as 別名]
# 或者: from dwcavalidator.validators.DwcaValidator import validate [as 別名]
 def test_float_usage_coerce_fail(self):
     """if failing this, the coerce addition failed to work
     """
     val = DwcaValidator(yaml.load(self.yaml_string))
     document = {'decimalLatitude' : '51.55'}
     val.validate(document)
     self.assertNotEqual(val.errors,
                         {'decimalLatitude': 'must be of float type'},
                         msg="addition of coerce to pre-interpret datatype float is failing")
開發者ID:inbo,項目名稱:dwca-validator,代碼行數:11,代碼來源:test_cerberus_additions.py


注:本文中的dwcavalidator.validators.DwcaValidator.validate方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。