~anso/nova/factorycleanup

« back to all changes in this revision

Viewing changes to nova/tests/test_quota.py

  • Committer: Todd Willey
  • Date: 2011-01-12 19:31:28 UTC
  • mfrom: (524.1.4 wsgirouter)
  • Revision ID: todd@ansolabs.com-20110112193128-3o6yktau46w9mhzu
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
#    License for the specific language governing permissions and limitations
17
17
#    under the License.
18
18
 
19
 
import logging
20
 
 
21
19
from nova import context
22
20
from nova import db
23
 
from nova import exception
24
21
from nova import flags
25
22
from nova import quota
26
23
from nova import test
27
24
from nova import utils
28
25
from nova.auth import manager
29
26
from nova.api.ec2 import cloud
 
27
from nova.compute import instance_types
30
28
 
31
29
 
32
30
FLAGS = flags.FLAGS
34
32
 
35
33
class QuotaTestCase(test.TestCase):
36
34
    def setUp(self):
37
 
        logging.getLogger().setLevel(logging.DEBUG)
38
35
        super(QuotaTestCase, self).setUp()
39
36
        self.flags(connection_type='fake',
40
37
                   quota_instances=2,
78
75
 
79
76
    def test_quota_overrides(self):
80
77
        """Make sure overriding a projects quotas works"""
81
 
        num_instances = quota.allowed_instances(self.context, 100, 'm1.small')
 
78
        num_instances = quota.allowed_instances(self.context, 100,
 
79
            instance_types.INSTANCE_TYPES['m1.small'])
82
80
        self.assertEqual(num_instances, 2)
83
81
        db.quota_create(self.context, {'project_id': self.project.id,
84
82
                                       'instances': 10})
85
 
        num_instances = quota.allowed_instances(self.context, 100, 'm1.small')
 
83
        num_instances = quota.allowed_instances(self.context, 100,
 
84
            instance_types.INSTANCE_TYPES['m1.small'])
86
85
        self.assertEqual(num_instances, 4)
87
86
        db.quota_update(self.context, self.project.id, {'cores': 100})
88
 
        num_instances = quota.allowed_instances(self.context, 100, 'm1.small')
 
87
        num_instances = quota.allowed_instances(self.context, 100,
 
88
            instance_types.INSTANCE_TYPES['m1.small'])
89
89
        self.assertEqual(num_instances, 10)
90
90
        db.quota_destroy(self.context, self.project.id)
91
91