api/metadata/vendordata_dynamic: don't import Requests for its constants

Python-requests isn't really needed, don't import it to prevent
copy/paste of the anti pattern of accessing it's codes directly.

Fix one unit test that was returning a 204 but actually including data
in it, but expecting that data to not be used.

Change-Id: I9f6eda0c3e6f7d390abca5e9e4ebe059788ee11f
This commit is contained in:
Jordan Pittier
2017-02-15 16:14:31 +01:00
committed by Sean Dague
parent 159bf6e4e4
commit b9587587c2
2 changed files with 3 additions and 5 deletions

View File

@@ -15,7 +15,6 @@
"""Render vendordata as stored fetched from REST microservices."""
import requests
import six
import sys
@@ -97,9 +96,7 @@ class DynamicVendorData(vendordata.VendorDataDriver):
res = self.session.request(url, 'POST', data=jsonutils.dumps(body),
verify=verify, headers=headers,
timeout=timeout)
if res.status_code in (requests.codes.OK,
requests.codes.CREATED,
requests.codes.ACCEPTED):
if res:
# TODO(mikal): Use the Cache-Control response header to do some
# sensible form of caching here.
return jsonutils.loads(res.text)