コード例 #1
0
 def test_get_from_manager_in_deleted_state(self):
     get_from_manager = utils.get_from_manager()
     manager = fakes.FakeManager()
     resource = fakes.FakeResource(manager=manager, status="DELETED")
     manager._cache(resource)
     self.assertRaises(exceptions.GetResourceNotFound, get_from_manager,
                       resource)
コード例 #2
0
 def setUp(self):
     save_conf = client.BaseClient._configure_manager
     client.BaseClient._configure_manager = Mock()
     self.client = client.BaseClient()
     client.BaseClient._configure_manager = save_conf
     self.client._manager = fakes.FakeManager()
     self.id_svc = pyrax.identity
コード例 #3
0
 def test_get_from_manager_in_error_state(self):
     get_from_manager = utils.get_from_manager()
     manager = fakes.FakeManager()
     resource = fakes.FakeResource(manager=manager, status="ERROR")
     manager._cache(resource)
     self.assertRaises(exceptions.GetResourceFailure, get_from_manager,
                       resource)
コード例 #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)
コード例 #5
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)
コード例 #6
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)
コード例 #7
0
ファイル: test_cloud_databases.py プロジェクト: igueths/pyrax
 def test_instantiate_instance(self):
     inst = CloudDatabaseInstance(fakes.FakeManager(), {
         "id": 42,
         "volume": {
             "size": 1,
             "used": 0.2
         }
     })
     self.assertTrue(isinstance(inst, CloudDatabaseInstance))
コード例 #8
0
ファイル: test_utils.py プロジェクト: tvaught/pyrax
 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")
コード例 #9
0
ファイル: test_utils.py プロジェクト: tvaught/pyrax
 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")
コード例 #10
0
ファイル: test_utils.py プロジェクト: tvaught/pyrax
 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)
コード例 #11
0
    def test_manager_list_sizes(self):
        manager = fakes.FakeManager()

        def lst():
            return [1] * 10

        manager.list = lst
        manager_list_size = utils.manager_list_size([5])
        self.assertFalse(manager_list_size(manager))

        manager_list_size = utils.manager_list_size([10])
        self.assertTrue(manager_list_size(manager))
コード例 #12
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
コード例 #13
0
 def test_get_from_manager_with_uuid_field(self):
     get_from_manager = utils.get_from_manager()
     manager = fakes.FakeManager()
     resource = fakes.FakeResource(manager=manager)
     manager._cache(resource)
     self.assertEqual(resource, get_from_manager(resource, id_attr="uuid"))
コード例 #14
0
 def test_get_from_manager(self):
     get_from_manager = utils.get_from_manager()
     manager = fakes.FakeManager()
     resource = fakes.FakeResource(manager=manager)
     manager._cache(resource)
     self.assertEqual(resource, get_from_manager(resource))
コード例 #15
0
        class TestClient(object):
            _manager = fakes.FakeManager()

            @assure_volume
            def test_method(self, volume):
                return volume
コード例 #16
0
        class TestClient(object):
            _snaps_manager = fakes.FakeManager()

            @assure_snapshot
            def test_method(self, snapshot):
                return snapshot
コード例 #17
0
ファイル: test_cloud_databases.py プロジェクト: igueths/pyrax
        class TestClient(object):
            _manager = fakes.FakeManager()

            @assure_instance
            def test_method(self, instance):
                return instance
コード例 #18
0
 def test_create_volume(self):
     vol = CloudBlockStorageVolume(fakes.FakeManager(), {})
     self.assertTrue(isinstance(vol, CloudBlockStorageVolume))