예제 #1
0
 def test_config_mode_close_configuration_ex(self, mock_exec):
     self.dev.rpc.open_configuration = MagicMock()
     ex = RpcError(rsp='ok')
     ex.message = 'Configuration database is not open'
     self.dev.rpc.close_configuration = MagicMock(side_effect=ex)
     with Config(self.dev, mode='batch') as conf:
         conf.load('conf', format='set')
     self.assertTrue(self.dev.rpc.close_configuration.called)
예제 #2
0
 def test_config_mode_close_configuration_ex(self, mock_exec):
     self.dev.rpc.open_configuration = MagicMock()
     ex = RpcError(rsp='ok')
     ex.message = 'Configuration database is not open'
     self.dev.rpc.close_configuration = MagicMock(side_effect=ex)
     try:
         with Config(self.dev, mode='batch') as conf:
             conf.load('conf', format='set')
     except Exception as ex:
         self.assertTrue(isinstance(ex, RpcError))
     self.assertTrue(self.dev.rpc.close_configuration.called)