Ejemplo n.º 1
0
    def test_one_item_passes(self):
        def fail(value):
            raise AssertionError

        data = {'a': 'some string'}
        schema = ('a', chainable.AnyIn(types.string, fail))
        assert validate(data, schema) is None
Ejemplo n.º 2
0
 def test_no_validator_passes(self):
     def foo(value): raise AssertionError
     def bar(value): raise AssertionError
     chain = chainable.AnyIn(foo, bar)
     with raises(AssertionError) as exc:
         chain('some value')
     assert exc.value.args[0] == 'did not passed validation against any validator'
Ejemplo n.º 3
0
    def test_all_items_fail(self):
        def fail(value):
            raise AssertionError

        data = {'a': 'some string'}
        schema = ('a', chainable.AnyIn(types.boolean, fail))
        with raises(Invalid) as exc:
            validate(data, schema)
        error = exc.value.args[0]
        assert '-> a -> some string  did not pass validation against callable: AnyIn' in error
Ejemplo n.º 4
0
    ("containerized_deployment", types.boolean),
    ('osd_objectstore', osd_objectstore_choices),
)

ceph_origin_repository = ("ceph_repository", ceph_repository_choices)

ceph_repository_community = (
    ("ceph_mirror", types.string),
    ("ceph_stable_key", types.string),
    ("ceph_stable_release", validate_ceph_stable_release),
    ("ceph_stable_repo", types.string),
)

ceph_repository_rhcs = (
    ("ceph_repository_type", ceph_repository_type_choices),
    ("ceph_rhcs_version", chainable.AnyIn(types.string, types.integer)),
)

ceph_repository_dev = (
    ("ceph_dev_branch", types.string),
    ("ceph_dev_sha1", types.string),
)

monitor_options = (
    ("cluster_network", types.string),
    ("fsid", types.string),
    ("monitor_address", validate_monitor_options),
    ("monitor_address_block", validate_monitor_options),
    ("monitor_interface", validate_monitor_options),
    ("public_network", types.string),
)
Ejemplo n.º 5
0
 def test_all_validators_pass(self):
     def foo(value): pass
     def bar(value): pass
     chain = chainable.AnyIn(foo, bar)
     assert chain('some value') is None