Use testscenarios to set attributes directly

testscenarios was previously used to set an intermediary symbol, which
then set additional attributes. This got really complicated to figure
out what scenarios were really doing, and how to add more (or bypass
them in tests).

This clarifies that usage, unwinds the testscenarios simplifying what
gets set up.

It also starts making calls to API v2.1 on the v2.1 url. This is
supported with existing API samples docs with a mechanism to update
links if they exist in the docs.

Change-Id: I9affc046300295cdf3e284ccc736019ccaffb9f2
This commit is contained in:
Sean Dague
2015-12-10 08:47:07 -05:00
parent e31f9a9811
commit ede70a1973
13 changed files with 109 additions and 52 deletions

View File

@@ -247,6 +247,13 @@ class ApiSampleTestBase(integrated_helpers._IntegratedTestBase):
"""
return subs
def _update_links(self, sample_data):
"""Process sample data and update version specific links."""
url_re = self._get_host() + "/v(2|2\.1)"
new_url = self._get_host() + "/" + self._api_version
updated_data = re.sub(url_re, new_url, sample_data)
return updated_data
def _verify_response(self, name, subs, response, exp_code):
self.assertEqual(exp_code, response.status_code)
response_data = response.content
@@ -267,6 +274,7 @@ class ApiSampleTestBase(integrated_helpers._IntegratedTestBase):
with file(self._get_sample(name,
self.request_api_version)) as sample:
sample_data = sample.read()
sample_data = self._update_links(sample_data)
try:
template_data = self._objectify(template_data)