]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
objects.rule: enable database tests for QosRule
authorIhar Hrachyshka <ihrachys@redhat.com>
Thu, 16 Jul 2015 13:15:11 +0000 (15:15 +0200)
committerIhar Hrachyshka <ihrachys@redhat.com>
Sun, 19 Jul 2015 06:34:06 +0000 (06:34 +0000)
While at it, simplified inheritance mess in test_policy.

Change-Id: I6cf2394a27f8bb29a18c99effe2dc2251c138d59

neutron/tests/unit/objects/qos/test_policy.py
neutron/tests/unit/objects/qos/test_rule.py

index d3b720cdd7ad2f48a6fb5d4b569df635886bd3b2..b73af22c6ccc7a116f86b90b9c04ccecd6a6ad3b 100644 (file)
@@ -18,20 +18,16 @@ from neutron.tests.unit.objects import test_base
 from neutron.tests.unit import testlib_api
 
 
-class QosPolicyBaseTestCase(object):
+class QosPolicyObjectTestCase(test_base.BaseObjectIfaceTestCase):
 
     _test_class = policy.QosPolicy
 
 
-class QosPolicyObjectTestCase(QosPolicyBaseTestCase,
-                              test_base.BaseObjectIfaceTestCase):
-    pass
-
-
-class QosPolicyDbObjectTestCase(QosPolicyBaseTestCase,
-                                test_base.BaseDbObjectTestCase,
+class QosPolicyDbObjectTestCase(test_base.BaseDbObjectTestCase,
                                 testlib_api.SqlTestCase):
 
+    _test_class = policy.QosPolicy
+
     def setUp(self):
         super(QosPolicyDbObjectTestCase, self).setUp()
         self._create_test_network()
index 52364fba63729c4f6af1e1c0e849f4ba6a9bf40e..53024b281331be7179fc3f6a9460fa8253482e4b 100644 (file)
 import mock
 
 from neutron.db import api as db_api
+from neutron.objects.qos import policy
 from neutron.objects.qos import rule
 from neutron.tests.unit.objects import test_base
+from neutron.tests.unit import testlib_api
 
 
-class QosBandwidthLimitPolicyObjectTestCase(test_base.BaseObjectIfaceTestCase):
+class QosBandwidthLimitRuleObjectTestCase(test_base.BaseObjectIfaceTestCase):
 
     _test_class = rule.QosBandwidthLimitRule
 
@@ -25,7 +27,7 @@ class QosBandwidthLimitPolicyObjectTestCase(test_base.BaseObjectIfaceTestCase):
     def get_random_fields(cls):
         # object middleware should not allow random types, so override it with
         # proper type
-        fields = (super(QosBandwidthLimitPolicyObjectTestCase, cls)
+        fields = (super(QosBandwidthLimitRuleObjectTestCase, cls)
                   .get_random_fields())
         fields['type'] = cls._test_class.rule_type
         return fields
@@ -110,3 +112,18 @@ class QosBandwidthLimitPolicyObjectTestCase(test_base.BaseObjectIfaceTestCase):
             update_mock.assert_any_call(
                 self.context, self._test_class.db_model, obj.id,
                 addn_db_obj)
+
+
+class QosBandwidthLimitRuleDbObjectTestCase(test_base.BaseDbObjectTestCase,
+                                            testlib_api.SqlTestCase):
+
+    _test_class = rule.QosBandwidthLimitRule
+
+    def setUp(self):
+        super(QosBandwidthLimitRuleDbObjectTestCase, self).setUp()
+
+        # Prepare policy to be able to insert a rule
+        generated_qos_policy_id = self.db_obj['qos_policy_id']
+        policy_obj = policy.QosPolicy(self.context,
+                                      id=generated_qos_policy_id)
+        policy_obj.create()