Update gabbi driver to reflect new test handling

(The files didn't make it in the previous commit)
This commit is contained in:
Chris Dent
2014-12-27 18:50:05 +00:00
parent 3c4645a15d
commit d17c3d03fb
4 changed files with 13 additions and 8 deletions

View File

@@ -2,4 +2,4 @@
test_command=${PYTHON:-python} -m subunit.run discover gabbi $LISTOPT $IDOPTION
test_id_option=--load-list $IDFILE
test_list_option=--list
group_regex=([^_]+)
group_regex=gabbi\.driver\.(test_[^_]+_[^_]+)

View File

@@ -28,6 +28,7 @@ An entire directory of YAML files is a TestSuite of TestSuites.
"""
import glob
import inspect
import json
import os
import re
@@ -280,7 +281,8 @@ class TestBuilder(type):
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.
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()
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
# a real host or an 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:
test = dict(base_test_data)
test.update(test_datum)
test_name = '%s_%s' % (test_base_name,
test['name'].lower().replace(' ', '_'))
test_name = '%s_%s_%s' % (test_file_name,
test_base_name,
test['name'].lower().replace(' ', '_'))
if set(test.keys()) != key_test:
raise ValueError('Invalid Keys in test %s' % test_name)
# Use metaclasses to build a class of the necessary type

View File

@@ -29,7 +29,7 @@ from six.moves.urllib import parse as urlparse
from gabbi import driver
TESTS_DIR = 'gabbits'
TESTS_DIR = 'gabbits_intercept'
METHODS = ['GET', 'PUT', 'POST', 'DELETE', 'PATCH']

View File

@@ -21,11 +21,8 @@ For the sake of exploratory development.
"""
import json
import os
from six.moves.urllib import parse as urlparse
from gabbi import driver