[autotest] Require lock reason to lock device
When locking a device, a locking reason now must be provided.
This applies to both adding a new device, and modifying an
existing device from both the web frontend and the atest
command-line tool.
BUG=chromium:336805
DEPLOY=migrate
TEST=Tested adding locked/unlocked devices and locking/unlocking devices
from both the web frontend and using the 'atest host ...' command-line tools.
Change-Id: I3a8cd8891a2999f026dd709ae8a79e2b8cbc251a
Reviewed-on: https://chromium-review.googlesource.com/267595
Tested-by: Matthew Sartori <[email protected]>
Reviewed-by: Dan Shi <[email protected]>
Commit-Queue: Matthew Sartori <[email protected]>
diff --git a/frontend/afe/rpc_interface_unittest.py b/frontend/afe/rpc_interface_unittest.py
index d4002d2..574991d 100755
--- a/frontend/afe/rpc_interface_unittest.py
+++ b/frontend/afe/rpc_interface_unittest.py
@@ -454,9 +454,11 @@
self.god.stub_with(frontend, 'AFE', mock_afe)
mock_afe2 = frontend.AFE.expect_new(server=shard_hostname)
- mock_afe2.run.expect_call('modify_host', id=host.id, locked=True)
+ mock_afe2.run.expect_call('modify_host', id=host.id, locked=True,
+ lock_reason='_modify_host_helper lock')
- rpc_interface.modify_host(id=host.id, locked=True)
+ rpc_interface.modify_host(id=host.id, locked=True,
+ lock_reason='_modify_host_helper lock')
host = models.Host.objects.get(pk=host.id)
self.assertTrue(host.locked)
@@ -507,16 +509,20 @@
mock_afe2.run.expect_call(
'modify_hosts',
host_filter_data={'id__in': [shard1.id, shard2.id]},
- update_data={'locked': True})
+ update_data={'locked': True,
+ 'lock_reason': 'Testing forward to shard'})
mock_afe1 = frontend.AFE.expect_new(server='shard1')
mock_afe1.run.expect_call(
'modify_hosts',
host_filter_data={'id__in': [shard1.id, shard2.id]},
- update_data={'locked': True})
+ update_data={'locked': True,
+ 'lock_reason': 'Testing forward to shard'})
rpc_interface.modify_hosts(host_filter_data={'status': 'Ready'},
- update_data={'locked': True})
+ update_data={
+ 'locked': True,
+ 'lock_reason': 'Testing forward to shard'})
host1 = models.Host.objects.get(pk=host1.id)
self.assertTrue(host1.locked)