Disable notify_new_message calls in testing and populate_db

(imported from commit 07a0fea4173e2e27a90ac5f111927f0000377764)
This commit is contained in:
Keegan McAllister 2012-10-12 15:27:19 -04:00
parent 648755ebbd
commit ea916951f4
4 changed files with 14 additions and 4 deletions

View File

@ -92,6 +92,11 @@ INITIAL_API_KEY_SALT = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
# FIXME: store this password more securely
SHARED_SECRET = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
# Are we running in an environment with the Tornado server?
# This should be True for both deployment and local development.
# We set it to False when running tests or populate_db.
HAVE_TORNADO_SERVER = True
# URL where Django code posts to the Tornado code to notify of new messages
NOTIFY_NEW_MESSAGE_URL = 'http://localhost:9993/notify_new_message'

View File

@ -16,6 +16,8 @@ import datetime
import random
from optparse import make_option
settings.HAVE_TORNADO_SERVER = False
def create_users(name_list):
for name, email in name_list:
(short_name, domain) = email.split("@")

View File

@ -286,10 +286,12 @@ def do_send_message(message, synced_from_mit=False, no_log=False):
for user_profile in recipients:
UserMessage(user_profile=user_profile, message=message).save()
requests.post(settings.NOTIFY_NEW_MESSAGE_URL, data=[
('secret', settings.SHARED_SECRET),
('message', message.id)]
+ [('user', user.id) for user in recipients])
# We can only publish messages to longpolling clients if the Tornado server is running.
if settings.HAVE_TORNADO_SERVER:
requests.post(settings.NOTIFY_NEW_MESSAGE_URL, data=[
('secret', settings.SHARED_SECRET),
('message', message.id)]
+ [('user', user.id) for user in recipients])
class Subscription(models.Model):
userprofile = models.ForeignKey(UserProfile)

View File

@ -18,6 +18,7 @@ import re
settings.MESSAGE_LOG = "/tmp/test-message-log"
settings.EMAIL_BACKEND = 'django.core.mail.backends.locmem.EmailBackend'
settings.HAVE_TORNADO_SERVER = False
def find_key_by_email(address):