diff options
author | Milo Casagrande <milo.casagrande@linaro.org> | 2015-03-10 15:12:21 +0100 |
---|---|---|
committer | Milo Casagrande <milo.casagrande@linaro.org> | 2015-03-10 15:12:21 +0100 |
commit | cc0136ec6300734c0523ce88336922b9e43bb772 (patch) | |
tree | 1f0b932b7a4b3af83be315363da0ca504c330367 | |
parent | c0ec6541f3922717f8c7349dc1c24f42b94fba74 (diff) |
Handle case of test cases not in a list.
-rw-r--r-- | app/handlers/test_set.py | 17 | ||||
-rw-r--r-- | app/handlers/tests/test_test_set_handler.py | 17 |
2 files changed, 28 insertions, 6 deletions
diff --git a/app/handlers/test_set.py b/app/handlers/test_set.py index 4ba12fb..70f9e6e 100644 --- a/app/handlers/test_set.py +++ b/app/handlers/test_set.py @@ -65,12 +65,17 @@ class TestSetHandler(htbase.TestBaseHandler): response.result = {models.ID_KEY: doc_id} response.reason = "Test set '%s' created" % test_set.name - # TODO: async import of test cases. - if all([test_case, isinstance(test_case, types.ListType)]): - response.status_code = 202 - response.messages = ( - "Associated test cases will be parsed and " - "imported") + if test_case: + if isinstance(test_case, types.ListType): + # TODO: async import of test cases. + response.status_code = 202 + response.messages = ( + "Associated test cases will be parsed and " + "imported") + else: + response.errors = ( + "Test cases are not wrapped in a " + "list; they will not be imported") else: response.reason = ( "Error saving test set '%s'" % test_set.name) diff --git a/app/handlers/tests/test_test_set_handler.py b/app/handlers/tests/test_test_set_handler.py index fa229b6..27d75bc 100644 --- a/app/handlers/tests/test_test_set_handler.py +++ b/app/handlers/tests/test_test_set_handler.py @@ -225,6 +225,23 @@ class TestTestSetHandler( self.assertEqual( response.headers["Content-Type"], DEFAULT_CONTENT_TYPE) + def test_post_correct_with_wrong_test_case(self): + headers = {"Authorization": "foo", "Content-Type": "application/json"} + body = json.dumps( + dict( + name="test-set", + test_suite_id="test-suite", + version="1.0", test_case={"foo": "bar"} + ) + ) + + response = self.fetch( + "/test/set", method="POST", headers=headers, body=body) + + self.assertEqual(response.code, 201) + self.assertEqual( + response.headers["Content-Type"], DEFAULT_CONTENT_TYPE) + def test_post_correct_with_params_error(self): headers = {"Authorization": "foo", "Content-Type": "application/json"} body = json.dumps( |