Skip to content

Commit

Permalink
Reach 100% test coverage.
Browse files Browse the repository at this point in the history
  • Loading branch information
jsmits committed Jul 31, 2015
1 parent 20d7763 commit 1a0183f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ History
0.2.5 (unreleased)
++++++++++++++++++

- Nothing changed yet.
- Reach 100% test coverage.


0.2.4 (2015-07-31)
Expand Down
16 changes: 16 additions & 0 deletions tests/middleware/test_middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,19 @@ def test_logging_middleware_with_user_email(caplog):
lmw.process_response(request, HttpResponse())
record = caplog.records()[0]
assert record.user_email == 'john@example.com'


def test_loglevel_warning_if_request_threshold_exceeded(caplog):
lmw = middleware.LoggingMiddleware()
lmw.start_time = time.time() - 2 # put the rquest two seconds back in time
lmw.process_response(HttpRequest(), HttpResponse())
record = caplog.records()[0]
assert record.levelname == 'WARNING'


def test_logging_middleware_process_response_exception(caplog):
lmw = middleware.LoggingMiddleware()
# force an AttributeError by using None as response
lmw.process_response(HttpRequest(), None)
record = caplog.records()[0]
assert record.levelname == 'ERROR'

0 comments on commit 1a0183f

Please sign in to comment.