test-2000.py 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. import requests
  2. # --- test 获取token ---
  3. # url = 'http://10.10.61.229:9000/token/api'
  4. url = 'http://192.168.131.23:9000/token/api'
  5. data = {
  6. 'username': 'admin', # 用户名
  7. 'password': 'admin', # 密码
  8. }
  9. response = requests.post(url=url, json=data)
  10. code = response.json().get('code')
  11. token = response.headers.get('authorization')
  12. # --- test 2001 获取全部渣包车状态 ---
  13. url = 'http://192.168.131.23:9000/v5/api'
  14. data = {
  15. 'code': 2001, # 接口号
  16. }
  17. response = requests.post(url=url, json=data, headers={'authorization': token})
  18. print(response.json())
  19. """
  20. {
  21. 'code': 0,
  22. 'data': [
  23. {
  24. 'name': '3号车', # 车辆名称
  25. 'address': '192.168.131.180', # 车辆ip
  26. 'check_vehicle_direction': True, # 当前车头方向是否符合自动驾驶条件 True 符合 False 不符合(默认值)
  27. 'state': 2, # 车辆状态 1 离线(默认值) 2 在线空闲 3 人工驾驶中 4 远程驾驶中 5 自动驾驶中
  28. 'current_vehicle_direction': 9, # 当前车头方向类型 3 围栏方向 9 渣场方向 12 维修间方向 6 维修间正对方向 0 未知(默认值)
  29. 'current_vehicle_weight': 0, # 当前车辆负载重量
  30. 'uuid': '65faa9d5921aec72550fb32d' # 车辆标识
  31. },
  32. {
  33. 'name': '5号车',
  34. 'address': '192.168.131.xxx',
  35. 'check_vehicle_direction': False,
  36. 'current_vehicle_direction': 0,
  37. 'state': 1,
  38. 'current_vehicle_weight': 0,
  39. 'uuid': '65faa9d5921aec72550fb32e'
  40. }
  41. ]
  42. }
  43. """
  44. # --- test 2002 指定渣包车点火操作接口 ---
  45. # url = 'http://10.10.61.229:9000/v5/api'
  46. # data = {
  47. # 'code': 2002, # 接口号
  48. # 'uuid': 'aassfafe', # 渣包车唯一标识
  49. # }
  50. # response = requests.post(url=url, json=data, headers={'authorization': token})
  51. # print(response.json())
  52. # """
  53. # {
  54. # 'code': 0,
  55. # 'data': 'aassfafe'
  56. # }
  57. # """
  58. # --- test 2003 指定渣包车熄火操作接口 ---
  59. # url = 'http://10.10.61.229:9000/v5/api'
  60. # data = {
  61. # 'code': 2003, # 接口号
  62. # 'uuid': 'aassfafe', # 渣包车唯一标识
  63. # }
  64. # response = requests.post(url=url, json=data, headers={'authorization': token})
  65. # print(response.json())
  66. # """
  67. # {
  68. # 'code': 0,
  69. # 'data': 'aassfafe'
  70. # }
  71. # """
  72. # --- test 2004 指定渣包车建立远程操作权限(或是切换)接口 ---
  73. # url = 'http://10.10.61.229:9000/v5/api'
  74. # data = {
  75. # 'code': 2004, # 接口号
  76. # 'uuid': 'aassfafe', # 渣包车唯一标识
  77. # }
  78. # response = requests.post(url=url, json=data, headers={'authorization': token})
  79. # print(response.json())
  80. # """
  81. # {
  82. # 'code': 0,
  83. # 'data': 'aassfafe'
  84. # }
  85. # """
  86. # --- test 2101 新增渣包车接口 ---
  87. # url = 'http://10.10.61.229:9000/v5/api'
  88. # data = {
  89. # 'code': 2101, # 接口号
  90. # 'name': '3号车', # 车辆名称
  91. # 'address': '192.168.131.41', # 网络地址
  92. # }
  93. # response = requests.post(url=url, json=data, headers={'authorization': token})
  94. # print(response.json())
  95. # """
  96. # {
  97. # 'code': 0,
  98. # 'data': 'aassfafe'
  99. # }
  100. # """
  101. # --- test 2102 修改渣包车接口 ---
  102. # url = 'http://10.10.61.229:9000/v5/api'
  103. # data = {
  104. # 'code': 2102, # 接口号
  105. # 'uuid': '659765411dd2f1fe6d346b3b', # 渣包车唯一标识
  106. # 'name': '3号车', # 车辆名称
  107. # 'address': '192.168.131.41', # 网络地址
  108. # }
  109. # response = requests.post(url=url, json=data, headers={'authorization': token})
  110. # print(response.json())
  111. # """
  112. # {
  113. # 'code': 0,
  114. # 'data': {
  115. # 'uuid': '659765411dd2f1fe6d346b3b',
  116. # 'name': '6号车',
  117. # 'update_at': 1704435941
  118. # }
  119. # }
  120. # """
  121. # --- test 2103 删除渣包车接口 ---
  122. # url = 'http://10.10.61.229:9000/v5/api'
  123. # data = {
  124. # 'code': 2103, # 接口号
  125. # 'uuid': '659764dd6b8e37c3ce95d849', # 渣包车唯一标识
  126. # }
  127. # response = requests.post(url=url, json=data, headers={'authorization': token})
  128. # print(response.json())