コード例 #1
0
 def test_node_get_request_full(self):
     params = {
         'identity': 'node-001',
         'show_details': True,
     }
     sot = nodes.NodeGetRequest(**params)
     self.assertEqual('node-001', sot.identity)
     self.assertTrue(sot.show_details)
コード例 #2
0
    def test_node_get2_node_not_found(self, mock_find):
        mock_find.side_effect = exc.ResourceNotFound(type='node', id='Bogus')

        req = orno.NodeGetRequest(identity='Bogus', show_details=False)
        ex = self.assertRaises(rpc.ExpectedException, self.eng.node_get2,
                               self.ctx, req.obj_to_primitive())

        self.assertEqual(exc.ResourceNotFound, ex.exc_info[0])
        self.assertEqual("The node (Bogus) could not be found.",
                         six.text_type(ex.exc_info[1]))
        mock_find.assert_called_once_with(self.ctx, 'Bogus')
コード例 #3
0
    def test_node_get_no_physical_id(self, mock_find):
        x_obj = mock.Mock(physical_id=None)
        x_obj.to_dict.return_value = {'foo': 'bar'}
        mock_find.return_value = x_obj
        req = orno.NodeGetRequest(identity='NODE1', show_details=True)

        result = self.eng.node_get(self.ctx, req.obj_to_primitive())

        self.assertEqual({'foo': 'bar'}, result)
        mock_find.assert_called_once_with(self.ctx, 'NODE1')
        x_obj.to_dict.assert_called_once_with()
コード例 #4
0
    def test_node_get2(self, mock_find, mock_load):
        x_obj = mock.Mock()
        mock_find.return_value = x_obj
        x_node = mock.Mock(physical_id='PHYSICAL_ID')
        x_node.to_dict.return_value = {'foo': 'bar'}
        mock_load.return_value = x_node

        req = orno.NodeGetRequest(identity='NODE1', show_details=False)
        result = self.eng.node_get2(self.ctx, req.obj_to_primitive())

        self.assertEqual({'foo': 'bar'}, result)
        mock_find.assert_called_once_with(self.ctx, 'NODE1')
        mock_load.assert_called_once_with(self.ctx, db_node=x_obj)
        x_node.to_dict.assert_called_once_with()
コード例 #5
0
 def test_node_get_request_default(self):
     sot = nodes.NodeGetRequest()
     sot.obj_set_defaults()
     self.assertFalse(sot.show_details)