From: Ihar Hrachyshka Date: Thu, 16 Jul 2015 13:15:11 +0000 (+0200) Subject: objects.rule: enable database tests for QosRule X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=ddd9ee9a4c1dc36b405cb4cb854bb1b46ed32e98;p=openstack-build%2Fneutron-build.git objects.rule: enable database tests for QosRule While at it, simplified inheritance mess in test_policy. Change-Id: I6cf2394a27f8bb29a18c99effe2dc2251c138d59 --- diff --git a/neutron/tests/unit/objects/qos/test_policy.py b/neutron/tests/unit/objects/qos/test_policy.py index d3b720cdd..b73af22c6 100644 --- a/neutron/tests/unit/objects/qos/test_policy.py +++ b/neutron/tests/unit/objects/qos/test_policy.py @@ -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() diff --git a/neutron/tests/unit/objects/qos/test_rule.py b/neutron/tests/unit/objects/qos/test_rule.py index 52364fba6..53024b281 100644 --- a/neutron/tests/unit/objects/qos/test_rule.py +++ b/neutron/tests/unit/objects/qos/test_rule.py @@ -13,11 +13,13 @@ 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()