Пример #1
0
 def _test_resource_update(self, res, update_router_id, update_attr,
                           update_value):
     getattr(self, "_test_{0}_setup".format(res))()
     obj = getattr(self, "_{0}_create".format(res))(self._router_id)
     uattrs = getattr(self, "_{0}_update_attrs".format(res))(obj)
     uattrs[update_attr] = update_value
     data = {res: uattrs}
     if update_router_id:
         uattrs['router_id'] = self._router_id
         with testlib_api.ExpectedException(
                 webexc.HTTPClientError) as ctx_manager:
             self._do_request(
                 'PUT', _get_path('lb/{0}s/{1}'.format(res, obj['id'])),
                 data)
         self.assertEqual(ctx_manager.exception.code, 400)
     else:
         self._do_request('PUT',
                          _get_path('lb/{0}s/{1}'.format(res, obj['id'])),
                          data)
         updated = self._do_request(
             'GET', _get_path('lb/{0}s/{1}'.format(res, obj['id'])))
         self.assertEqual(updated[res][update_attr], update_value)
Пример #2
0
 def _test_router_update(self, update_service_type_id):
     router = self._router_create(self._service_type_id)
     router_id = router['id']
     new_name = _uuid()
     data = {
         "router": {
             "name": new_name,
             "admin_state_up": router['admin_state_up'],
         }
     }
     if update_service_type_id:
         data["router"]["service_type_id"] = _uuid()
         with testlib_api.ExpectedException(
                 webexc.HTTPClientError) as ctx_manager:
             res = self._do_request(
                 'PUT', _get_path('routers/{0}'.format(router_id)), data)
         self.assertEqual(ctx_manager.exception.code, 400)
     else:
         res = self._do_request('PUT',
                                _get_path('routers/{0}'.format(router_id)),
                                data)
         res = self._do_request(
             'GET', _get_path('routers/{0}'.format(router['id'])))
         self.assertEqual(res['router']['name'], new_name)
Пример #3
0
 def test_create_bridge_vlan_network_outofrange_returns_400(self):
     with testlib_api.ExpectedException(
             webob.exc.HTTPClientError) as ctx_manager:
         self._test_create_bridge_network(vlan_id=5000)
     self.assertEqual(ctx_manager.exception.code, 400)