

def test_find_free_prefix1(self):
    " Functionality testing of find_free_prefix\n\n            Mostly based on 'from-prefix'\n        "
    schema = {
        'id': self.schema_attrs['id'],
    }
    prefix_attrs = {
        'authoritative_source': 'nipap-test',
        'prefix': '100.0.0.0/16',
        'type': 'assignment',
        'description': 'test prefix',
        'comment': 'test comment, please remove! ;)',
    }
    self.nipap.add_prefix(self.auth, schema, prefix_attrs)
    res = self.nipap.find_free_prefix(self.auth, schema, {
        'from-prefix': ['100.0.0.0/16', '1.3.3.0/24'],
        'prefix_length': 24,
        'count': 1,
    })
    self.assertEqual(res, ['100.0.0.0/24'], 'Incorrect prefix set returned')
    res = self.nipap.find_free_prefix(self.auth, schema, {
        'from-prefix': ['100.0.0.0/16'],
        'prefix_length': 24,
        'count': 1,
    })
    self.assertEqual(res, ['100.0.0.0/24'], 'Incorrect prefix set returned')
    res = self.nipap.find_free_prefix(self.auth, schema, {
        'from-prefix': ['100.0.0.0/16', '1.3.3.0/24'],
        'prefix_length': 24,
        'count': 999,
    })
    self.assertEqual(len(res), 256, 'Incorrect prefix set returned')

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