Skip to content

Commit

Permalink
tests: increase cover
Browse files Browse the repository at this point in the history
  • Loading branch information
cahytinne committed Jul 30, 2015
1 parent 755bd29 commit 347a45f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ py==1.4.26
coveralls==0.4.4
webtest==2.0.16
mock==1.0.1
testfixtures==4.1.2

# Documentation
Sphinx==1.2.3
Expand Down
12 changes: 12 additions & 0 deletions tests/test_audit.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@
import unittest
from atramhasis.audit import audit, _origin_from_response
from pyramid.response import Response
import logging
from testfixtures import LogCapture

try:
from unittest.mock import Mock, MagicMock
except ImportError:
from mock import Mock, MagicMock, call # pragma: no cover

log = logging.getLogger('')


class RecordingManager(object):

Expand Down Expand Up @@ -96,6 +100,14 @@ def test_audit_other(self):
self.dummy_parent.dummy()
self._check(2, None, ['conceptscheme_id', 'concept_id'])

def test_invalid_use(self):
with LogCapture() as logs:
self.dummy_parent.request.url = "http://host/conceptschemes/STYLES"
self.dummy_parent.request.accept = ['application/json']
self.dummy_parent.request.matchdict = {'invalid_parameter_id': '1'}
self.dummy_parent.dummy()
self.assertIn('Misuse of the audit decorator. The url must at least contain a {scheme_id} parameter', str(logs))

def test_origin_from_response(self):
res = Response(content_type='application/rdf+xml')
self.assertEqual('RDF', _origin_from_response(res))
Expand Down
2 changes: 2 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ deps =
pytest
webtest
mock
testfixtures
commands =
pip install -r requirements-dev.txt
py.test
Expand All @@ -18,6 +19,7 @@ deps =
pytest-cov
webtest
mock
testfixtures
commands =
pip install -r requirements-dev.txt
py.test --cov atramhasis --cov-report term-missing tests

0 comments on commit 347a45f

Please sign in to comment.