[LNT] r311616 - api: Fix error handling in runs POST

Matthias Braun via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 23 15:38:14 PDT 2017


Author: matze
Date: Wed Aug 23 15:38:13 2017
New Revision: 311616

URL: http://llvm.org/viewvc/llvm-project?rev=311616&view=rev
Log:
api: Fix error handling in runs POST

Modified:
    lnt/trunk/lnt/server/ui/api.py
    lnt/trunk/tests/server/ui/test_api_modify.py

Modified: lnt/trunk/lnt/server/ui/api.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/ui/api.py?rev=311616&r1=311615&r2=311616&view=diff
==============================================================================
--- lnt/trunk/lnt/server/ui/api.py (original)
+++ lnt/trunk/lnt/server/ui/api.py Wed Aug 23 15:38:13 2017
@@ -296,7 +296,7 @@ class Runs(Resource):
 
         error = result['error']
         if error is not None:
-            response = jsonify(response)
+            response = jsonify(result)
             response.status = '400'
             logger.warning("%s: Submission rejected: %s" %
                            (request.url, error))

Modified: lnt/trunk/tests/server/ui/test_api_modify.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/tests/server/ui/test_api_modify.py?rev=311616&r1=311615&r2=311616&view=diff
==============================================================================
--- lnt/trunk/tests/server/ui/test_api_modify.py (original)
+++ lnt/trunk/tests/server/ui/test_api_modify.py Wed Aug 23 15:38:13 2017
@@ -135,8 +135,6 @@ class JSONAPIDeleteTester(unittest.TestC
         for run_id in run_ids:
             resp = check_json(client,
                               'api/db_default/v4/nts/runs/{}'.format(run_id))
-            import pprint
-            pprint.pprint(resp['tests'])
             sample_ids.append([s['id'] for s in resp['tests']])
         self.assertNotEqual(len(sample_ids), 0)
 
@@ -185,6 +183,16 @@ Deleted machine machine2:2
         resp_json = json.loads(resp.data)
         self.assertEqual(resp_json['run_id'], 5)
 
+        # Provoke a failing submission.
+        resp = client.post('api/db_default/v4/nts/runs?merge=reject',
+                           data=data,
+                           headers={'AuthToken': 'test_token'})
+        self.assertEqual(resp.status_code, 400)
+        resp_json = json.loads(resp.data)
+        self.assertEqual(resp_json['error'],
+                         "import failure: Duplicate submission for '1'")
+        self.assertEqual(resp_json['success'], False)
+
     def test_04_merge_into(self):
         """Check POST/merge into request for /machines."""
         client = self.client




More information about the llvm-commits mailing list