CottageLabs/OpenArticleGauge

Testing requires elastic search

Opened this issue · 1 comments

Currently tests don't run unless you have Elastic Search available. This is a problem for contributions because it means third party contributors can't test their code properly.

UK-MC-10081:tests cneylon$ nosetests test_bmc_new.py
E
======================================================================
ERROR: Failure: ConnectionError (HTTPConnectionPool(host='localhost', port=9200): Max retries exceeded with url: /oag/publisher/_mapping (Caused by : [Errno 61] Connection refused))
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/cneylon/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/nose/loader.py", line 413, in loadTestsFromName
    addr.filename, addr.module)
  File "/Users/cneylon/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/nose/importer.py", line 47, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "/Users/cneylon/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/nose/importer.py", line 94, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
  File "/Users/cneylon/Documents/Programming/plos/OpenArticleGauge/openarticlegauge/tests/test_bmc_new.py", line 5, in 
    from openarticlegauge import config, models
  File "/Users/cneylon/Documents/Programming/plos/OpenArticleGauge/openarticlegauge/models.py", line 10, in 
    from openarticlegauge.dao import DomainObject
  File "/Users/cneylon/Documents/Programming/plos/OpenArticleGauge/openarticlegauge/dao.py", line 13, in 
    from openarticlegauge.core import app #, current_user
  File "/Users/cneylon/Documents/Programming/plos/OpenArticleGauge/openarticlegauge/core.py", line 56, in 
    app = create_app()
  File "/Users/cneylon/Documents/Programming/plos/OpenArticleGauge/openarticlegauge/core.py", line 11, in create_app
    if app.config['INITIALISE_INDEX']: initialise_index(app)
  File "/Users/cneylon/Documents/Programming/plos/OpenArticleGauge/openarticlegauge/core.py", line 36, in initialise_index
    exists = requests.get(im)
  File "/Users/cneylon/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/requests-1.1.0-py2.7.egg/requests/api.py", line 55, in get
    return request('get', url, **kwargs)
  File "/Users/cneylon/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/requests-1.1.0-py2.7.egg/requests/api.py", line 44, in request
    return session.request(method=method, url=url, **kwargs)
  File "/Users/cneylon/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/requests-1.1.0-py2.7.egg/requests/sessions.py", line 279, in request
    resp = self.send(prep, stream=stream, timeout=timeout, verify=verify, cert=cert, proxies=proxies)
  File "/Users/cneylon/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/requests-1.1.0-py2.7.egg/requests/sessions.py", line 374, in send
    r = adapter.send(request, **kwargs)
  File "/Users/cneylon/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/requests-1.1.0-py2.7.egg/requests/adapters.py", line 209, in send
    raise ConnectionError(e)
ConnectionError: HTTPConnectionPool(host='localhost', port=9200): Max retries exceeded with url: /oag/publisher/_mapping (Caused by : [Errno 61] Connection refused)
-------------------- >> begin captured logging << --------------------
requests.packages.urllib3.connectionpool: INFO: Starting new HTTP connection (1): localhost
--------------------- >> end captured logging << ---------------------

----------------------------------------------------------------------
Ran 1 test in 0.001s

FAILED (errors=1)

the problem: tests rely on models.MessageObject

Suggest mock MessageObject which does not rely on ES? There won't be a way for it to subclass the real models.MessageObject, any importing of models will import the code which prepares the index (correctly so..). It will have to explicitly mock functions needed by the tests, which are only a few, so should not be a big deal.