Esempio n. 1
0
 def setUp(self):
     save_conf = client.BaseClient._configure_manager
     client.BaseClient._configure_manager = Mock()
     self.identity = pyrax.identity = ID_CLS()
     self.client = client.BaseClient(self.identity)
     client.BaseClient._configure_manager = save_conf
     self.client._manager = fakes.FakeManager()
Esempio n. 2
0
 def test_delete_network_fail(self):
     clt = self.client
     nm = "fake"
     net = fakes.FakeCloudNetwork(name=nm)
     net.manager = fakes.FakeManager()
     err = exc.Forbidden(403)
     net.manager.delete = Mock(side_effect=err)
     self.assertRaises(exc.NetworkInUse, net.delete)
Esempio n. 3
0
 def test_delete_network(self):
     clt = self.client
     nm = "fake"
     net = fakes.FakeCloudNetwork(name=nm)
     net.manager = fakes.FakeManager()
     net.manager.delete = Mock()
     net.delete()
     net.manager.delete.assert_called_once_with(net)
Esempio n. 4
0
 def _create_dummy_resource(self):
     mgr = fakes.FakeManager()
     info = {
         "name": "test_resource",
         "size": 42,
         "id": utils.random_unicode()
     }
     return resource.BaseResource(mgr, info)
Esempio n. 5
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.00001, callback=cback)
     thread.join()
     cback.assert_called_once_with(status_obj)
Esempio n. 6
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.00001,
             attempts=2)
     self.assertFalse(ret.status == "fake")
Esempio n. 7
0
 def test_instantiate_instance(self):
     inst = CloudDatabaseInstance(fakes.FakeManager(), {
         "id": 42,
         "volume": {
             "size": 1,
             "used": 0.2
         }
     })
     self.assertTrue(isinstance(inst, CloudDatabaseInstance))
     self.assertTrue(isinstance(inst.volume, CloudDatabaseVolume))
Esempio n. 8
0
    def test_create_volume(self):
        mgr = fakes.FakeManager()
        mgr.api.region_name = "FAKE"
        sav = pyrax.connect_to_cloudservers
        fakenovavol = utils.random_unicode()

        class FakeVol(object):
            def __init__(self, *args, **kwargs):
                self.volumes = fakenovavol

        pyrax.connect_to_cloudservers = Mock(return_value=FakeVol())
        vol = CloudBlockStorageVolume(mgr, {})
        self.assertTrue(isinstance(vol, CloudBlockStorageVolume))
        self.assertEqual(vol._nova_volumes, fakenovavol)
        pyrax.connect_to_cloudservers = sav
Esempio n. 9
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()
     sys.stdout = out
     ret = utils.wait_until(status_obj, "status", "ready", interval=0.00001,
             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
Esempio n. 10
0
        class TestClient(object):
            _snapshot_manager = fakes.FakeManager()

            @assure_snapshot
            def test_method(self, snapshot):
                return snapshot
Esempio n. 11
0
        class TestClient(object):
            _manager = fakes.FakeManager()

            @assure_volume
            def test_method(self, volume):
                return volume
Esempio n. 12
0
        class TestClient(object):
            _manager = fakes.FakeManager()

            @assure_image
            def test_method(self, img):
                return img
Esempio n. 13
0
        class TestClient(object):
            _manager = fakes.FakeManager()

            @assure_instance
            def test_method(self, instance):
                return instance