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

Commit

Permalink
Add tests for LoggingSender.
Browse files Browse the repository at this point in the history
  • Loading branch information
hodgestar committed Jun 25, 2014
1 parent 8696c13 commit f3dbc24
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
2 changes: 1 addition & 1 deletion go_http/send.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def send_text(self, to_addr, content):
"to_addr": to_addr,
}

def fire_metric(self, metric, value, agg):
def fire_metric(self, metric, value, agg="last"):
""" Fire a value for a metric.
:param str metric:
Expand Down
27 changes: 25 additions & 2 deletions go_http/tests/test_send.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from requests_testadapter import TestAdapter, TestSession

from go_http.send import HttpApiSender
from go_http.send import HttpApiSender, LoggingSender


class RecordingAdapter(TestAdapter):
Expand Down Expand Up @@ -84,4 +84,27 @@ def test_fire_metric_default_agg(self):


class TestLoggingSender(TestCase):
pass
def setUp(self):
self.sender = LoggingSender('go_http.test')

def test_send_text(self):
result = self.sender.send_text("to-addr-1", "Hello!")
self.assertEqual(result, {
"message_id": result["message_id"],
"to_addr": "to-addr-1",
"content": "Hello!",
})

def test_fire_metric(self):
result = self.sender.fire_metric("metric-1", 5.1, agg="max")
self.assertEqual(result, {
"success": True,
"reason": "Metrics published",
})

def test_fire_metric_default_agg(self):
result = self.sender.fire_metric("metric-1", 5.2)
self.assertEqual(result, {
"success": True,
"reason": "Metrics published",
})

0 comments on commit f3dbc24

Please sign in to comment.