Commit caa49ced by Gabe Mulley

clean up some minor details

* Ensure "from future import __absolute__" is included in new files
* Clean up some doc strings
* Remove __ prefix from some internal test methods
parent 1b56a606
[run] [run]
branch = True branch = True
omit = *mock* include = eventtracking*
""" """
Test the event tracking module Test the event tracking module
""" """
from __future__ import absolute_import
from datetime import datetime from datetime import datetime
from unittest import TestCase from unittest import TestCase
...@@ -28,9 +29,9 @@ class TestTrack(TestCase): # pylint: disable=missing-docstring ...@@ -28,9 +29,9 @@ class TestTrack(TestCase): # pylint: disable=missing-docstring
def test_event_simple_event_without_data(self): def test_event_simple_event_without_data(self):
track.event(sentinel.event_type) track.event(sentinel.event_type)
self.__assert_backend_called_with(sentinel.event_type) self.assert_backend_called_with(sentinel.event_type)
def __assert_backend_called_with(self, event_type, data=None, backend=None): def assert_backend_called_with(self, event_type, data=None, backend=None):
"""Ensures the backend is called exactly once with the expected data.""" """Ensures the backend is called exactly once with the expected data."""
if not backend: if not backend:
backend = self._mock_backend backend = self._mock_backend
...@@ -51,7 +52,7 @@ class TestTrack(TestCase): # pylint: disable=missing-docstring ...@@ -51,7 +52,7 @@ class TestTrack(TestCase): # pylint: disable=missing-docstring
} }
) )
self.__assert_backend_called_with( self.assert_backend_called_with(
sentinel.event_type, sentinel.event_type,
{ {
sentinel.key: sentinel.value sentinel.key: sentinel.value
...@@ -64,8 +65,8 @@ class TestTrack(TestCase): # pylint: disable=missing-docstring ...@@ -64,8 +65,8 @@ class TestTrack(TestCase): # pylint: disable=missing-docstring
try: try:
track.event(sentinel.event_type) track.event(sentinel.event_type)
self.__assert_backend_called_with(sentinel.event_type) self.assert_backend_called_with(sentinel.event_type)
self.__assert_backend_called_with( self.assert_backend_called_with(
sentinel.event_type, backend=another_backend) sentinel.event_type, backend=another_backend)
finally: finally:
track.BACKENDS.remove(another_backend) track.BACKENDS.remove(another_backend)
...@@ -78,7 +79,7 @@ class TestTrack(TestCase): # pylint: disable=missing-docstring ...@@ -78,7 +79,7 @@ class TestTrack(TestCase): # pylint: disable=missing-docstring
try: try:
track.event(sentinel.event_type) track.event(sentinel.event_type)
self.__assert_backend_called_with( self.assert_backend_called_with(
sentinel.event_type, backend=another_backend) sentinel.event_type, backend=another_backend)
finally: finally:
track.BACKENDS.remove(another_backend) track.BACKENDS.remove(another_backend)
...@@ -13,6 +13,8 @@ Best Practices: ...@@ -13,6 +13,8 @@ Best Practices:
equivalent to another, say so in your documenation, and the analyst equivalent to another, say so in your documenation, and the analyst
can decide whether or not to group them. can decide whether or not to group them.
""" """
from __future__ import absolute_import
from datetime import datetime from datetime import datetime
import logging import logging
...@@ -25,8 +27,9 @@ def event(event_type, data=None): ...@@ -25,8 +27,9 @@ def event(event_type, data=None):
""" """
Emit an event annotated with the UTC time when this function was called. Emit an event annotated with the UTC time when this function was called.
:event_type: A unique identification string for an event that has already been registered. `event_type` is a unique identification string for an event that has already been registered.
:data: A dictionary mapping field names to the value to include in the event. Note that all values provided must be serializable. `data` is a dictionary mapping field names to the value to include in the event.
Note that all values provided must be serializable.
""" """
full_event = { full_event = {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment