Update gabbi driver to reflect new test handling
(The files didn't make it in the previous commit)
This commit is contained in:
@@ -2,4 +2,4 @@
|
|||||||
test_command=${PYTHON:-python} -m subunit.run discover gabbi $LISTOPT $IDOPTION
|
test_command=${PYTHON:-python} -m subunit.run discover gabbi $LISTOPT $IDOPTION
|
||||||
test_id_option=--load-list $IDFILE
|
test_id_option=--load-list $IDFILE
|
||||||
test_list_option=--list
|
test_list_option=--list
|
||||||
group_regex=([^_]+)
|
group_regex=gabbi\.driver\.(test_[^_]+_[^_]+)
|
||||||
|
@@ -28,6 +28,7 @@ An entire directory of YAML files is a TestSuite of TestSuites.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import glob
|
import glob
|
||||||
|
import inspect
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
@@ -280,7 +281,8 @@ class TestBuilder(type):
|
|||||||
return type.__new__(mcs, name, bases, attributes)
|
return type.__new__(mcs, name, bases, attributes)
|
||||||
|
|
||||||
|
|
||||||
def build_tests(path, loader, host=None, port=8001, intercept=None):
|
def build_tests(path, loader, host=None, port=8001, intercept=None,
|
||||||
|
test_file_name=None):
|
||||||
"""Read YAML files from a directory to create tests.
|
"""Read YAML files from a directory to create tests.
|
||||||
|
|
||||||
Each YAML file represents an ordered sequence of HTTP requests.
|
Each YAML file represents an ordered sequence of HTTP requests.
|
||||||
@@ -288,6 +290,11 @@ def build_tests(path, loader, host=None, port=8001, intercept=None):
|
|||||||
top_suite = suite.TestSuite()
|
top_suite = suite.TestSuite()
|
||||||
http = httplib2.Http()
|
http = httplib2.Http()
|
||||||
|
|
||||||
|
if test_file_name is None:
|
||||||
|
test_file_name = inspect.stack()[1]
|
||||||
|
test_file_name = os.path.splitext(os.path.basename(
|
||||||
|
test_file_name[1]))[0]
|
||||||
|
|
||||||
# Return an empty suite if we have no host to access, either via
|
# Return an empty suite if we have no host to access, either via
|
||||||
# a real host or an intercept
|
# a real host or an intercept
|
||||||
if not host and not intercept:
|
if not host and not intercept:
|
||||||
@@ -315,8 +322,9 @@ def build_tests(path, loader, host=None, port=8001, intercept=None):
|
|||||||
for test_datum in test_data:
|
for test_datum in test_data:
|
||||||
test = dict(base_test_data)
|
test = dict(base_test_data)
|
||||||
test.update(test_datum)
|
test.update(test_datum)
|
||||||
test_name = '%s_%s' % (test_base_name,
|
test_name = '%s_%s_%s' % (test_file_name,
|
||||||
test['name'].lower().replace(' ', '_'))
|
test_base_name,
|
||||||
|
test['name'].lower().replace(' ', '_'))
|
||||||
if set(test.keys()) != key_test:
|
if set(test.keys()) != key_test:
|
||||||
raise ValueError('Invalid Keys in test %s' % test_name)
|
raise ValueError('Invalid Keys in test %s' % test_name)
|
||||||
# Use metaclasses to build a class of the necessary type
|
# Use metaclasses to build a class of the necessary type
|
||||||
|
@@ -29,7 +29,7 @@ from six.moves.urllib import parse as urlparse
|
|||||||
from gabbi import driver
|
from gabbi import driver
|
||||||
|
|
||||||
|
|
||||||
TESTS_DIR = 'gabbits'
|
TESTS_DIR = 'gabbits_intercept'
|
||||||
METHODS = ['GET', 'PUT', 'POST', 'DELETE', 'PATCH']
|
METHODS = ['GET', 'PUT', 'POST', 'DELETE', 'PATCH']
|
||||||
|
|
||||||
|
|
||||||
|
@@ -21,11 +21,8 @@ For the sake of exploratory development.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
import json
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from six.moves.urllib import parse as urlparse
|
|
||||||
|
|
||||||
from gabbi import driver
|
from gabbi import driver
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user