Fixes #23
Route find by way of route delete is now being passed the "id" argument correctly, preventing us from deleting the wrong route.
This commit is contained in:
@@ -76,7 +76,7 @@ def delete_route(context, id):
|
||||
# for all the above later
|
||||
LOG.info("delete_route %s for tenant %s" % (id, context.tenant_id))
|
||||
with context.session.begin():
|
||||
route = db_api.route_find(context, id, scope=db_api.ONE)
|
||||
route = db_api.route_find(context, id=id, scope=db_api.ONE)
|
||||
if not route:
|
||||
raise quark_exceptions.RouteNotFound(route_id=id)
|
||||
db_api.route_delete(context, route)
|
||||
|
@@ -18,6 +18,7 @@ import contextlib
|
||||
import mock
|
||||
from neutron.common import exceptions
|
||||
|
||||
from quark.db import api as db_api
|
||||
from quark import exceptions as quark_exceptions
|
||||
from quark.tests import test_quark_plugin
|
||||
|
||||
@@ -118,12 +119,12 @@ class TestQuarkDeleteRoutes(test_quark_plugin.TestQuarkPlugin):
|
||||
mock.patch("%s.route_find" % db_mod),
|
||||
) as (route_delete, route_find):
|
||||
route_find.return_value = route
|
||||
yield route_delete
|
||||
yield route_delete, route_find
|
||||
|
||||
def test_delete_route(self):
|
||||
route = dict(id=1, cidr="192.168.0.0/24", gateway="192.168.0.1",
|
||||
subnet_id=2)
|
||||
with self._stubs(route=route) as route_delete:
|
||||
with self._stubs(route=route) as (route_delete, route_find):
|
||||
self.plugin.delete_route(self.context, 1)
|
||||
self.assertTrue(route_delete.called)
|
||||
|
||||
@@ -131,3 +132,12 @@ class TestQuarkDeleteRoutes(test_quark_plugin.TestQuarkPlugin):
|
||||
with self._stubs(route=None):
|
||||
with self.assertRaises(quark_exceptions.RouteNotFound):
|
||||
self.plugin.delete_route(self.context, 1)
|
||||
|
||||
def test_delete_route_deletes_correct_route(self):
|
||||
route = dict(id=1, cidr="192.168.0.0/24", gateway="192.168.0.1",
|
||||
subnet_id=2)
|
||||
with self._stubs(route=route) as (route_delete, route_find):
|
||||
self.plugin.delete_route(self.context, 1)
|
||||
self.assertTrue(route_find.called_with(context=self.context, id=1,
|
||||
scope=db_api.ONE))
|
||||
self.assertTrue(route_delete.called)
|
||||
|
Reference in New Issue
Block a user