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.sot = _cluster.Cluster()

        self.sot_expected = _cluster.Cluster(**EXAMPLE_LIST[0])
示例#2
0
 def test_get(self):
     with patch.object(self.proxy,
                       '_find',
                       return_value=_cluster.Cluster(id='cluster_id')):
         self._verify2('otcextensions.sdk.sdk_proxy.Proxy._get',
                       self.proxy.get_cluster_node,
                       method_args=['cluster_id', 'node'],
                       expected_args=[_cluster_node.ClusterNode, 'node'],
                       expected_kwargs={'cluster_uuid': 'cluster_id'})
 def test_delete_nodes(self):
     with patch.object(self.proxy, '_find',
                       return_value=_cluster.Cluster(id='cluster_id')):
         self._verify(
             'otcextensions.sdk.cce.v1.cluster.Cluster.delete_nodes',
             self.proxy.delete_cluster_nodes,
             method_args=['cluster_id', ['n1', 'n2']],
             expected_args=[self.proxy, ['n1', 'n2']],
             expected_kwargs={}
         )
 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_get)
     self.assertTrue(sot.allow_update)
     self.assertTrue(sot.allow_delete)
 def test_list(self):
     with patch.object(self.proxy, '_find',
                       return_value=_cluster.Cluster(id='cluster_id')):
         self.verify_list(
             self.proxy.cluster_nodes, _cluster_node.ClusterNode,
             mock_method='otcextensions.sdk.sdk_proxy.Proxy._list',
             method_args=['cluster_id'],
             method_kwargs={},
             expected_kwargs={
                 'paginated': False,
                 'cluster_uuid': 'cluster_id'
             },
             expected_args=[]
         )
 def test_add_node(self):
     attrs = {'a': 'b'}
     with patch.object(self.proxy, '_find',
                       return_value=_cluster.Cluster(id='cluster_id')):
         self._verify(
             'otcextensions.sdk.cce.v1.cluster_node.ClusterNode.create',
             self.proxy.add_node,
             method_args=['cluster_id'],
             method_kwargs=attrs,
             expected_args=[self.proxy],
             expected_kwargs={
                 'endpoint_override': None,
                 'headers': None,
                 'prepend_key': True,
                 'requests_auth': None
             }
         )