test-3000.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import requests
  2. # --- test 获取token ---
  3. # url = 'http://58.34.94.177:29101/v1/token'
  4. url = 'http://127.0.0.1:9000/v1/token'
  5. data = {
  6. 'username': 'admin', # 用户名
  7. 'password': '123456', # 密码
  8. }
  9. response = requests.post(url=url, json=data)
  10. code = response.json().get('code')
  11. token = response.headers.get('authorization')
  12. # print(code, token)
  13. # --- test 3001 查询驾驶人员操作记录列表 ---
  14. url = 'http://58.34.94.177:29101/v6/api'
  15. data = {
  16. 'code': 3001, # 接口号
  17. 'page': 1, # 页码
  18. 'size': 3, # 每页条数
  19. 'pid': 'AA', # 模糊查询,车牌号(可选项)
  20. 'driver_name': 'AABBXX', # 模糊查询,驾驶员(可选项)
  21. }
  22. response = requests.post(url=url, json=data, headers={'authorization': token})
  23. print(response.json())
  24. """
  25. {
  26. 'code': 0,
  27. 'data': [
  28. {
  29. 'uuid': '65dbe96949fbe311a3a01d30',
  30. 'pid': 'AA112233',
  31. 'start_time_at': 1708917227,
  32. 'end_time_at': 1708946027,
  33. 'driver_name': '张三',
  34. 'cockpit_name': '1号舱'
  35. }
  36. ],
  37. 'total': 1,
  38. 'page': 1,
  39. 'size': 3
  40. }
  41. """
  42. # --- test 3002 下载指定驾驶人员操作日志 ---
  43. url = 'http://58.34.94.177:29101/v6/api'
  44. params = {'code': 3002}
  45. response = requests.get(url=url, params=params, headers={'authorization': token})
  46. print(response.text)
  47. requests.get(url='http://58.34.94.177:29101/v6/api?code=3002').text