DRY test_connection

An earlier change [1] wastefully subclassed TestConnection when all it
needed was the setUp(). The subclass was redundantly running all the
superclass's tests again.

This commit factors out the setUp into a local base class and subclasses
that base class from TestConnection and TestOsloConfig, cutting out 14
redundant tests.

[1] I3d16d17caa2e8a58b7064c54e930468288aa6ff1

Change-Id: If65d7c23e07d9f232410a562e47f183d003a7dc0
This commit is contained in:
Eric Fried 2019-08-12 14:13:13 -05:00
parent 8a81f8dd7b
commit ad0a52033c
1 changed files with 5 additions and 3 deletions

View File

@ -94,10 +94,10 @@ public-clouds:
""".format(auth_url=CONFIG_AUTH_URL)
class TestConnection(base.TestCase):
class _TestConnectionBase(base.TestCase):
def setUp(self):
super(TestConnection, self).setUp()
super(_TestConnectionBase, self).setUp()
# Create a temporary directory where our test config will live
# and insert it into the search path via OS_CLIENT_CONFIG_FILE.
config_dir = self.useFixture(fixtures.TempDir()).path
@ -110,6 +110,8 @@ class TestConnection(base.TestCase):
"OS_CLIENT_CONFIG_FILE", config_path))
self.use_keystone_v2()
class TestConnection(_TestConnectionBase):
def test_other_parameters(self):
conn = connection.Connection(cloud='sample-cloud', cert='cert')
self.assertEqual(conn.session.cert, 'cert')
@ -261,7 +263,7 @@ class TestConnection(base.TestCase):
self.assertFalse(sot.session.verify)
class TestOsloConfig(TestConnection):
class TestOsloConfig(_TestConnectionBase):
def test_from_conf(self):
c1 = connection.Connection(cloud='sample-cloud')
conn = connection.Connection(