def test_stored_in_redis(self): key = settings.CC_TOP_CONTRIB_CACHE_KEY try: redis = redis_client(name='default') # Other tests are lame and don't clean up after themselves. # This also verifies that Redis is alive and well. redis.delete(key) except RedisError: raise SkipTest get_customercare_stats() blob = redis.get(key) stats = json.loads(blob) eq_(len(stats), 2)
def test_all_range(self): """Test that data looks about right for the 'all' date range.""" stats = get_customercare_stats() # Limited to two results from @override_settings on this class. eq_(len(stats), 2) eq_(stats[0]['twitter_username'], 'moe') eq_(stats[1]['twitter_username'], 'larry') eq_(stats[0]['all'], 25) eq_(stats[0]['1m'], 5) eq_(stats[0]['1w'], 5) eq_(stats[0]['1d'], 3)
def test_week_range(self): """Data looks about right for the 'one week' date range. Test two date ranges to ensure that the code is paying attention to settings.py. """ stats = get_customercare_stats() # Limited to two results from @override_settings on this class. eq_(len(stats), 2) eq_(stats[0]['twitter_username'], 'curly') eq_(stats[1]['twitter_username'], 'moe') eq_(stats[0]['all'], 8) eq_(stats[0]['1m'], 8) eq_(stats[0]['1w'], 6) eq_(stats[0]['1d'], 0)
from django.conf import settings from kitsune.customercare.cron import get_customercare_stats from kitsune.sumo.redis_utils import redis_client, RedisError try: print "Removing old data" redis = redis_client(name='default') redis.delete(settings.CC_TOP_CONTRIB_CACHE_KEY) print "Collecting new data." get_customercare_stats() print "Done" except RedisError: print "This migration needs Redis to be done."