remove use of _get_regexes in samples tests

There was an exceptionally large amount of rote use of _get_regexes
throughout the samples tests, which doesn't provide any additional
explicitness in what's happening, and only couples the tests to the
base class in less useful ways.

Instead, when we call _verify_response, always also use the base
vanilla regexes for matching tests.

We also needed to add a few more variables to the list which always
need to be reset before testing against the static samples, because
uuids are often generated on the fly for the tests.

Lastly, test_keypairs needed some test specific surgery. It is so
highly normalized (with private test methods that take **kwargs) at
this point that it's not really clear that it's testing useful things
any more. This really needs denormalization.

Change-Id: I165b0f3aa2132373cb59982a5a5ded37b4fa1b52
This commit is contained in:
Sean Dague
2015-12-14 10:12:13 -05:00
parent 21f6f7b63a
commit 5ac81f47a4
60 changed files with 160 additions and 282 deletions

View File

@@ -257,6 +257,13 @@ class ApiSampleTestBase(integrated_helpers._IntegratedTestBase):
def _verify_response(self, name, subs, response, exp_code,
update_links=True):
# Always also include the laundry list of base regular
# expressions for possible key values in our templates. Test
# specific patterns (the value of ``subs``) can override
# these.
regexes = self._get_regexes()
regexes.update(subs)
subs = regexes
self.assertEqual(exp_code, response.status_code)
response_data = response.content
response_data = pretty_data(response_data)
@@ -291,6 +298,8 @@ class ApiSampleTestBase(integrated_helpers._IntegratedTestBase):
vanilla_regexes = self._get_regexes()
subs['compute_host'] = vanilla_regexes['host_name']
subs['id'] = vanilla_regexes['id']
subs['uuid'] = vanilla_regexes['uuid']
subs['image_id'] = vanilla_regexes['uuid']
subs = self.generalize_subs(subs, vanilla_regexes)
sample_data = objectify(sample_data)
self._compare_result(subs, template_data, sample_data, "Sample")