]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Add missing keyword raise to get_profile_binding function
authorEugene Nikanorov <enikanorov@mirantis.com>
Fri, 13 Jun 2014 06:12:46 +0000 (10:12 +0400)
committerEugene Nikanorov <enikanorov@mirantis.com>
Fri, 13 Jun 2014 07:43:55 +0000 (11:43 +0400)
Improve corresponding unit tests.

Change-Id: I8f71ee7aa8fcafbf3ef6e3f9d4f0b89c874af73b
Closes-Bug: #1329426

neutron/plugins/cisco/db/n1kv_db_v2.py
neutron/tests/unit/cisco/n1kv/test_n1kv_db.py

index 5e256bbef65bda6fb996b2092401e4fc8d6cd93d..e3f4445a09feec5d51c3d878cc11b19c2413c4eb 100644 (file)
@@ -893,7 +893,7 @@ def get_profile_binding(db_session, tenant_id, profile_id):
         return (db_session.query(n1kv_models_v2.ProfileBinding).filter_by(
             tenant_id=tenant_id, profile_id=profile_id).one())
     except exc.NoResultFound:
-        c_exc.ProfileTenantBindingNotFound(profile_id=profile_id)
+        raise c_exc.ProfileTenantBindingNotFound(profile_id=profile_id)
 
 
 def delete_profile_binding(db_session, tenant_id, profile_id):
index 39e27e6e7976b7e38c34fcf15ecca8ddb409ad4a..e806944e0b82b35493c072cbde524613b7030464 100644 (file)
@@ -825,6 +825,11 @@ class ProfileBindingTests(base.BaseTestCase,
         self.assertEqual(binding.profile_id, test_profile_id)
         self.assertEqual(binding.profile_type, test_profile_type)
 
+    def test_get_profile_binding_not_found(self):
+        self.assertRaises(
+            c_exc.ProfileTenantBindingNotFound,
+            n1kv_db_v2.get_profile_binding, self.session, "123", "456")
+
     def test_delete_profile_binding(self):
         test_tenant_id = "d434dd90-76ec-11e2-bcfd-0800200c9a66"
         test_profile_id = "dd7b9741-76ec-11e2-bcfd-0800200c9a66"
@@ -855,9 +860,11 @@ class ProfileBindingTests(base.BaseTestCase,
         binding = n1kv_db_v2.get_profile_binding(self.session,
                                                  ctx.tenant_id,
                                                  test_profile_id)
-        self.assertIsNone(n1kv_db_v2.get_profile_binding(
+        self.assertRaises(
+            c_exc.ProfileTenantBindingNotFound,
+            n1kv_db_v2.get_profile_binding,
             self.session,
             cisco_constants.TENANT_ID_NOT_SET,
-            test_profile_id))
+            test_profile_id)
         self.assertNotEqual(binding.tenant_id,
                             cisco_constants.TENANT_ID_NOT_SET)