From 498cffea8d57ebd24945699261f682d6686cea36 Mon Sep 17 00:00:00 2001 From: John-Mark Gurney Date: Wed, 9 Dec 2020 17:49:46 -0800 Subject: [PATCH] now that we use deactivate to turn off power, make sure it's called.. --- bitelab/__init__.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/bitelab/__init__.py b/bitelab/__init__.py index d449363..b4b2fe4 100644 --- a/bitelab/__init__.py +++ b/bitelab/__init__.py @@ -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'))