本文整理匯總了Python中pyIOSXR.IOSXR.lock方法的典型用法代碼示例。如果您正苦於以下問題:Python IOSXR.lock方法的具體用法?Python IOSXR.lock怎麽用?Python IOSXR.lock使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pyIOSXR.IOSXR
的用法示例。
在下文中一共展示了IOSXR.lock方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_lock_raises_LockError
# 需要導入模塊: from pyIOSXR import IOSXR [as 別名]
# 或者: from pyIOSXR.IOSXR import lock [as 別名]
def test_lock_raises_LockError(self):
"""Tests if DB already locked raises LockError"""
if self.MOCK:
self.assertRaises(
LockError,
self.device.lock
)
self.assertFalse(self.device.locked)
else:
self.device.unlock() # make sure the config is not locked
same_device = IOSXR(self.HOSTNAME,
self.USERNAME,
self.PASSWORD,
port=self.PORT,
lock=self.LOCK,
logfile=self.LOG,
timeout=self.TIMEOUT)
same_device.open()
same_device.lock()
# the other instance locks the config DB
try:
# trying to acquire the config DB
self.device.lock()
except LockError:
self.assertFalse(self.device.locked)
else:
self.assertTrue(self.device.locked)
same_device.close()
示例2: test_lock
# 需要導入模塊: from pyIOSXR import IOSXR [as 別名]
# 或者: from pyIOSXR.IOSXR import lock [as 別名]
def test_lock(self, mock_rpc, mock_sendline, mock_expect, mock_spawn):
'''
Test pyiosxr class lock
Should return None
'''
device = IOSXR(hostname='hostname', username='ejasinska', password='passwd', port=22, timeout=60, logfile=None, lock=False)
mock_spawn.return_value = None
device.open()
self.assertIsNone(device.lock())