~veebers/autopilot/move-testing-process-run-fixture

« back to all changes in this revision

Viewing changes to autopilot/tests/unit/test_logging.py

  • Committer: Tarmac
  • Author(s): Thomi Richards
  • Date: 2014-07-15 05:09:59 UTC
  • mfrom: (497.4.12 refactor-test-logger)
  • Revision ID: tarmac-20140715050959-6c0orwme4v2t8ofu
Refactor test logging code.

Approved by PS Jenkins bot, Christopher Lee.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 
22
22
import logging
23
23
 
 
24
from unittest.mock import Mock
24
25
import testtools
25
26
 
26
27
from autopilot.logging import log_action
 
28
from autopilot._logging import TestCaseLoggingFixture
27
29
 
28
30
 
29
31
class LogHandlerTestCase(testtools.TestCase):
138
140
            "Do something with a multiline docstring. "
139
141
            "Arguments ('arg1', 'arg2'). "
140
142
            "Keyword arguments: {'arg3': 'arg3', 'arg4': 'arg4'}.")
 
143
 
 
144
 
 
145
class TestCaseLoggingFixtureTests(testtools.TestCase):
 
146
 
 
147
    def test_test_log_is_added(self):
 
148
        token = self.getUniqueString()
 
149
        add_detail_fn = Mock()
 
150
        fixture = TestCaseLoggingFixture("Test.id", add_detail_fn)
 
151
        fixture.setUp()
 
152
        logging.getLogger(__name__).info(token)
 
153
        fixture.cleanUp()
 
154
 
 
155
        self.assertEqual(1, add_detail_fn.call_count)
 
156
        self.assertEqual('test-log', add_detail_fn.call_args[0][0])
 
157
        self.assertIn(token, add_detail_fn.call_args[0][1].as_text())