Пример #1
0
    def test_visibility_validator_restricted_false(self):
        tests = [
            ({
                'private': True,
                'visibility': 'private'
            }, True),
            ({
                'private': False,
                'visibility': 'private'
            }, True),
            ({
                'private': True,
                'visibility': 'restricted'
            }, False),
            ({
                'private': False,
                'visibility': 'restricted'
            }, False),
            ({
                'private': True,
                'visibility': 'public'
            }, False),
            ({
                'private': False,
                'visibility': 'public'
            }, False),
        ]

        for test in tests:
            key = ('visibility', )
            data = df.flatten_dict(test[0])
            validators.visibility_validator(key, data, {}, {})
            assert (data[('private', )] == test[1]
                    ), 'Data: {}, expected: {}, returned: {}'.format(
                        test[0], test[1], data[('private', )])
Пример #2
0
    def test_visibility_validator_set_correct_value(self):
        tests = [
            ({
                'visibility': 'private'
            }, 'restricted'),
            ({
                'visibility': 'restricted'
            }, 'restricted'),
            ({
                'visibility': 'public'
            }, 'public'),
        ]

        for test in tests:
            key = ('visibility', )
            data = df.flatten_dict(test[0])
            validators.visibility_validator(key, data, {}, {})
            assert (data[('visibility', )] == test[1]
                    ), 'Data: {}, expected: {}, returned: {}'.format(
                        test[0], test[1], data[('private', )])
Пример #3
0
 def test_visibility_validator_invalid_value(self):
     key = ('visibility', )
     data = {'private': True, 'visibility': 'unknown'}
     data = df.flatten_dict(data)
     with pytest.raises(toolkit.Invalid):
         validators.visibility_validator(key, data, {}, {})