Add unit test for controller api

Change-Id: I5424c2ec3c3b1fe4bf1bbdb4f4f6dee6578de0a8
This commit is contained in:
songwenping 2022-11-06 11:59:53 +08:00 committed by hejunli
parent 93184e1e25
commit 16ac2c94d9

View File

@ -0,0 +1,30 @@
# Copyright 2022 Inspur
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import unittest
from unittest import mock
from elasticsearch import Elasticsearch
from venus.api import extensions
from venus.modules.search.controller import SearchController
from venus.tests.unit import fakes
class TestSearchController(unittest.TestCase):
@mock.patch('elasticsearch.Elasticsearch')
def setUp(self, mock_es):
mock_es.return_value = Elasticsearch()
self.controller = SearchController(extensions.ExtensionManager)
self.req = fakes.HTTPRequest.blank('')
super(TestSearchController, self).setUp()