test_publish_slot.py 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import json
  2. import redis
  3. from configure import REDIS_CFG
  4. # 使用的键名(原 Channel 名称)
  5. key = "vs:signal:slot.lon.fr.tourist"
  6. # 消息体
  7. message = {
  8. "group_id": "tls.gb.fr",
  9. "apt_type": {
  10. "weight": 10,
  11. "routing_key": "slot.lon.fr.tourist",
  12. "city": "London",
  13. "visa_type": "Tourist",
  14. "country": "France"
  15. },
  16. "query_result": {
  17. "routing_key": "slot.lon.fr.tourist",
  18. "country": "France",
  19. "city": "London",
  20. "visa_type": "Tourist",
  21. "availability_status": "Available",
  22. "earliest_date": "2026-06-06",
  23. "availability": [
  24. {
  25. "date": "2026-06-06",
  26. "times": [
  27. {
  28. "time": "16:30",
  29. "label": ""
  30. }
  31. ]
  32. }
  33. ],
  34. "snapshot_source": "worker",
  35. "snapshot_at": "2026-05-02T14:23:45.123456+00:00"
  36. },
  37. "timestamp": 1777745853
  38. }
  39. def main():
  40. r = redis.Redis(**REDIS_CFG, decode_responses=True)
  41. r.setex(key, 30, json.dumps(message, ensure_ascii=False))
  42. print(f"写入成功 -> 键: {key}")
  43. print("有效期: 30 秒")
  44. if __name__ == "__main__":
  45. main()