[autotest] Ensure one host only has one board label
Ensure one host only has one board label with it, otherwise shard-client
will crash
BUG=chromium:654100
TEST=Test in local autotest
Change-Id: I4e9035d331d03554612ba46040d118a6807d950c
Reviewed-on: https://chromium-review.googlesource.com/396530
Commit-Ready: Shuqian Zhao <shuqianz@chromium.org>
Tested-by: Shuqian Zhao <shuqianz@chromium.org>
Reviewed-by: Dan Shi <dshi@google.com>
diff --git a/frontend/afe/models_test.py b/frontend/afe/models_test.py
index 253e9c9..c404fde 100755
--- a/frontend/afe/models_test.py
+++ b/frontend/afe/models_test.py
@@ -67,6 +67,18 @@
self.assertEquals(host2.status, models.Host.Status.RUNNING)
+ def test_check_no_board(self):
+ host = models.Host.create_one_time_host('othost')
+ # First check with host with no board label.
+ self.assertEqual(host.check_no_board([host]), None)
+
+ # Second check with host with board label
+ label = models.Label.add_object(name='board:test')
+ label.host_set.add(host)
+ self.assertRaises(model_logic.ValidationError,
+ host.check_no_board, [host])
+
+
class SpecialTaskUnittest(unittest.TestCase,
frontend_test_utils.FrontendTestMixin):
def setUp(self):