def test_prefix_add(self):
        # check that some error / sanity checking is there
        attr = {}
        with self.assertRaisesRegexp(xmlrpclib.Fault, "specify 'prefix' or 'from-prefix' or 'from-pool'"):
            s.add_prefix({ 'auth': ad, 'attr': attr })

        attr['prefix'] = '1.3.3.0/24'
        with self.assertRaisesRegexp(xmlrpclib.Fault, "Either description or node must be specified."):
            s.add_prefix({ 'auth': ad, 'attr': attr })

        attr['description'] = 'test prefix'
        with self.assertRaisesRegexp(xmlrpclib.Fault, "Unknown prefix type"):
            s.add_prefix({ 'auth': ad, 'attr': attr })

        attr['type'] = 'assignment'

        # add 1.3.3.0/24
        prefix = s.add_prefix({ 'auth': ad, 'attr': attr })
        attr['id'] = prefix['id']
        self.assertGreater(attr['id'], 0)

        # what we expect the above prefix to look like
        expected = {
                'alarm_priority': None,
                'authoritative_source': 'nipap',
                'avps': {},
                'comment': None,
                'country': None,
                'description': 'test prefix',
                'display_prefix': '1.3.3.0/24',
                'expires': None,
                'external_key': None,
                'family': 4,
                'id': 131,
                'indent': 0,
                'inherited_tags': [],
                'monitor': None,
                'node': None,
                'order_id': None,
                'customer_id': None,
                'pool_name': None,
                'pool_id': None,
                'tags': [],
                'status': 'assigned',
                'vrf_rt': None,
                'vrf_id': 0,
                'vrf_name': 'default',
                'vlan': None
            }
        expected.update(attr)
        self.assertEqual(
                self._mangle_prefix_result(s.list_prefix({ 'auth': ad })),
                [expected])

        attr = {
                'description': 'test for from-prefix 1.3.3.0/24',
                'type': 'host'
            }
        args = { 'from-prefix': ['1.3.3.0/24'], 'prefix_length': 32 }
        # add a host in 1.3.3.0/24
        res = s.add_prefix({ 'auth': ad, 'attr': attr, 'args': args })

        # copy expected from 1.3.3.0/24 since we expect most things to look the
        # same for the new prefix (1.3.3.1/32) from 1.3.3.0/24
        expected_host = expected.copy()
        expected_host.update(attr)
        expected_host['id'] = res['id']
        expected_host['prefix'] = '1.3.3.1/32'
        expected_host['display_prefix'] = '1.3.3.1/24'
        expected_host['indent'] = 1

        # build list of expected
        expected_list = []
        expected_list.append(expected)
        expected_list.append(expected_host)

        # add another prefix, try with vrf_id = None
        attr['vrf_id'] = None
        res = s.add_prefix({ 'auth': ad, 'attr': attr, 'args': args })
        # update expected list
        expected_host2 = expected_host.copy()
        expected_host2['id'] = res['id']
        expected_host2['prefix'] = '1.3.3.2/32'
        expected_host2['display_prefix'] = '1.3.3.2/24'
        expected_list.append(expected_host2)

        # add another prefix, this time completely without VRF info
        del(attr['vrf_id'])
        res = s.add_prefix({ 'auth': ad, 'attr': attr, 'args': args })
        # update expected list
        expected_host3 = expected_host.copy()
        expected_host3['id'] = res['id']
        expected_host3['prefix'] = '1.3.3.3/32'
        expected_host3['display_prefix'] = '1.3.3.3/24'
        expected_list.append(expected_host3)

        # add another prefix, based on VRF name
        attr['vrf_name'] = 'default'
        res = s.add_prefix({ 'auth': ad, 'attr': attr, 'args': args })
        # update expected list
        expected_host4 = expected_host.copy()
        expected_host4['id'] = res['id']
        expected_host4['prefix'] = '1.3.3.4/32'
        expected_host4['display_prefix'] = '1.3.3.4/24'
        expected_list.append(expected_host4)

        # make sure the result looks like we expect it too! :D
        self.assertEqual(
                self._mangle_prefix_result(s.list_prefix({ 'auth': ad })),
                expected_list)
Method to align the widgets laid out in a single row.
dataset/ETHPy150Open SpriteLink/NIPAP/tests/xmlrpc.py/NipapXmlTest.test_prefix_add--crossover with--dataset/ETHPy150Open sahana/eden/modules/s3db/survey.py/survey_LayoutBlocks.alignRow