Пример #1
0
    def test_AnyBytes(self):
        # Test conditions for valid arguments.
        anybytes_schema = SCHEMA.AnyBytes()

        self.assertTrue(anybytes_schema.matches(b''))
        self.assertTrue(anybytes_schema.matches(b'a string'))

        # Test conditions for invalid arguments.
        self.assertFalse(anybytes_schema.matches('a string'))
        self.assertFalse(anybytes_schema.matches(['a']))
        self.assertFalse(anybytes_schema.matches(3))
        self.assertFalse(anybytes_schema.matches({'a': 'string'}))
Пример #2
0
SCHEME_SCHEMA = SCHEMA.AnyString()

# A path string, whether relative or absolute, e.g. 'metadata/root/'
PATH_SCHEMA = SCHEMA.AnyString()
PATHS_SCHEMA = SCHEMA.ListOf(PATH_SCHEMA)

# An integer representing logger levels, such as logging.CRITICAL (=50).
# Must be between 0 and 50.
LOGLEVEL_SCHEMA = SCHEMA.Integer(lo=0, hi=50)

# A string representing a named object.
NAME_SCHEMA = SCHEMA.AnyString()
NAMES_SCHEMA = SCHEMA.ListOf(NAME_SCHEMA)

# A byte string representing data.
DATA_SCHEMA = SCHEMA.AnyBytes()

# A text string.  For instance, a string entered by the user.
TEXT_SCHEMA = SCHEMA.AnyString()

# Supported hash algorithms.
HASHALGORITHMS_SCHEMA = SCHEMA.ListOf(
    SCHEMA.OneOf([
        SCHEMA.String('md5'),
        SCHEMA.String('sha1'),
        SCHEMA.String('sha224'),
        SCHEMA.String('sha256'),
        SCHEMA.String('sha384'),
        SCHEMA.String('sha512')
    ]))