def test__RedongoServer__OK1(self): signal.alarm(10) mongo_client = pymongo.MongoClient('mongodb://{0}:{1}@{2}/{3}'.format(MONGO_USER, MONGO_PASSWORD, MONGO_HOST, MONGO_DB)) mongo_client[MONGO_DB][MONGO_COLLECTION].drop() with redirect_argv('redongo_server.py', '-r', str(REDIS_HOST), '-d', str(REDIS_DB), '-q', str(REDIS_QUEUE), '-L', '0'): redongo_server.main() r = redis.Redis(REDIS_HOST, db=REDIS_DB) assert r.llen(REDIS_QUEUE) == 0 assert r.llen(REDIS_QUEUE_FAILED) == 1 assert mongo_client[MONGO_DB][MONGO_COLLECTION].count() == 9 assert mongo_client[MONGO_DB][MONGO_COLLECTION].find({"test": 5}).count() == 3 search = mongo_client[MONGO_DB][MONGO_COLLECTION].find({"_id": 123454321}) assert search.count() == 1 obj = { '_id': 123454321, 'int_field': 100, 'long_field': 100L, 'float_field': 100.0, # 'complex_field': 100j, 'list_field': ['list_element']*100, 'dict_field': { 'int_field': 100, 'long_field': 100L, 'float_field': 100.0, # 'complex_field': 100j, 'list_field': ['list_element']*100, } }
def handle(self, *args, **options): try: # Instantiate a server with redirect_argv('redongo_server.py', '-r', self.settings['redis_host'], '-d', self.settings['redis_db'], '-q', self.settings['redis_queue'], '-l', '0'): redongo_server.main() except Exception, e: raise CommandError(e)