예제 #1
0
def send_minichat_update_message(sender, **kwargs):
    if not kwargs.get('raw', False): # check that this is not a fixture
        try:
            RedisPublisher = get_redis_publisher()
            redis_publisher = RedisPublisher(facility='lexpage', broadcast=True)
            message = {'action': 'reload_minichat', 'app': 'minichat'}
            redis_message = RedisMessage(json.dumps(message))
            redis_publisher.publish_message(redis_message)
        except ConnectionError:
            logger = logging.getLogger()
            logger.exception('Error when publishing a message to the websocket channel')
예제 #2
0
def send_notification_update_message(sender, **kwargs):
    if not kwargs.get('raw', False): # check that this is not a fixture
        try:
            RedisPublisher = get_redis_publisher()
            notification = kwargs.get('instance')
            redis_publisher = RedisPublisher(facility='lexpage', users=[notification.recipient])
            counter = str(len(sender.objects.filter(recipient__id=notification.recipient.id)))
            message = {'action': 'update_counter', 'data': counter, 'app': 'notifications'}
            redis_message = RedisMessage(json.dumps(message))
            redis_publisher.publish_message(redis_message)
        except ConnectionError:
            logger = logging.getLogger()
            logger.exception('Error when publishing a message to the websocket channel')
예제 #3
0
import os

from django.test import LiveServerTestCase
from django.utils.module_loading import import_string
from django.conf import settings
from django.core.urlresolvers import reverse
from django.db import connection
from django.core.servers.basehttp import WSGIServer
from django.test.testcases import LiveServerThread, QuietWSGIRequestHandler, _StaticFilesHandler

from ws4redis.django_runserver import _websocket_url, _websocket_app, _django_app

from socketserver import ThreadingMixIn

from redis_helpers import get_redis_publisher
redis_publisher = get_redis_publisher()


###### Selenium setup

try:
    from selenium.webdriver.support.wait import WebDriverWait
    SELENIUM_AVAILABLE = True
except ImportError:
    SELENIUM_AVAILABLE = False

if getattr(settings, 'SELENIUM_WEBDRIVER', None) and SELENIUM_AVAILABLE:
    WebDriver = import_string(settings.SELENIUM_WEBDRIVER)
else:
    WebDriver = None