def setUp(self): super(TestCluster, self).setUp() self.sess = mock.Mock(spec=adapter.Adapter) self.sess.get = mock.Mock() self.sess.delete = mock.Mock() self.sess.post = mock.Mock() self.sess.put = mock.Mock() self.sess.default_microversion = '1' self.sess._get_connection = mock.Mock(return_value=self.cloud) self.sot = _cluster.Cluster() self.sot_expected = _cluster.Cluster(**EXAMPLE_LIST['items'][0])
def test_find(self): cluster = _cluster.Cluster(id='cluster_id') self._verify2('openstack.proxy.Proxy._find', self.proxy.find_cluster_node, method_args=[cluster, 'node'], expected_args=[_cluster_node.ClusterNode, 'node'], expected_kwargs={'cluster_id': cluster.id})
def test_find_node_pool(self): cluster = _cluster.Cluster(id='cluster_id') self._verify('openstack.proxy.Proxy._find', self.proxy.find_node_pool, method_args=[cluster, 'node_pool'], expected_args=[_node_pool.NodePool, 'node_pool'], expected_kwargs={'cluster_id': cluster.id})
def test_server_wait_for(self): value = _cluster.Cluster(id='cluster_id') self.verify_wait_for_status( self.proxy.wait_for_cluster, method_args=[value], expected_args=[self.proxy, value, 'Available', ['ERROR'], 2, 960], expected_kwargs={'attribute': 'status.status'})
def setUp(self): super(TestListClusterNode, self).setUp() self.cmd = cluster_node.ListCCEClusterNode(self.app, None) self.client.cluster_nodes = mock.Mock() self.client.find_cluster = mock.Mock( return_value=cluster.Cluster(id='cluster_id'))
def setUp(self): super(TestListNodePool, self).setUp() self.cmd = node_pool.ListCCENodePools(self.app, None) self.client.node_pools = mock.Mock() self.client.find_cluster = mock.Mock(return_value=cluster.Cluster( id='cluster_id'))
def setUp(self): super(TestClusterCertificateShow, self).setUp() self.cmd = cluster_certificate.ShowCCEClusterCertificates( self.app, None) self.client.find_cluster = mock.Mock(return_value=cluster.Cluster( id='cluster_uuid')) self.client.get_cluster_certificates = mock.Mock()
def test_add_node(self): attrs = {'a': 'b'} cluster = _cluster.Cluster(id='cluster_id') self._verify2('openstack.proxy.Proxy._create', self.proxy.create_cluster_node, method_args=[cluster], method_kwargs=attrs, expected_args=[_cluster_node.ClusterNode], expected_kwargs=dict(cluster_id=cluster.id, **attrs))
def setUp(self): super(TestDeleteCluster, self).setUp() self.cmd = cluster.DeleteCCECluster(self.app, None) self.client.delete_cluster = mock.Mock() self.client.find_cluster = mock.Mock( return_value=_cluster.Cluster(id='cluster_uuid'))
def setUp(self): super(TestShowNodePool, self).setUp() self.cmd = node_pool.ShowCCENodePool(self.app, None) self.client.find_node_pool = mock.Mock() self.client.find_cluster = mock.Mock(return_value=cluster.Cluster( id='cluster_uuid'))
def setUp(self): super(TestShowClusterNode, self).setUp() self.cmd = cluster_node.ShowCCEClusterNode(self.app, None) self.client.find_cluster_node = mock.Mock() self.client.find_cluster = mock.Mock( return_value=cluster.Cluster(id='cluster_uuid'))
def test_delete_node(self): cluster = _cluster.Cluster(id='cluster_id') self._verify2('openstack.proxy.Proxy._delete', self.proxy.delete_cluster_node, method_args=[cluster, 'n1'], expected_args=[_cluster_node.ClusterNode, 'n1'], expected_kwargs={ 'cluster_id': cluster.id, 'ignore_missing': True })
def test_get_certs(self): cluster = _cluster.Cluster(id='cluster_id') self._verify2('openstack.proxy.Proxy._get', self.proxy.get_cluster_certificates, method_args=[cluster], expected_args=[_cluster_cert.ClusterCertificate], expected_kwargs={ 'cluster_id': cluster.id, 'requires_id': False })
def test_basic(self): sot = _cluster.Cluster() self.assertEqual('', sot.resource_key) self.assertEqual('', sot.resources_key) self.assertEqual('/clusters', sot.base_path) self.assertTrue(sot.allow_list) self.assertTrue(sot.allow_create) self.assertTrue(sot.allow_fetch) self.assertTrue(sot.allow_commit) self.assertTrue(sot.allow_delete)
def test_list(self): cluster = _cluster.Cluster(id='cluster_id') self.verify_list(self.proxy.cluster_nodes, _cluster_node.ClusterNode, method_args=[cluster], method_kwargs={}, expected_kwargs={ 'paginated': False, 'cluster_id': cluster.id })
def test_list_node_pool(self): self.verify_list(self.proxy.node_pools, _node_pool.NodePool, method_args=[_cluster.Cluster(id='cluster_id')], method_kwargs={}, expected_kwargs={ 'paginated': False, 'cluster_id': 'cluster_id' }, expected_args=[])
def setUp(self): super(TestCreateNodePool, self).setUp() self.cmd = node_pool.CreateCCENodePool(self.app, None) self.app.client_manager.sdk_connection = mock.Mock() self.cloud_client = self.app.client_manager.sdk_connection self.cloud_client.create_cce_node_pool = mock.Mock() self.client.find_cluster = mock.Mock(return_value=cluster.Cluster( id='cluster_id'))
def test_get_status(self): data = EXAMPLE_LIST['items'][0] cluster = _cluster.Cluster(**data) self.assertEqual(data['status']['phase'], getattr(cluster, 'status.status'))