test-1000.py 4.4 KB

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