Update affected /v1/executions API endpoint tests.
@@ -39,6 +39,7 @@ from st2common.transport.publishers import PoolPublisher
from st2common.util import action_db as action_db_util
from st2common.util import isotime
from st2common.util import date as date_utils
+from st2api.controllers.v1.actionexecutions import ActionExecutionsController
import st2common.validators.api.action as action_validator
from tests.base import BaseActionExecutionControllerTestCase
from st2tests.api import SUPER_SECRET_PARAMETER
@@ -241,6 +242,10 @@ TEST_FIXTURES = {
@mock.patch.object(content_utils, 'get_pack_base_path', mock.MagicMock(return_value='/tmp/test'))
@mock.patch.object(PoolPublisher, 'publish', mock.MagicMock())
class ActionExecutionControllerTestCase(BaseActionExecutionControllerTestCase, FunctionalTest):
+ get_all_path = '/v1/executions'
+ controller_cls = ActionExecutionsController
+ include_attribute_field_name = 'status'
+ exclude_attribute_field_name = 'start_timestamp'
@classmethod
@mock.patch.object(action_validator, 'validate_action', mock.MagicMock(
@@ -410,30 +415,6 @@ class ActionExecutionControllerTestCase(BaseActionExecutionControllerTestCase, F
resp = self.app.get('/v1/executions/100', expect_errors=True)
self.assertEqual(resp.status_int, 404)
- def test_get_all_include_attributes_filter(self):
- # 1. Invalid field
- resp = self.app.get('/v1/executions?include_attributes=invalid', expect_errors=True)
-
- expected_msg = ('Invalid or unsupported include attribute specified: '
- 'Cannot resolve field "invalid"')
- self.assertEqual(resp.status_int, 400)
- self.assertEqual(resp.json['faultstring'], expected_msg)
-
- # NOTE: start_timestamp attribute is always included since we sort on it
-
- # 2. Valid field (single)
- resp = self.app.get('/v1/executions?include_attributes=id&limit=1')
- self.assertEqual(len(resp.json), 1)
- self.assertEqual(len(resp.json[0].keys()), 1)
- self.assertTrue('id' in resp.json[0])
-
- # 3. Valid field (single)
- resp = self.app.get('/v1/executions?include_attributes=id,status&limit=1')
- self.assertEqual(len(resp.json), 1)
- self.assertEqual(len(resp.json[0].keys()), 2)
- self.assertTrue('id' in resp.json[0])
- self.assertTrue('status' in resp.json[0])
-
def test_post_delete(self):
post_resp = self._do_post(LIVE_ACTION_1)
self.assertEqual(post_resp.status_int, 201)
