Enabled create test job out of private test build.

We now allow user to have a test source build containing tests not
present in the moblab and its database. The user could fetch those tests
and select them to create jobs.

BUG=chromium:603774
TEST=manually tests and some unit test.

Change-Id: I4aecb922b006a0743ef4cb223f555fac7343c6c0
Reviewed-on: https://chromium-review.googlesource.com/351480
Commit-Ready: Michael Tang <ntang@chromium.org>
Tested-by: Michael Tang <ntang@chromium.org>
Reviewed-by: Michael Tang <ntang@chromium.org>
Reviewed-by: Dan Shi <dshi@google.com>
diff --git a/frontend/afe/rpc_utils.py b/frontend/afe/rpc_utils.py
index f2965d2..eea15b9 100644
--- a/frontend/afe/rpc_utils.py
+++ b/frontend/afe/rpc_utils.py
@@ -268,6 +268,23 @@
     return type('TestObject', (object,), numerized_dict)
 
 
+def _check_is_server_test(test_type):
+    """Checks if the test type is a server test.
+
+    @param test_type The test type in enum integer or string.
+
+    @returns A boolean to identify if the test type is server test.
+    """
+    if test_type is not None:
+        if isinstance(test_type, basestring):
+            try:
+                test_type = control_data.CONTROL_TYPE.get_value(test_type)
+            except AttributeError:
+                return False
+        return (test_type == control_data.CONTROL_TYPE.SERVER)
+    return False
+
+
 def prepare_generate_control_file(tests, kernel, label, profilers,
                                   db_tests=True):
     if db_tests:
@@ -287,7 +304,7 @@
              'tests together (tests %s and %s differ' % (
             test1.name, test2.name)})
 
-    is_server = (test_type == control_data.CONTROL_TYPE.SERVER)
+    is_server = _check_is_server_test(test_type)
     if test_objects:
         synch_count = max(test.sync_count for test in test_objects)
     else: