Skip to content
Snippets Groups Projects
Commit 9f8f82ae authored by Benjamin Becker's avatar Benjamin Becker
Browse files

adds more unit tests for icap

parent 60cefa28
No related branches found
No related tags found
No related merge requests found
import nose.tools as nt import nose.tools as nt
from testfixtures import log_capture
from ckan.common import config from ckan.common import config
from ckanext.odsh.lib.odsh_icap_client import ODSHICAPRequest, _read_from_config from ckanext.odsh.lib.odsh_icap_client import ODSHICAPRequest, _read_from_config
...@@ -20,6 +21,36 @@ class Test_ODSHICAPRequest(object): ...@@ -20,6 +21,36 @@ class Test_ODSHICAPRequest(object):
nt.assert_equal(request.PORT, 123) nt.assert_equal(request.PORT, 123)
nt.assert_equal(request.CLIENTIP, 'some_ip') nt.assert_equal(request.CLIENTIP, 'some_ip')
@log_capture()
def test_it_logs_missing_parameter_host_to_error_log(self, capture):
del config['ckanext.odsh.icap.host']
ODSHICAPRequest('some_filename', 'some_filebuffer')
capture.check((
'ckanext.odsh.lib.odsh_icap_client',
'ERROR',
"'key ckanext.odsh.icap.host is not defined in ckan config file.'"
))
@log_capture()
def test_it_logs_missing_parameter_port_to_error_log(self, capture):
del config['ckanext.odsh.icap.port']
ODSHICAPRequest('some_filename', 'some_filebuffer')
capture.check((
'ckanext.odsh.lib.odsh_icap_client',
'ERROR',
"'key ckanext.odsh.icap.port is not defined in ckan config file.'"
))
@log_capture()
def test_it_logs_missing_parameter_clientip_to_error_log(self, capture):
del config['ckanext.odsh.icap.clientip']
ODSHICAPRequest('some_filename', 'some_filebuffer')
capture.check((
'ckanext.odsh.lib.odsh_icap_client',
'ERROR',
"'key ckanext.odsh.icap.clientip is not defined in ckan config file.'"
))
def test_read_from_config_raises_KeyError_if_host_not_defined_in_config(self): def test_read_from_config_raises_KeyError_if_host_not_defined_in_config(self):
del config['ckanext.odsh.icap.host'] del config['ckanext.odsh.icap.host']
with nt.assert_raises(KeyError): with nt.assert_raises(KeyError):
......
alabaster==0.7.11
amqp==1.4.9
anyjson==0.3.3
arrow==0.13.1
asn1crypto==0.24.0
astroid==1.6.6
atomicwrites==1.3.0
attrs==19.3.0
Babel==2.3.4
backports.functools-lru-cache==1.5
Beaker==1.8.1
beautifulsoup4==4.5.1
billiard==3.3.0.23
bleach==1.5.0
blinker==1.4
celery==3.1.25
certifi==2018.8.13
cffi==1.11.5
chardet==3.0.4
click==6.7
configparser==3.7.4
contextlib2==0.6.0.post1
cookies==2.2.1
coverage==4.5.1
coveralls==1.3.0
cryptography==2.3
decorator==4.0.6
defusedxml==0.6.0
dnspython==1.16.0
docopt==0.6.2
docutils==0.12
entrypoints==0.3
enum34==1.1.6
eventlet==0.24.1
extras==1.0.0
factory-boy==2.1.1
fanstatic==0.12
filehash==0.1.dev3
first==2.0.1
fixtures==3.0.0
flake8==3.7.8
Flask==0.11.1
Flask-DebugToolbar==0.10.0
FormEncode==1.3.0
funcsigs==1.0.2
functools32==3.2.3.post2
futures==3.3.0
GeoAlchemy==0.7.2
GeoAlchemy2==0.4.2
geolinks==0.2.0
geomet==0.2.0.post2
greenlet==0.4.15
html5lib==0.9999999
httpretty==0.8.3
hupper==1.6.1
idna==2.7
imagesize==1.0.0
importlib-metadata==0.23
ipaddress==1.0.22
isodate==0.6.0
isort==4.3.21
itsdangerous==0.24
Jinja2==2.8
json-table-schema==0.2.1
kombu==3.0.37
lazy-object-proxy==1.4.1
linecache2==1.0.0
lxml==3.6.2
Mako==1.0.4
Markdown==2.6.7
MarkupSafe==0.23
mccabe==0.6.1
messytables==0.15.2
mock==2.0.0
monotonic==1.5
more-itertools==5.0.0
mox3==0.26.0
multiline-log-formatter==0.1.8
nose==1.3.7
ofs==0.4.2
ordereddict==1.1
OWSLib==0.16.0
packaging==17.1
Pairtree===0.7.1-T
passlib==1.6.5
Paste==1.7.5.1
PasteDeploy==2.0.1
PasteScript==2.0.2
pathlib==1.0.1
pathlib2==2.3.5
pbr==1.10.0
pdf2image==1.9.0
pdftotext==2.1.2
pika==0.12.0
Pillow==6.1.0
pip-tools==1.7.0
piwikapi==0.3
pkg-resources==0.0.0
plaster==1.0
plaster-pastedeploy==0.7
pluggy==0.13.0
polib==1.0.7
progressbar==2.3
psycopg2==2.7.3.2
py==1.8.0
pyasn1==0.4.8
pycodestyle==2.5.0
pycountry==18.5.26
pycparser==2.18
pycrypto==2.6.1
pycryptodome==3.9.0
pycsw==2.2.0
pyfakefs==2.9
pyflakes==2.1.1
Pygments==2.1.3
pylint==1.9.5
Pylons==0.9.7
pymongo==3.9.0
pyOpenSSL==18.0.0
pyparsing==2.2.0
pyproj==1.9.5.1
pyramid==1.10.4
pyramid-exclog==0.1
-e git+https://github.com/IdentityPython/pysaml2.git@247e2f642b37de90a61c4f5ca49d8403840b6ea2#egg=pysaml2
pysolr==3.6.0
pytest==4.6.6
pytest-cov==2.8.1
python-dateutil==2.8.0
python-json-logger==0.1.11
python-magic==0.4.12
python-memcached==1.48
python-mimeparse==1.6.0
pytz==2016.7
pyutilib.component.core==4.6.4
rdflib==4.2.1
rdflib-jsonld==0.4.0
redis==2.10.1
repoze.lru==0.6
repoze.who==2.3
repoze.who-friendlyform==1.0.8
requests==2.11.1
responses==0.10.6
rope==0.14.0
Routes==1.13
rq==0.6.0
rq-dashboard==0.4.0
scandir==1.10.0
selenium==3.141.0
Shapely==1.5.17
simplejson==3.10.0
singledispatch==3.4.0.3
six==1.10.0
snowballstemmer==1.2.1
SPARQLWrapper==1.8.2
Sphinx==1.7.1
sphinx-rtd-theme==0.3.1
sphinxcontrib-websupport==1.1.0
SQLAlchemy==0.9.6
sqlalchemy-migrate==0.10.0
sqlparse==0.2.2
Tempita==0.5.2
testfixtures==6.10.3
testtools==2.3.0
traceback2==1.4.0
translationstring==1.3
typing==3.6.4
tzlocal==1.3
unicodecsv==0.14.1
unittest2==1.1.0
urllib3==1.23
vdm==0.13
venusian==1.2.0
vine==1.1.4
wcwidth==0.1.7
WebError==0.13.1
WebHelpers==1.3
WebOb==1.0.8
WebTest==1.4.3
Werkzeug==0.11.10
wrapt==1.11.2
xlrd==1.0.0
xmltodict==0.10.2
zipp==0.6.0
zope.deprecation==4.4.0
zope.interface==4.3.2
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment