~hazmat/pyjuju/rapi-rollup

« back to all changes in this revision

Viewing changes to juju/providers/openstack/tests/test_provider.py

  • Committer: Kapil Thangavelu
  • Date: 2013-01-20 12:17:15 UTC
  • mfrom: (616.2.13 rapi-annotation)
  • Revision ID: kapil@canonical.com-20130120121715-exju6n7miobz9gmc
Merged rapi-annotation into rapi-rollup.

Show diffs side-by-side

added added

removed removed

Lines of Context:
192
192
        cs2 = yield provider.get_constraint_set()
193
193
        self.assertIsInstance(cs2, ConstraintSet)
194
194
        self.assertEqual(cs, cs2)
 
195
 
 
196
    def create_constraint_set(self):
 
197
        self.expect_nova_get("flavors",
 
198
            response={'flavors': self.default_flavors})
 
199
        self.mocker.replay()
 
200
        provider = self.get_provider()
 
201
        return provider.get_constraint_set()
 
202
 
 
203
    @inlineCallbacks
 
204
    def test_parse_scheduler_hints_one(self):
 
205
        cs = yield self.create_constraint_set()
 
206
        c = cs.parse(["os-scheduler-hints={\"hint-key\": \"hint-val\"}"])
 
207
        self.assertEqual({"hint-key": "hint-val"}, c["os-scheduler-hints"])
 
208
 
 
209
    @inlineCallbacks
 
210
    def test_parse_scheduler_hints_bad_value(self):
 
211
        cs = yield self.create_constraint_set()
 
212
        err = self.assertRaises(errors.ConstraintError,
 
213
            cs.parse, ["os-scheduler-hints=notjson"])
 
214
        self.assertRegexpMatches(str(err),
 
215
            "Bad 'os-scheduler-hints' constraint 'notjson': .*")
 
216
 
 
217
    @inlineCallbacks
 
218
    def test_parse_scheduler_hints_bad_array(self):
 
219
        cs = yield self.create_constraint_set()
 
220
        err = self.assertRaises(errors.ConstraintError,
 
221
            cs.parse, ["os-scheduler-hints=[]"])
 
222
        self.assertRegexpMatches(str(err),
 
223
            "Bad 'os-scheduler-hints' constraint '\\[\\]': .*")