add schema version to rebaseline_server intermediate JSON
authorcommit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>
Thu, 13 Mar 2014 16:33:36 +0000 (16:33 +0000)
committercommit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>
Thu, 13 Mar 2014 16:33:36 +0000 (16:33 +0000)
NOTREECHECKS=True
NOTRY=True
R=rmistry@google.com

Author: epoger@google.com

Review URL: https://codereview.chromium.org/196343009

git-svn-id: http://skia.googlecode.com/svn/trunk@13790 2bbb7eff-a529-9590-31e7-b0007b416f81

gm/rebaseline_server/results.py
gm/rebaseline_server/results_test.py
gm/rebaseline_server/static/constants.js
gm/rebaseline_server/testdata/outputs/expected/results_test.ResultsTest.test_gm/gm.json

index 5c33e30..efc898a 100755 (executable)
@@ -38,6 +38,7 @@ import imagepairset
 
 # Keys used to link an image to a particular GM test.
 # NOTE: Keep these in sync with static/constants.js
+REBASELINE_SERVER_SCHEMA_VERSION_NUMBER = 1
 KEY__EXPECTATIONS__BUGS = gm_json.JSONKEY_EXPECTEDRESULTS_BUGS
 KEY__EXPECTATIONS__IGNOREFAILURE = gm_json.JSONKEY_EXPECTEDRESULTS_IGNOREFAILURE
 KEY__EXPECTATIONS__REVIEWED = gm_json.JSONKEY_EXPECTEDRESULTS_REVIEWED
@@ -52,6 +53,7 @@ KEY__HEADER__IS_EXPORTED = 'isExported'
 KEY__HEADER__IS_STILL_LOADING = 'resultsStillLoading'
 KEY__HEADER__RESULTS_ALL = 'all'
 KEY__HEADER__RESULTS_FAILURES = 'failures'
+KEY__HEADER__SCHEMA_VERSION = 'schemaVersion'
 KEY__HEADER__TIME_NEXT_UPDATE_AVAILABLE = 'timeNextUpdateAvailable'
 KEY__HEADER__TIME_UPDATED = 'timeUpdated'
 KEY__HEADER__TYPE = 'type'
@@ -193,6 +195,8 @@ class Results(object):
     response_dict = self._results[results_type]
     time_updated = self.get_timestamp()
     response_dict[KEY__HEADER] = {
+        KEY__HEADER__SCHEMA_VERSION: REBASELINE_SERVER_SCHEMA_VERSION_NUMBER,
+
         # Timestamps:
         # 1. when this data was last updated
         # 2. when the caller should check back for new data (if ever)
index 958222c..7cbddef 100755 (executable)
@@ -35,11 +35,18 @@ class ResultsTest(base_unittest.TestCase):
         actuals_root=os.path.join(self._input_dir, 'gm-actuals'),
         expected_root=os.path.join(self._input_dir, 'gm-expectations'),
         generated_images_root=self._temp_dir)
+    results_obj.get_timestamp = mock_get_timestamp
     gm_json.WriteToFile(
-        results_obj.get_results_of_type(results.KEY__HEADER__RESULTS_ALL),
+        results_obj.get_packaged_results_of_type(
+            results.KEY__HEADER__RESULTS_ALL),
         os.path.join(self._output_dir_actual, 'gm.json'))
 
 
+def mock_get_timestamp():
+  """Mock version of Results.get_timestamp() for testing."""
+  return 12345678
+
+
 def main():
   base_unittest.main(ResultsTest)
 
index f795b6f..8d832f0 100644 (file)
@@ -38,6 +38,7 @@ module.constant('constants', (function() {
     KEY__IMAGESETS__DESCRIPTION: 'description',
 
     // NOTE: Keep these in sync with ../results.py
+    REBASELINE_SERVER_SCHEMA_VERSION_NUMBER: 1,
     KEY__EXPECTATIONS__BUGS: 'bugs',
     KEY__EXPECTATIONS__IGNOREFAILURE: 'ignore-failure',
     KEY__EXPECTATIONS__REVIEWED: 'reviewed-by-human',
@@ -52,6 +53,7 @@ module.constant('constants', (function() {
     KEY__HEADER__IS_STILL_LOADING: 'resultsStillLoading',
     KEY__HEADER__RESULTS_ALL: 'all',
     KEY__HEADER__RESULTS_FAILURES: 'failures',
+    KEY__HEADER__SCHEMA_VERSION: 'schemaVersion',
     KEY__HEADER__TIME_NEXT_UPDATE_AVAILABLE: 'timeNextUpdateAvailable',
     KEY__HEADER__TIME_UPDATED: 'timeUpdated',
     KEY__HEADER__TYPE: 'type',
index 3821655..562d6c1 100644 (file)
       }
     }
   }, 
+  "header": {
+    "dataHash": "2099241024256114776", 
+    "isEditable": false, 
+    "isExported": true, 
+    "schemaVersion": 1, 
+    "timeNextUpdateAvailable": null, 
+    "timeUpdated": 12345678, 
+    "type": "all"
+  }, 
   "imagePairs": [
     {
       "differenceData": {