aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMilo Casagrande <milo.casagrande@linaro.org>2015-03-09 18:15:30 +0100
committerMilo Casagrande <milo.casagrande@linaro.org>2015-03-09 18:15:58 +0100
commit0f327461365da854d4dc05f2b28cafbda8453060 (patch)
tree17636bc3ece4bee88c1f0e3fcd818dd3c763185a
parent22cc0b62882c5147fc0ed47e1bedc1bcd2c9aeee (diff)
Clean up test suite handler.
-rw-r--r--app/handlers/test_suite.py22
-rw-r--r--app/handlers/tests/test_test_suite_handler.py2
2 files changed, 9 insertions, 15 deletions
diff --git a/app/handlers/test_suite.py b/app/handlers/test_suite.py
index 214db09..29db3a3 100644
--- a/app/handlers/test_suite.py
+++ b/app/handlers/test_suite.py
@@ -66,14 +66,13 @@ class TestSuiteHandler(hbase.BaseHandler):
test_suite = mtsuite.TestSuiteDocument.from_json(test_suite_json)
test_suite.created_on = datetime.datetime.now(tz=bson.tz_util.utc)
- ret_val, doc_id = utils.db.save(self.db, test_suite)
+ ret_val, doc_id = utils.db.save(
+ self.db, test_suite, manipulate=True)
+ response.status_code = ret_val
if ret_val == 201:
- response.status_code = ret_val
response.result = {models.ID_KEY: doc_id}
- response.reason = (
- "Test suite '%s' created with ID: %s" %
- (test_suite.name, doc_id))
+ response.reason = "Test suite '%s' created" % test_suite.name
# TODO: async import of test sets and test cases
if all([test_set, isinstance(test_set, types.ListType)]):
@@ -86,9 +85,8 @@ class TestSuiteHandler(hbase.BaseHandler):
response.messages = (
"Associated test cases will be parsed and imported")
else:
- response.status_code = 500
response.reason = (
- "Error saving test set '%s'" % test_suite.name)
+ "Error saving test suite '%s'" % test_suite.name)
return response
@@ -105,8 +103,7 @@ class TestSuiteHandler(hbase.BaseHandler):
json_obj = json.loads(self.request.body.decode("utf8"))
valid_json, j_reason = validator.is_valid_json(
- json_obj, self._valid_keys("PUT")
- )
+ json_obj, self._valid_keys("PUT"))
if valid_json:
kwargs["json_obj"] = json_obj
kwargs["db_options"] = self.settings["dboptions"]
@@ -116,18 +113,16 @@ class TestSuiteHandler(hbase.BaseHandler):
response = hresponse.HandlerResponse(400)
if j_reason:
response.reason = (
- "Provided JSON is not valid: %s" % j_reason
- )
+ "Provided JSON is not valid: %s" %
+ j_reason)
else:
response.reason = "Provided JSON is not valid"
- response.result = None
except ValueError, ex:
self.log.exception(ex)
error = "No JSON data found in the PUT request"
self.log.error(error)
response = hresponse.HandlerResponse(422)
response.reason = error
- response.result = None
else:
response = hresponse.HandlerResponse(valid_request)
response.reason = (
@@ -137,7 +132,6 @@ class TestSuiteHandler(hbase.BaseHandler):
"Use %s as the content type" % self.content_type
)
)
- response.result = None
else:
response = hresponse.HandlerResponse(400)
response.reason = "No ID specified"
diff --git a/app/handlers/tests/test_test_suite_handler.py b/app/handlers/tests/test_test_suite_handler.py
index 0117d55..d36faf2 100644
--- a/app/handlers/tests/test_test_suite_handler.py
+++ b/app/handlers/tests/test_test_suite_handler.py
@@ -13,7 +13,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-"""Test module for the JobHandler handler."""
+"""Test module for the TestSuiteHandler handler."""
import concurrent.futures
import json