Merge pull request #371 from coreos-inc/fmt

Fix tests in response to breakage in #351
This commit is contained in:
Jimmy Zelinskie 2015-08-17 16:27:53 -04:00
commit 3f6f5162e8
4 changed files with 14 additions and 7 deletions

View file

@ -2,13 +2,15 @@ import unittest
from endpoints.v1 import v1_bp
from endpoints.verbs import verbs
from app import app
class TestAnonymousAccessChecked(unittest.TestCase):
def verifyBlueprint(self, blueprint):
class Checker(object):
def __init__(self, test_case):
self.test_case = test_case
self.first_registration = True
self.app = app
def add_url_rule(self, rule, endpoint, view_function, methods=None):
if (not '__anon_protected' in dir(view_function) and

View file

@ -51,3 +51,5 @@ class TestConfig(DefaultConfig):
LICENSE_EXPIRATION_WARNING = datetime.now() + timedelta(weeks=520)
FEATURE_GITHUB_BUILD = True
CLOUDWATCH_NAMESPACE = None

View file

@ -18,11 +18,11 @@ def start_cloudwatch_sender(metrics, app):
"""
Starts sending from metrics to a new CloudWatchSender.
"""
try:
access_key = app.config['CLOUDWATCH_AWS_ACCESS_KEY']
secret_key = app.config['CLOUDWATCH_AWS_SECRET_KEY']
namespace = app.config['CLOUDWATCH_NAMESPACE']
except KeyError:
access_key = app.config.get('CLOUDWATCH_AWS_ACCESS_KEY')
secret_key = app.config.get('CLOUDWATCH_AWS_SECRET_KEY')
namespace = app.config.get('CLOUDWATCH_NAMESPACE')
if not namespace:
logger.debug('CloudWatch not configured')
return

View file

@ -19,7 +19,7 @@ class MetricQueue(object):
def put(self, name, value, **kwargs):
if self._queue is None:
logging.debug('No metric queue: %s %s %s', name, value, kwargs)
logger.debug('No metric queue %s %s %s', name, value, kwargs)
return
try:
@ -47,12 +47,15 @@ def time_after_request(name, metric_queue):
start = getattr(g, '_request_start_time', None)
if start is None:
return r
dur = time.time() - start
dims = {'endpoint': request.endpoint}
metric_queue.put('ResponseTime', dur, dimensions=dims, unit='Seconds')
metric_queue.put('ResponseCode', r.status_code, dimensions=dims)
if r.status_code < 200 or r.status_code >= 300:
metric_queue.put('Non200Response', 1, dimensions={'name': name})
return r
return f