Browse Source

now that we use deactivate to turn off power, make sure it's called..

main
John-Mark Gurney 4 years ago
parent
commit
498cffea8d
1 changed files with 9 additions and 2 deletions
  1. +9
    -2
      bitelab/__init__.py

+ 9
- 2
bitelab/__init__.py View File

@@ -436,6 +436,8 @@ async def release_board(board_id, user: str = Depends(lookup_user),
board=Board.from_orm(brd)),
)

await brd.deactivate()

env = os.environ.copy()
addkeys = { 'iface', 'ip', 'devfsrule', 'devfspath' }
env.update((k, brd.attrs[k]) for k in addkeys if k in brd.attrs)
@@ -608,10 +610,11 @@ class TestBiteLab(unittest.IsolatedAsyncioTestCase):
self.assertEqual(res.json(), { 'cora-z7s': BoardClassInfo(**{
'arch': 'arm-armv7', 'clsname': 'cora-z7s', }) })

@patch('bitelab.BoardImpl.deactivate')
@patch('asyncio.create_subprocess_exec')
@patch('bitelab.snmp.snmpget')
@patch('logging.error')
async def test_board_release_script_fail(self, le, sg, cse):
async def test_board_release_script_fail(self, le, sg, cse, bideact):
# that when snmpget returns False
sg.return_value = False

@@ -655,10 +658,11 @@ class TestBiteLab(unittest.IsolatedAsyncioTestCase):
# and that the error got logged
le.assert_called_with('release script failure: board: \'cora-1\', ret: 1, stderr: b\'error\'')

@patch('bitelab.BoardImpl.deactivate')
@patch('bitelab.BoardImpl.activate')
@patch('asyncio.create_subprocess_exec')
@patch('bitelab.snmp.snmpget')
async def test_board_reserve_release(self, sg, cse, biact):
async def test_board_reserve_release(self, sg, cse, biact, bideact):
# that when releasing a board that is not yet reserved
res = await self.client.post('/board/cora-1/release',
auth=BiteAuth('anotherlongapikey'))
@@ -786,6 +790,9 @@ class TestBiteLab(unittest.IsolatedAsyncioTestCase):
'cora-1', 'foo', env=env,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)

# and deactivated attributes
bideact.assert_called()

# that it can be reserved by a different user
res = await self.client.post('/board/cora-1/reserve',
auth=BiteAuth('anotherlongapikey'))


Loading…
Cancel
Save