

def test_find_free_prefix_input(self):
    ' Mostly input testing of find_free_prefix\n\n            Try to stress find_free_prefix and send a lot of junk..\n        '
    schema = {
        'id': self.schema_attrs['id'],
    }
    prefix_attrs = {
        'authoritative_source': 'nipap-test',
        'prefix': '100.0.0.0/16',
        'type': 'reservation',
        'description': 'test prefix',
        'comment': 'test comment, please remove! ;)',
    }
    self.nipap.add_prefix(self.auth, schema, prefix_attrs)
    self.assertRaises(NipapInputError, self.nipap.find_free_prefix, self.auth, schema, {
        'from-prefix': ['100.0.0.0/16'],
    })
    self.assertRaises(NipapInputError, self.nipap.find_free_prefix, self.auth, schema, {
        'from-prefix': '100.0.0.0/16',
    })
    self.assertRaises(NipapMissingInputError, self.nipap.find_free_prefix, self.auth, schema, {
        'from-prefix': ['100.0.0.0/16'],
        'count': 1,
    })
    self.assertRaises(NipapInputError, self.nipap.find_free_prefix, self.auth, schema, {
        'from-prefix': ['100.0.0.0/16', '2a00:800::0/25'],
        'prefix_length': 24,
        'count': 1,
    })
    self.assertRaises(NipapValueError, self.nipap.find_free_prefix, self.auth, schema, {
        'from-prefix': ['100.0.0.0/16'],
        'prefix_length': '24',
        'count': 1,
    })
    self.assertRaises(NipapValueError, self.nipap.find_free_prefix, self.auth, schema, {
        'from-prefix': ['100.0.0.0/16'],
        'prefix_length': 35,
        'count': 1,
    })
    self.assertRaises(NipapValueError, self.nipap.find_free_prefix, self.auth, schema, {
        'from-prefix': ['2a00:800::1/25'],
        'prefix_length': 150,
        'count': 1,
    })
    self.assertRaises(NipapValueError, self.nipap.find_free_prefix, self.auth, schema, {
        'from-prefix': ['100.0.0.0/16'],
        'prefix_length': 30,
        'count': 55555,
    })
    self.assertRaises(NipapMissingInputError, self.nipap.find_free_prefix, self.auth, schema, {
        'from-pool': {
            'name': self.pool_attrs['name'],
        },
        'prefix_length': 24,
        'count': 1,
    })
    self.assertRaises(ValueError, self.nipap.find_free_prefix, self.auth, schema, {
        'from-pool': {
            'name': self.pool_attrs['name'],
        },
        'prefix_length': 24,
        'count': 1,
        'family': 'crap',
    })
    self.assertRaises(NipapValueError, self.nipap.find_free_prefix, self.auth, schema, {
        'from-pool': {
            'name': self.pool_attrs['name'],
        },
        'prefix_length': 24,
        'count': 1,
        'family': 7,
    })
    self.assertRaises(NipapNonExistentError, self.nipap.find_free_prefix, self.auth, schema, {
        'from-pool': {
            'name': 'crap',
        },
        'prefix_length': 24,
        'count': 1,
        'family': 4,
    })

dataset/ETHPy150Open SpriteLink/NIPAP/tests/nipapbase.py NipapTest.test_find_free_prefix_input/original