def verify_pspfc_is_correct(context, push_id): if push_id.upper() == "PUSH_ID": push_id = PUSH_ID request_tasks = [{"file_id": task["file_id"], "operation": "delete", "priority": task["priority"]} for task in context.delete_tasks if task["push_id"] == push_id] redis_value = redis_single_get_zset("PSPFC_{0}".format(push_id)) actual_tasks = [json.loads(task) for task in redis_value] print "task in redis:", actual_tasks print "task should be:", request_tasks assert_that(actual_tasks.sort(), equal_to(request_tasks.sort()), "value in PSPFC may be incorrect")
def send_preprocessing_tasks(context): # record PSPFC status before sent request so that we can verify if push-hub do anything to PSPFC context.redis_key = "PSPFC_{0}".format( context.preprocessing_tasks.get("id", None)) context.redis_value_before_request = redis_single_get_zset( context.redis_key) print context.redis_key, "before request:", context.redis_value_before_request uri = "/preprocessing_tasks?{0}"\ .format("&".join(["{0}={1}".format(k, v) for k, v in context.preprocessing_tasks.items()])) context.response = send_http_request(GET, PUSH_HUB_HOST, PUSH_HUB_PORT, uri, HEADERS, None, {})
def verify_pspfc_is_correct(context, push_id): if push_id.upper() == "PUSH_ID": push_id = PUSH_ID request_tasks = [] for task in context.download_tasks: if task.get("push_id", None) == push_id: task.pop("push_ip", None) task.pop("push_id", None) task["operation"] = "download" request_tasks.append(task) redis_value = redis_single_get_zset("PSPFC_{0}".format(push_id)) actual_tasks = [json.loads(task) for task in redis_value] print "task in redis:", actual_tasks print "task should be:", request_tasks assert_that(actual_tasks.sort(), equal_to(request_tasks.sort()), "value in PSPFC may be incorrect")
def verify_pspfc_is_empty(context, push_id): redis_value = redis_single_get_zset(get_pspfc_key(push_id)) assert_that(len(redis_value), equal_to(0))
def verify_pspfc_in_redis(context, task_count, push_id): redis_value = redis_single_get_zset(get_pspfc_key(push_id)) print "task_count in redis:", len(redis_value), "task in redis:", redis_value assert_that(len(redis_value), equal_to(int(task_count)))
def verify_pspfc_has_no_change(context): redis_value_after_request = redis_single_get_zset(context.redis_key) assert_that(redis_value_after_request, equal_to(context.redis_value_before_request))