Esempio n. 1
0
    def test_rules(self):
        # Tests each rule to ensure that empty and other
        # cases work

        rules = {v.VaultGetRule, v.VaultPutRule, v.BlockGetRule,
                 v.FileGetRule, v.FilePostRuleNoneOk,
                 v.BlockPutRuleNoneOk, v.FileMarkerRule, v.OffsetMarkerRule,
                 v.BlockMarkerRule, v.LimitRule}

        for rule in rules:
            with self.assertRaises(ValidationFailed):
                v.val_limit()('')

            with self.assertRaises(ValidationFailed):
                v.val_limit()(None)
Esempio n. 2
0
    def test_limit(self):
        positive_cases = [
            '0', '100', '100000000', '100'
        ]

        for limit in positive_cases:
            v.val_limit()(limit)

        negative_cases = [
            '-1', 'blah', None
        ]

        for limit in negative_cases:
            with self.assertRaises(ValidationFailed):
                v.val_limit()(limit)

        v.val_limit(empty_ok=True)('')
        v.val_limit(none_ok=True)(None)

        with self.assertRaises(ValidationFailed):
            v.val_limit()('')

        with self.assertRaises(ValidationFailed):
            v.val_limit()(None)