[autotest] Refactor lab_status_unittest.py for simplification.

This changes the code that generates the various test values to use
a helper function rather than raw JSON strings.

BUG=None
TEST=Run the unit tests

Change-Id: I039fe720c99b54d56b03c9f6f6e8019c1a03d075
Reviewed-on: https://chromium-review.googlesource.com/280579
Commit-Queue: Richard Barnette <jrbarnette@chromium.org>
Tested-by: Richard Barnette <jrbarnette@chromium.org>
Reviewed-by: Don Garrett <dgarrett@chromium.org>
diff --git a/server/lab_status_unittest.py b/server/lab_status_unittest.py
index 1299a66..b0eed23 100644
--- a/server/lab_status_unittest.py
+++ b/server/lab_status_unittest.py
@@ -16,160 +16,57 @@
 _DEADBUILD = 'deadboard-release/R33-4966.0.0'
 _LIVEBUILD = 'liveboard-release/R32-4920.14.0'
 
+_STATUS_TEMPLATE = '''
+    {
+      "username": "fizzbin@google.com",
+      "date": "2013-11-16 00:25:23.511208",
+      "message": "%s",
+      "can_commit_freely": %s,
+      "general_state": "%s"
+    }
+    '''
+
+
+def _make_status(message, can_commit, state):
+    return _STATUS_TEMPLATE % (message, can_commit, state)
+
+
+def _make_open_status(message, state):
+    return _make_status(message, 'true', state)
+
+
+def _make_closed_status(message):
+    return _make_status(message, 'false', 'closed')
+
+
+def _make_deadbuild_status(message):
+    return _make_status(message, 'false', 'open')
+
+
 _OPEN_STATUS_VALUES = [
-    '''
-    {
-      "username": "fizzbin@google.com",
-      "date": "2013-11-16 00:25:23.511208",
-      "message": "Lab is up (cross your fingers)",
-      "can_commit_freely": true,
-      "general_state": "open"
-    }
-    ''',
-
-    '''
-    {
-      "username": "fizzbin@google.com",
-      "date": "2013-11-16 00:25:23.511208",
-      "message": "Lab is on fire",
-      "can_commit_freely": true,
-      "general_state": "throttled"
-    }
-    ''',
-
-    '''
-    {
-      "username": "fizzbin@google.com",
-      "date": "2013-11-16 00:25:23.511208",
-      "message": "Lab is up despite deadboard",
-      "can_commit_freely": true,
-      "general_state": "open"
-    }
-    ''',
-
-    '''
-    {
-      "username": "fizzbin@google.com",
-      "date": "2013-11-16 00:25:23.511208",
-      "message": "Lab is up despite R33-4966.0.0",
-      "can_commit_freely": true,
-      "general_state": "open"
-    }
-    ''',
+    _make_open_status('Lab is up (cross your fingers)', 'open'),
+    _make_open_status('Lab is on fire', 'throttled'),
+    _make_open_status('Lab is up despite deadboard', 'open'),
+    _make_open_status('Lab is up despite R33-4966.0.0', 'open'),
 ]
 
 _CLOSED_STATUS_VALUES = [
-    '''
-    {
-      "username": "fizzbin@google.com",
-      "date": "2013-11-16 00:25:23.511208",
-      "message": "Lab is down for spite",
-      "can_commit_freely": false,
-      "general_state": "closed"
-    }
-    ''',
-
-    '''
-    {
-      "username": "fizzbin@google.com",
-      "date": "2013-11-16 00:25:23.511208",
-      "message": "Lab is down even for [liveboard-release/R32-4920.14.0]",
-      "can_commit_freely": false,
-      "general_state": "closed"
-    }
-    ''',
+    _make_closed_status('Lab is down for spite'),
+    _make_closed_status('Lab is down even for [%s]' % _LIVEBUILD),
+    _make_closed_status('Lab is down even for [%s]' % _DEADBUILD),
 ]
 
 _DEADBUILD_STATUS_VALUES = [
-    '''
-    {
-      "username": "fizzbin@google.com",
-      "date": "2013-11-16 00:25:23.511208",
-      "message": "Lab is up except for [deadboard-]",
-      "can_commit_freely": false,
-      "general_state": "open"
-    }
-    ''',
-
-    '''
-    {
-      "username": "fizzbin@google.com",
-      "date": "2013-11-16 00:25:23.511208",
-      "message": "Lab is up except for [R33-]",
-      "can_commit_freely": false,
-      "general_state": "open"
-    }
-    ''',
-
-    '''
-    {
-      "username": "fizzbin@google.com",
-      "date": "2013-11-16 00:25:23.511208",
-      "message": "Lab is up except for [deadboard-.*/R33-]",
-      "can_commit_freely": false,
-      "general_state": "open"
-    }
-    ''',
-
-    '''
-    {
-      "username": "fizzbin@google.com",
-      "date": "2013-11-16 00:25:23.511208",
-      "message": "Lab is up except for [ deadboard-]",
-      "can_commit_freely": false,
-      "general_state": "open"
-    }
-    ''',
-
-    '''
-    {
-      "username": "fizzbin@google.com",
-      "date": "2013-11-16 00:25:23.511208",
-      "message": "Lab is up except for [deadboard- ]",
-      "can_commit_freely": false,
-      "general_state": "open"
-    }
-    ''',
-
-    '''
-    {
-      "username": "fizzbin@google.com",
-      "date": "2013-11-16 00:25:23.511208",
-      "message": "Lab is up [first R33- last]",
-      "can_commit_freely": false,
-      "general_state": "open"
-    }
-    ''',
-
-    '''
-    {
-      "username": "fizzbin@google.com",
-      "date": "2013-11-16 00:25:23.511208",
-      "message": "liveboard is good, but [deadboard-] is bad",
-      "can_commit_freely": false,
-      "general_state": "open"
-    }
-    ''',
-
-    '''
-    {
-      "username": "fizzbin@google.com",
-      "date": "2013-11-16 00:25:23.511208",
-      "message": "Lab is up [deadboard- otherboard-]",
-      "can_commit_freely": false,
-      "general_state": "open"
-    }
-    ''',
-
-    '''
-    {
-      "username": "fizzbin@google.com",
-      "date": "2013-11-16 00:25:23.511208",
-      "message": "Lab is up [otherboard- deadboard-]",
-      "can_commit_freely": false,
-      "general_state": "open"
-    }
-    ''',
+    _make_deadbuild_status('Lab is up except for [deadboard-]'),
+    _make_deadbuild_status('Lab is up except for [^board- deadboard-]'),
+    _make_deadbuild_status('Lab is up except for [R33-]'),
+    _make_deadbuild_status('Lab is up except for [deadboard-.*/R33-]'),
+    _make_deadbuild_status('Lab is up except for [ deadboard-]'),
+    _make_deadbuild_status('Lab is up except for [deadboard- ]'),
+    _make_deadbuild_status('Lab is up [first R33- last]'),
+    _make_deadbuild_status('liveboard is good, but [deadboard-] is bad'),
+    _make_deadbuild_status('Lab is up [deadboard- otherboard-]'),
+    _make_deadbuild_status('Lab is up [otherboard- deadboard-]'),
 ]