Skip Algolia in unit tests.
Unit tests hang when our internet connection dropped.
This commit is contained in:
parent
0faecdb4fe
commit
b894eb2477
@ -1,13 +1,15 @@
|
||||
import copy
|
||||
import json
|
||||
import datetime
|
||||
import functools
|
||||
import logging
|
||||
|
||||
import bson
|
||||
from eve import RFC1123_DATE_FORMAT
|
||||
from flask import current_app
|
||||
|
||||
__all__ = ('remove_private_keys', 'PillarJSONEncoder')
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
def remove_private_keys(document):
|
||||
"""Removes any key that starts with an underscore, returns result as new
|
||||
@ -52,3 +54,16 @@ def jsonify(mongo_doc, status=200, headers=None):
|
||||
mimetype='application/json',
|
||||
status=status,
|
||||
headers=headers)
|
||||
|
||||
|
||||
def skip_when_testing(func):
|
||||
"""Decorator, skips the decorated function when app.config['TESTING']"""
|
||||
|
||||
@functools.wraps(func)
|
||||
def wrapper(*args, **kwargs):
|
||||
if current_app.config['TESTING']:
|
||||
log.debug('Skipping call to %s(...) due to TESTING', func.func_name)
|
||||
return None
|
||||
|
||||
return func(*args, **kwargs)
|
||||
return wrapper
|
||||
|
@ -1,10 +1,16 @@
|
||||
import logging
|
||||
|
||||
from bson import ObjectId
|
||||
from flask import current_app
|
||||
|
||||
from application import algolia_index_users
|
||||
from application import algolia_index_nodes
|
||||
from application.modules.file_storage import generate_link
|
||||
from . import skip_when_testing
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@skip_when_testing
|
||||
def algolia_index_user_save(user):
|
||||
# Define accepted roles
|
||||
accepted_roles = ['admin', 'subscriber', 'demo']
|
||||
@ -24,7 +30,7 @@ def algolia_index_user_save(user):
|
||||
'email': user['email']
|
||||
})
|
||||
|
||||
|
||||
@skip_when_testing
|
||||
def algolia_index_node_save(node):
|
||||
accepted_node_types = ['asset', 'texture', 'group']
|
||||
if node['node_type'] in accepted_node_types and algolia_index_nodes:
|
||||
|
Loading…
x
Reference in New Issue
Block a user