Esempio n. 1
0
 def test_wait_until_fail(self):
     status_obj = fakes.FakeStatusChanger()
     self.assertRaises(exc.NoReloadError, utils.wait_until, status_obj,
             "status", "available")
     status_obj.manager = fakes.FakeManager()
     status_obj.manager.get = Mock(return_value=status_obj)
     status_obj.get = status_obj.manager.get
     ret = utils.wait_until(status_obj, "status", "fake", interval=0.1,
             attempts=2)
     self.assertFalse(ret.status == "fake")
Esempio n. 2
0
 def test_wait_until_callback(self):
     cback = Mock()
     status_obj = fakes.FakeStatusChanger()
     status_obj.manager = fakes.FakeManager()
     status_obj.manager.get = Mock(return_value=status_obj)
     status_obj.get = status_obj.manager.get
     thread = utils.wait_until(obj=status_obj, att="status", desired="ready",
             interval=0.1, callback=cback)
     thread.join()
     cback.assert_called_once_with(status_obj)
Esempio n. 3
0
 def test_wait_until(self):
     status_obj = fakes.FakeStatusChanger()
     self.assertRaises(exc.NoReloadError, utils.wait_until, status_obj,
             "status", "available")
     status_obj.manager = fakes.FakeManager()
     status_obj.manager.get = Mock(return_value=status_obj)
     status_obj.get = status_obj.manager.get
     ret = utils.wait_until(status_obj, "status", "ready", interval=0.1)
     self.assertTrue(isinstance(ret, fakes.FakeStatusChanger))
     self.assertEqual(ret.status, "ready")
Esempio n. 4
0
 def test_wait_until(self):
     status_obj = fakes.FakeStatusChanger()
     self.assertRaises(exc.NoReloadError, utils.wait_until, status_obj,
                       "status", "available")
     status_obj.manager = fakes.FakeManager()
     status_obj.manager.get = Mock(return_value=status_obj)
     status_obj.get = status_obj.manager.get
     sav_out = sys.stdout
     out = StringIO.StringIO()
     sys.stdout = out
     ret = utils.wait_until(status_obj,
                            "status",
                            "ready",
                            interval=0.01,
                            verbose=True,
                            verbose_atts="progress")
     self.assertTrue(isinstance(ret, fakes.FakeStatusChanger))
     self.assertEqual(ret.status, "ready")
     self.assertTrue(len(out.getvalue()) > 0)
     sys.stdout = sav_out