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


Python validators.DwcaValidator類代碼示例

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


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

示例1: test_no_delimiter_error

 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,代碼行數:7,代碼來源:test_validators.py

示例2: test_multiple_if_combi

 def test_multiple_if_combi(self):
     """document satisfies if and non-if clauses
     """
     schema = yaml.load(self.yaml_ifcombi)
     document = {'basisOfRecord': 'PreservedSpecimen', 'collectionCode': ''}
     val = DwcaValidator(schema)
     self.assertTrue(val.validate(document))
開發者ID:inbo,項目名稱:dwca-validator,代碼行數:7,代碼來源:test_validators.py

示例3: test_default_ignore_empty_string

 def test_default_ignore_empty_string(self):
     """empty string (converted to None values) should provide an error
     by default
     """
     val = DwcaValidator(yaml.load(self.yaml_string))
     document = {'abundance': ''}
     self.assertFalse(val.validate(document))
開發者ID:inbo,項目名稱:dwca-validator,代碼行數:7,代碼來源:test_cerberus_additions.py

示例4: test_multiple_if_pass

 def test_multiple_if_pass(self):
     """document satisfies both if clauses at the same time
     """
     schema = yaml.load(self.yaml_ifif)
     document = {'age' : '21', 'lifestage':'adult'} #True
     val = DwcaValidator(schema)
     self.assertTrue(val.validate(document))
開發者ID:inbo,項目名稱:dwca-validator,代碼行數:7,代碼來源:test_validators.py

示例5: test_no_number_usage

 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,代碼行數:8,代碼來源:test_cerberus_additions.py

示例6: test_minmax_float

 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,代碼行數:8,代碼來源:test_validators.py

示例7: test_length

 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,代碼行數:8,代碼來源:test_validators.py

示例8: test_number

 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,代碼行數:8,代碼來源:test_validators.py

示例9: test_numberformat_right

 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,代碼行數:8,代碼來源:test_validators.py

示例10: test_min_int_coerce

 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,代碼行數:8,代碼來源:test_validators.py

示例11: test_maxlength

 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,代碼行數:8,代碼來源:test_validators.py

示例12: test_minmax_int

 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,代碼行數:8,代碼來源:test_validators.py

示例13: test_numberformat_integer

 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,代碼行數:8,代碼來源:test_validators.py

示例14: test_allowed_list

 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,代碼行數:8,代碼來源:test_validators.py

示例15: test_euqals_float

 def test_euqals_float(self):
     """test if the float value equals the given value
     """
     val = DwcaValidator(yaml.load(self.yaml_length))
     # here not type test needed in schema, value given as float
     document = {'precision' : 200.00}
     self.assertTrue(val.validate(document))
     document = {'precision' : 200.001}
     self.assertFalse(val.validate(document))
開發者ID:inbo,項目名稱:dwca-validator,代碼行數:9,代碼來源:test_validators.py


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