test_that: Fix argument validation.

A test_droid CL broke argument validation so that test_that started
accepting :lab: runs without a --build argument. This would lead to
cryptic error later from the run_suite RPC.

FixIt, and add unittests to protect this argument validation.

BUG=None
TEST=(new) unittest fails before the change, pass afterwards.

Change-Id: Iffcd8005c62665ea9c0a2f1c45d43b8564c67abf
Reviewed-on: https://chromium-review.googlesource.com/559950
Commit-Ready: Prathmesh Prabhu <pprabhu@chromium.org>
Tested-by: Prathmesh Prabhu <pprabhu@chromium.org>
Reviewed-by: Xixuan Wu <xixuan@chromium.org>
diff --git a/site_utils/test_that.py b/site_utils/test_that.py
index 9b7df27..ae37f67 100755
--- a/site_utils/test_that.py
+++ b/site_utils/test_that.py
@@ -71,12 +71,10 @@
         if arguments.ssh_verbosity:
             raise ValueError('--ssh_verbosity flag not supported when running '
                              'against :lab:')
-        if not arguments.board or not arguments.build:
+        if not arguments.board or arguments.build == test_runner_utils.NO_BUILD:
             raise ValueError('--board and --build are both required when '
                              'running against :lab:')
     else:
-        if arguments.build is None:
-            arguments.build = test_runner_utils.NO_BUILD
         if arguments.web:
             raise ValueError('--web flag not supported when running locally')
 
diff --git a/site_utils/test_that_unittest.py b/site_utils/test_that_unittest.py
index b46fca3..050bf0e 100755
--- a/site_utils/test_that_unittest.py
+++ b/site_utils/test_that_unittest.py
@@ -62,9 +62,19 @@
         self.assertEqual('some_remote', args.remote)
         self.assertEqual(['test1', 'test2'], args.tests)
 
-    def test_fetch_local_suite(self):
-        # Deferred until fetch_local_suite knows about non-local builds.
-        pass
+    def test_parse_arguments_lab_run_requires_build(self):
+        """Running against :lab: requires certain extra arguments."""
+        args = test_that.parse_arguments(['-b', 'some_board', ':lab:', 'test1'])
+        with self.assertRaises(ValueError):
+            test_that.validate_arguments(args)
+
+    def test_parse_arguments_lab_run_disallows_suite_args(self):
+        """Running against :lab: requires certain extra arguments."""
+        args = test_that.parse_arguments([
+                '-b', 'some_board', '-i', 'some_image', '--args', 'some_args',
+                ':lab:', 'test1'])
+        with self.assertRaises(ValueError):
+            test_that.validate_arguments(args)
 
 
 if __name__ == '__main__':