test-1000.py 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. import requests
  2. # --- test 获取token ---
  3. url = 'http://58.34.94.177:29101/v1/token'
  4. data = {
  5. 'username': 'admin', # 登录账户
  6. 'password': '123456', # 登录密码
  7. }
  8. response = requests.post(url=url, json=data)
  9. code = response.json().get('code')
  10. token = response.headers.get('authorization')
  11. # print(response.json())
  12. # """
  13. # {
  14. # 'code': 0,
  15. # 'message': 'authorization passed.',
  16. # 'data': {
  17. # 'uid': '65dc4187e6e1bf491a4aad1f',
  18. # 'username': 'admin',
  19. # 'role': '超级管理员',
  20. # 'role_type': 1,
  21. # 'token': 'xxxxxxxx'
  22. # }
  23. # }
  24. # """
  25. # --- test 1001 新增用户 ---
  26. # url = 'http://58.34.94.177:29101/v6/api'
  27. # data = {
  28. # 'code': 1001, # 接口号
  29. # 'username': 'aabbcc', # 登录账户(必须项)
  30. # 'password': 'aabbcc', # 登录密码(可选项)(默认值:baosteel@2024)
  31. # 'role_type': 1, # 角色类型(可选项)(1: 超级管理员 2: 普通管理员 3: 普通用户)
  32. # 'name': 'aabbcc', # 姓名(可选项)
  33. # 'cid': '112233', # 身份证号(可选项)
  34. # 'phone': '112233', # 手机号(可选项)
  35. # 'sex': 0, # 性别(可选项)(0:未设置 1:男 2:女)
  36. # 'department': 'aabbcc', # 部门(可选项)
  37. # 'wid': 'aabbcc', # 工号(可选项)
  38. # }
  39. # response = requests.post(url=url, json=data, headers={'authorization': token})
  40. # print(response.json())
  41. # --- test 1002 查询用户列表 ---
  42. url = 'http://58.34.94.177:29101/v6/api'
  43. data = {
  44. 'code': 1002, # 接口号
  45. 'page': 1, # 页码
  46. 'size': 3, # 每页条数
  47. 'name': 'a', # 模糊姓名(可选项)
  48. 'phone': '', # 手机号(可选项)
  49. 'role_type': ['2'], # 角色类型(可选项) 1 超级管理员 2 普通管理员 3 普通用户(默认值)
  50. }
  51. response = requests.post(url=url, json=data, headers={'authorization': token})
  52. print(response.json())
  53. """
  54. {
  55. 'code': 0,
  56. 'data': [
  57. {
  58. 'uuid': '65dbeb1c49fbe311a3a01d34',
  59. 'name': 'aabbcc',
  60. 'cid': '112233',
  61. 'phone': '112233',
  62. 'sex': 0, # 性别 (0:未设置 1:男 2:女)
  63. 'department': 'aabbcc',
  64. 'wid': 'aabbcc',
  65. 'state': 0, # 禁用状态 (0:激活 1:禁用)
  66. 'allow_at': 1708911388 # 注册审批时间时间戳
  67. }
  68. ]
  69. }
  70. """
  71. # --- test 1003 删除指定用户 ---
  72. # url = 'http://58.34.94.177:29101/v6/api'
  73. # data = {
  74. # 'code': 1003, # 接口号
  75. # 'uuid': '65db84b35e305885648ec062', # 用户id(必须项)
  76. # }
  77. # response = requests.post(url=url, json=data, headers={'authorization': token})
  78. # print(response.json())
  79. # --- test 1004 禁用指定用户 ---
  80. # url = 'http://58.34.94.177:29101/v6/api'
  81. # data = {
  82. # 'code': 1004, # 接口号
  83. # 'uuid': '65decb7744b74ae33732d813', # 用户id(必须项)
  84. # }
  85. # response = requests.post(url=url, json=data, headers={'authorization': token})
  86. # print(response.json())
  87. # --- test 1005 启用指定用户 ---
  88. # url = 'http://58.34.94.177:29101/v6/api'
  89. # data = {
  90. # 'code': 1005, # 接口号
  91. # 'uuid': '65decb7744b74ae33732d813', # 用户id(必须项)
  92. # }
  93. # response = requests.post(url=url, json=data, headers={'authorization': token})
  94. # print(response.json())
  95. # --- test 1006 获取指定用户详情 ---
  96. # url = 'http://58.34.94.177:29101/v6/api'
  97. # data = {
  98. # 'code': 1006, # 接口号
  99. # 'uuid': '65dd775c44b74ae33732d7f7', # 用户id(必须项)
  100. # }
  101. # response = requests.post(url=url, json=data, headers={'authorization': token})
  102. # print(response.json())
  103. # --- test 1007 修改指定用户信息 ---
  104. # url = 'http://58.34.94.177:29101/v6/api'
  105. # data = {
  106. # 'code': 1007, # 接口号
  107. # 'uuid': '65dd775c44b74ae33732d7f7', # 用户id(必须项)
  108. # # 'username': 'aabbcc', # 登录账户(必须项)
  109. # # 'password': 'aabbcc', # 登录密码(可选项)(默认值:baosteel@2024)
  110. # # 'role_type': 3, # 角色类型(可选项)(1: 超级管理员 2: 普通管理员 3: 普通用户)
  111. # 'name': 'aabbcc', # 姓名(可选项)
  112. # # 'cid': '112233', # 身份证号(可选项)
  113. # # 'phone': '112233', # 手机号(可选项)
  114. # # 'sex': 0, # 性别(可选项)(0:未设置 1:男 2:女)
  115. # # 'department': 'aabbcc', # 部门(可选项)
  116. # # 'wid': 'aabbcc', # 工号(可选项)
  117. # }
  118. # response = requests.post(url=url, json=data, headers={'authorization': token})
  119. # print(response.json())