aboutsummaryrefslogtreecommitdiffstats
path: root/functest/api/resources/v1/testcases.py
diff options
context:
space:
mode:
Diffstat (limited to 'functest/api/resources/v1/testcases.py')
-rw-r--r--functest/api/resources/v1/testcases.py19
1 files changed, 18 insertions, 1 deletions
diff --git a/functest/api/resources/v1/testcases.py b/functest/api/resources/v1/testcases.py
index cc2d4e19..7cc70bbc 100644
--- a/functest/api/resources/v1/testcases.py
+++ b/functest/api/resources/v1/testcases.py
@@ -13,11 +13,14 @@ Resources to handle testcase related requests
import logging
import os
+import re
import pkg_resources
+import socket
import uuid
import ConfigParser
from flask import jsonify
+from flasgger.utils import swag_from
from functest.api.base import ApiResource
from functest.api.common import api_utils, thread
@@ -28,20 +31,30 @@ import functest.utils.functest_utils as ft_utils
LOGGER = logging.getLogger(__name__)
+ADDRESS = socket.gethostbyname(socket.gethostname())
+ENDPOINT_TESTCASES = ('http://{}:5000/api/v1/functest/testcases'
+ .format(ADDRESS))
+
class V1Testcases(ApiResource):
""" V1Testcases Resource class"""
+ @swag_from(pkg_resources.resource_filename(
+ 'functest', 'api/swagger/testcases.yaml'))
def get(self): # pylint: disable=no-self-use
""" GET all testcases """
testcases_list = Testcase().list()
- result = {'testcases': testcases_list.split('\n')[:-1]}
+ result = {'testcases': re.split(' |\n ', testcases_list)[1:]}
return jsonify(result)
class V1Testcase(ApiResource):
""" V1Testcase Resource class"""
+ @swag_from(
+ pkg_resources.resource_filename('functest',
+ 'api/swagger/testcase.yaml'),
+ endpoint='{0}/<testcase_name>'.format(ENDPOINT_TESTCASES))
def get(self, testcase_name): # pylint: disable=no-self-use
""" GET the info of one testcase"""
testcase = Testcase().show(testcase_name)
@@ -61,6 +74,10 @@ class V1Testcase(ApiResource):
result.update({'dependency': dependency_dict})
return jsonify(result)
+ @swag_from(
+ pkg_resources.resource_filename('functest',
+ 'api/swagger/testcase_run.yaml'),
+ endpoint='{0}/action'.format(ENDPOINT_TESTCASES))
def post(self):
""" Used to handle post request """
return self._dispatch_post()