#
# Copyright 2014, 2015 Red Hat. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
"""Test that the driver can build tests effectively.
"""

import os
import testtools
import unittest

from gabbi import driver

TESTS_DIR = 'test_gabbits'


class DriverTest(testtools.TestCase):

    def setUp(self):
        super(DriverTest, self).setUp()
        self.loader = unittest.defaultTestLoader
        self.test_dir = os.path.join(os.path.dirname(__file__), TESTS_DIR)

    def test_driver_loads_one_test(self):
        suite = driver.build_tests(self.test_dir, self.loader,
                                   host='localhost', port=8001)
        self.assertEqual(1, len(suite._tests),
                         'top level suite contains one suite')
        self.assertEqual(1, len(suite._tests[0]._tests),
                         'contained suite contains one test')
        self.assertEqual('test_driver_single_one',
                         suite._tests[0]._tests[0].__class__.__name__,
                         'test class name maps')

@@ -667,25 +667,8 @@
  os%0A
-import testtools%0A
 impo
@@ -679,16 +679,16 @@
 nittest%0A
+
 %0Afrom ga
@@ -756,17 +756,16 @@
 est(
+unit
 test
-tools
 .Tes
@@ -1479,16 +1479,16 @@
 name__,%0A
-
         
@@ -1528,8 +1528,1064 @@
  maps')%0A
+%0A    def test_build_requires_host_or_intercept(self):%0A        with self.assertRaises(AssertionError):%0A            driver.build_tests(self.test_dir, self.loader)%0A%0A    def test_name_key_required(self):%0A        test_yaml = %7B'tests': %5B%7B'url': '/'%7D%5D%7D%0A%0A        with self.assertRaises(AssertionError) as failure:%0A            driver.test_suite_from_yaml(self.loader, 'foo', test_yaml, '.',%0A                                        'localhost', 80, None, None)%0A        self.assertEqual('Test name missing in a test in foo.',%0A                         str(failure.exception))%0A%0A    def test_unsupported_key_errors(self):%0A        test_yaml = %7B'tests': %5B%7B%0A            'url': '/',%0A            'name': 'simple',%0A            'bad_key': 'wow',%0A        %7D%5D%7D%0A%0A        with self.assertRaises(AssertionError) as failure:%0A            driver.test_suite_from_yaml(self.loader, 'foo', test_yaml, '.',%0A                                        'localhost', 80, None, None)%0A        self.assertIn(%22Invalid test keys used in test foo_simple:%22,%0A                      str(failure.exception))%0A

Add some more superficial tests driver.py