

def test_add_prefix(self):
    ' Test add_prefix in a bit more detail\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 = {
            'authoritative_source': 'nipap-test',
            'prefix': p,
            'type': 'reservation',
            'description': 'test prefix',
            'pool_id': self.pool_attrs['id'],
            'comment': 'test comment, please remove! ;)',
        }
        self.nipap.add_prefix(res.auth, schema, prefix_attrs)
    prefix_attrs = {
        'type': 'assignment',
        'authoritative_source': 'nipap-test',
        'description': 'test prefix',
        'comment': 'test comment, please remove! ;)',
    }
    res = self.nipap.add_prefix(self.auth, schema, prefix_attrs, {
        'from-prefix': ['10.0.0.0/24'],
        'prefix_length': 30,
    })
    p = self.nipap.list_prefix(self.auth, schema, {
        'id': res,
    })
    self.assertEqual(p[0]['prefix'], '10.0.0.0/30', 'New prefix differ from what it should be!')
    self.nipap.add_schema(self.auth, {
        'name': 'testtest',
        'description': 'another test schema!',
    })

dataset/ETHPy150Open SpriteLink/NIPAP/tests/nipapbase.py NipapTest.test_add_prefix/VarMisuse@140/284 `self`->`res`