def test__lock_released_on_error(self):
exception = factory.make_exception()
self.patch(node_module, 'refresh').side_effect = exception
region = yield deferToDatabase(factory.make_RegionController)
self.patch(node_module, 'get_maas_id').return_value = region.system_id
self.patch(node_module, 'get_sys_info').return_value = {
'hostname': region.hostname,
'architecture': region.architecture,
'osystem': '',
'distro_series': '',
'interfaces': {},
}
with ExpectedException(type(exception)):
yield region.refresh()
lock = NamedLock('refresh')
self.assertFalse(lock.is_locked())
评论列表
文章目录