Skip to content
This repository has been archived by the owner on Oct 27, 2022. It is now read-only.

Commit

Permalink
PEP8
Browse files Browse the repository at this point in the history
  • Loading branch information
imsickofmaps committed Nov 25, 2014
1 parent b8ef812 commit a4c33cd
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions go_http/tests/test_metrics.py
Expand Up @@ -14,6 +14,7 @@


class RecordingAdapter(TestAdapter):

""" Record the request that was handled by the adapter.
"""
request = None
Expand All @@ -22,7 +23,9 @@ def send(self, request, *args, **kw):
self.request = request
return super(RecordingAdapter, self).send(request, *args, **kw)


class TestMetricApiReader(TestCase):

def setUp(self):
self.session = TestSession()
self.sender = MetricsApiClient(
Expand Down Expand Up @@ -51,23 +54,25 @@ def check_request(self, request, method, data=None, headers=None):
self.assertEqual(request.headers[key], value)

def test_send_request(self):
response = {u'stores.store_name.metric_name.agg': [{u'x': 1413936000000,
u'y': 88916.0},
{u'x': 1414022400000,
u'y': 91339.0},
{u'x': 1414108800000,
u'y': 92490.0},
{u'x': 1414195200000,
u'y': 92655.0},
{u'x': 1414281600000,
u'y': 92786.0}]}
response = {u'stores.store_name.metric_name.agg':
[{u'x': 1413936000000,
u'y': 88916.0},
{u'x': 1414022400000,
u'y': 91339.0},
{u'x': 1414108800000,
u'y': 92490.0},
{u'x': 1414195200000,
u'y': 92655.0},
{u'x': 1414281600000,
u'y': 92786.0}]}
adapter = RecordingAdapter(json.dumps(response))
self.session.mount(
"http://example.com/api/v1/go/"
"metrics?m=stores.store_name.metric_name.agg"
"&interval=1d&from=-30d&nulls=omit", adapter)

result = self.sender.get_metric("stores.store_name.metric_name.agg", "-30d", "1d", "omit")
result = self.sender.get_metric(
"stores.store_name.metric_name.agg", "-30d", "1d", "omit")
self.assertEqual(result, response)
self.check_request(
adapter.request, 'GET',
Expand Down

0 comments on commit a4c33cd

Please sign in to comment.