Merge "Make test_verify_server independent of test env"

This commit is contained in:
Zuul 2021-01-15 08:20:27 +00:00 committed by Gerrit Code Review
commit f30455be23

View File

@ -13,6 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import print_function
import unittest
from test.unit import temptree
@ -297,6 +298,12 @@ class TestManagerModule(unittest.TestCase):
("-server", "swift--server"))
def test_verify_server(self):
def mock_find_exe(f):
# pretend that swift-object-server is the only file on path
return f if f == 'swift-object-server' else None
with mock.patch('swift.common.manager.find_executable',
side_effect=mock_find_exe):
# test valid servers
self.assertTrue(manager.verify_server('object'))
self.assertTrue(manager.verify_server('object-server'))