test-5000.py 792 B

1234567891011121314151617181920212223242526272829303132
  1. import requests
  2. # --- test 获取token ---
  3. url = 'http://10.10.61.229:9000/token/api'
  4. data = {
  5. 'username': 'admin', # 用户名
  6. 'password': 'admin', # 密码
  7. }
  8. response = requests.post(url=url, json=data)
  9. code = response.json().get('code')
  10. token = response.headers.get('authorization')
  11. # print(code, token)
  12. # --- test 5001 获取告警数据列表接口 ---
  13. # --- test 5001 获取告警数据列表接口 ---
  14. url = 'http://10.10.61.229:9000/v5/api'
  15. data = {
  16. 'code': 5001, # 接口号
  17. }
  18. response = requests.post(url=url, json=data, headers={'authorization': token})
  19. print(response.json())
  20. """
  21. {
  22. 'code': 0,
  23. 'data': [
  24. {
  25. 'message': '1号车油量低,请及时加油!', # 警告内容
  26. 'create_at': 1704435199 # 警告时间(时间戳)
  27. }
  28. ]
  29. }
  30. """