comparison gpp/antispam/tests/rate_limit_tests.py @ 508:6f5fff924877

Created a centralized spot to get a Redis connection so that settings can be managed in one place.
author Brian Neal <bgneal@gmail.com>
date Sun, 04 Dec 2011 19:53:27 +0000
parents 7c3816d76c6c
children
comparison
equal deleted inserted replaced
507:8631d32e6b16 508:6f5fff924877
1 """ 1 """
2 Tests for the rate limiting function in the antispam application. 2 Tests for the rate limiting function in the antispam application.
3 3
4 """ 4 """
5 import redis
6 from django.test import TestCase 5 from django.test import TestCase
7 from django.core.urlresolvers import reverse 6 from django.core.urlresolvers import reverse
8 7
9 from antispam.rate_limit import _make_key 8 from antispam.rate_limit import _make_key
9 from core.services import get_redis_connection
10 10
11 11
12 class RateLimitTestCase(TestCase): 12 class RateLimitTestCase(TestCase):
13 KEY = _make_key('127.0.0.1') 13 KEY = _make_key('127.0.0.1')
14 14
15 def setUp(self): 15 def setUp(self):
16 self.conn = redis.Redis(host='localhost', port=6379, db=0) 16 self.conn = get_redis_connection()
17 self.conn.delete(self.KEY) 17 self.conn.delete(self.KEY)
18 18
19 def tearDown(self): 19 def tearDown(self):
20 self.conn.delete(self.KEY) 20 self.conn.delete(self.KEY)
21 21