

def test_find_free_prefix2(self):
    " Functionality testing of find_free_prefix\n\n            Mostly based on 'from-pool'\n        "
    schema = {
        'id': self.schema_attrs['id'],
    }
    pool = self.nipap.list_pool(self.auth, schema, {
        'id': self.pool_attrs['id'],
    })
    self.assertNotEqual(pool[0], [], 'Pool must exist!')
    pfxs = ['10.0.0.0/24', '10.0.1.0/24', '10.0.2.0/24', '10.0.3.0/24', '10.0.4.0/24']
    for p in pfxs:
        prefix_attrs = {
            'type': 'reservation',
            'authoritative_source': 'nipap-test',
            'prefix': p,
            'description': 'test prefix',
            'pool_id': self.pool_attrs['id'],
            'comment': 'test comment, please remove! ;)',
        }
        self.nipap.add_prefix(self.auth, schema, prefix_attrs)
    res = self.nipap.find_free_prefix(prefix_attrs.auth, schema, {
        'from-pool': {
            'name': self.pool_attrs['name'],
        },
        'count': 1,
        'family': 4,
    })
    self.assertEqual(res, ['10.0.1.0/30'], 'Incorrect prefix set returned when requesting default prefix-length')
    res = self.nipap.find_free_prefix(self.auth, schema, {
        'from-pool': {
            'name': self.pool_attrs['name'],
        },
        'count': 1,
        'family': 4,
        'prefix_length': 31,
    })
    self.assertEqual(res, ['10.0.1.0/31'], 'Incorrect prefix set returned with explicit prefix-length')

dataset/ETHPy150Open SpriteLink/NIPAP/tests/nipapbase.py NipapTest.test_find_free_prefix2/VarMisuse@158/323 `self`->`prefix_attrs`