コード例 #1
0
 def test_get_database_bad(self):
     inst = self.instance
     db1 = fakes.FakeEntity()
     db1.name = "a"
     db2 = fakes.FakeEntity()
     db2.name = "b"
     inst.list_databases = Mock(return_value=[db1, db2])
     self.assertRaises(exc.NoSuchDatabase, inst.get_database, "z")
コード例 #2
0
 def test_get_database(self):
     inst = self.instance
     db1 = fakes.FakeEntity()
     db1.name = "a"
     db2 = fakes.FakeEntity()
     db2.name = "b"
     inst.list_databases = Mock(return_value=[db1, db2])
     ret = inst.get_database("a")
     self.assertEqual(ret, db1)
コード例 #3
0
 def test_findall_bad_att(self):
     mgr = self.manager
     o1 = fakes.FakeEntity()
     o1.some_att = "ok"
     o2 = fakes.FakeEntity()
     o2.some_att = "bad"
     o3 = fakes.FakeEntity()
     o3.some_att = "ok"
     mgr.list = Mock(return_value=[o1, o2, o3])
     ret = mgr.findall(some_att="ok", bad_att="oops")
     self.assertFalse(o1 in ret)
     self.assertFalse(o2 in ret)
     self.assertFalse(o3 in ret)
コード例 #4
0
 def test_find_single_match(self):
     mgr = self.manager
     mtch = fakes.FakeEntity()
     mgr.resource_class = fakes.FakeEntity
     mgr.findall = Mock(return_value=[mtch])
     ret = mgr.find()
     self.assertEqual(ret, mtch)
コード例 #5
0
 def test_add_method_no_name(self):
     def fake_method(self):
         pass
     obj = fakes.FakeEntity()
     utils.add_method(obj, fake_method)
     self.assertTrue(hasattr(obj, "fake_method"))
     self.assertTrue(callable(obj.fake_method))
コード例 #6
0
 def test_action(self):
     mgr = self.manager
     mgr.uri_base = "testing"
     mgr.api.method_post = Mock()
     item = fakes.FakeEntity()
     mgr.action(item, "fake")
     mgr.api.method_post.assert_called_once_with("/testing/%s/action" %
             item.id, body={"fake": {}})
コード例 #7
0
ファイル: test_manager.py プロジェクト: autotune/pyrax
 def test_find_mult_match(self):
     mgr = self.manager
     sav_fa = mgr.findall
     mtch = fakes.FakeEntity()
     mgr.resource_class = fakes.FakeEntity
     mgr.findall = Mock(return_value=[mtch, mtch])
     self.assertRaises(exc.NoUniqueMatch, mgr.find)
     mgr.findall = sav_fa
コード例 #8
0
 def test_wait_for_build(self):
     sav = utils.wait_until
     utils.wait_until = Mock()
     obj = fakes.FakeEntity()
     att = utils.random_unicode()
     desired = utils.random_unicode()
     callback = utils.random_unicode()
     interval = utils.random_unicode()
     attempts = utils.random_unicode()
     verbose = utils.random_unicode()
     verbose_atts = utils.random_unicode()
     utils.wait_for_build(obj, att, desired, callback, interval, attempts,
             verbose, verbose_atts)
     utils.wait_until.assert_called_once_with(obj, att, desired,
             callback=callback, interval=interval, attempts=attempts,
             verbose=verbose, verbose_atts=verbose_atts)
     utils.wait_until = sav
コード例 #9
0
 def test_safe_issubclass_bad(self):
     fake = fakes.FakeEntity()
     ret = utils.safe_issubclass(fake, None)
     self.assertFalse(ret)