|
@@ -103,6 +103,9 @@ async def log_event(tag, board=None, user=None, extra={}): |
|
|
|
|
|
|
|
|
logging.info(json.dumps(info)) |
|
|
logging.info(json.dumps(info)) |
|
|
|
|
|
|
|
|
|
|
|
class TimeOut(DefROAttribute): |
|
|
|
|
|
defattername = 'timeout' |
|
|
|
|
|
|
|
|
class EtherIface(DefROAttribute): |
|
|
class EtherIface(DefROAttribute): |
|
|
defattrname = 'eiface' |
|
|
defattrname = 'eiface' |
|
|
|
|
|
|
|
@@ -172,10 +175,14 @@ class BoardImpl: |
|
|
self.attrcache[i] = await self.attrmap[i].getvalue() |
|
|
self.attrcache[i] = await self.attrmap[i].getvalue() |
|
|
|
|
|
|
|
|
async def activate(self): |
|
|
async def activate(self): |
|
|
|
|
|
assert self.lock.locked() and self.reserved |
|
|
|
|
|
|
|
|
for i in self.options: |
|
|
for i in self.options: |
|
|
await i.activate(self) |
|
|
await i.activate(self) |
|
|
|
|
|
|
|
|
async def deactivate(self): |
|
|
async def deactivate(self): |
|
|
|
|
|
assert self.lock.locked() and self.reserved |
|
|
|
|
|
|
|
|
for i in self.options: |
|
|
for i in self.options: |
|
|
await i.deactivate(self) |
|
|
await i.deactivate(self) |
|
|
|
|
|
|
|
@@ -1228,7 +1235,9 @@ class TestBoardImpl(unittest.IsolatedAsyncioTestCase): |
|
|
opt = create_autospec(Attribute) |
|
|
opt = create_autospec(Attribute) |
|
|
brd = BoardImpl('foo', 'bar', [ opt ]) |
|
|
brd = BoardImpl('foo', 'bar', [ opt ]) |
|
|
|
|
|
|
|
|
await brd.activate() |
|
|
|
|
|
|
|
|
async with brd.lock: |
|
|
|
|
|
await brd.reserve() |
|
|
|
|
|
await brd.activate() |
|
|
|
|
|
|
|
|
opt.activate.assert_called_with(brd) |
|
|
opt.activate.assert_called_with(brd) |
|
|
|
|
|
|
|
@@ -1237,7 +1246,9 @@ class TestBoardImpl(unittest.IsolatedAsyncioTestCase): |
|
|
opt = create_autospec(Attribute) |
|
|
opt = create_autospec(Attribute) |
|
|
brd = BoardImpl('foo', 'bar', [ opt ]) |
|
|
brd = BoardImpl('foo', 'bar', [ opt ]) |
|
|
|
|
|
|
|
|
await brd.deactivate() |
|
|
|
|
|
|
|
|
async with brd.lock: |
|
|
|
|
|
await brd.reserve() |
|
|
|
|
|
await brd.deactivate() |
|
|
|
|
|
|
|
|
opt.deactivate.assert_called_with(brd) |
|
|
opt.deactivate.assert_called_with(brd) |
|
|
|
|
|
|
|
@@ -1348,3 +1359,10 @@ class TestAttrs(unittest.IsolatedAsyncioTestCase): |
|
|
wrap_subprocess_exec(cse, retcode=1) |
|
|
wrap_subprocess_exec(cse, retcode=1) |
|
|
with self.assertRaises(RuntimeError): |
|
|
with self.assertRaises(RuntimeError): |
|
|
await ei.activate(brd) |
|
|
await ei.activate(brd) |
|
|
|
|
|
|
|
|
|
|
|
async def test_timeout(self): |
|
|
|
|
|
# that a TimeOut can be created |
|
|
|
|
|
to = TimeOut(.1) |
|
|
|
|
|
|
|
|
|
|
|
# that a board w/ the to |
|
|
|
|
|
brd = BoardImpl('foo', 'bar', [ to ]) |