• Day06作业(postman接口测试)


    Day06作业

    作业

    1. 在自己电脑上安装搭建项目,并完成上面的快速体验开发接口的代码测试。
    

    Postman接口测试

    使用postman接口测试

    1. GET请求测试

      GET  http://127.0.0.1:8000/students/
      

      返回数据

      {
          "stu": "http://127.0.0.1:8000/students/stu/"
      }
      

      获取所有的数据接口

      GET http://127.0.0.1:8000/students/stu/
      

      返回数据

      [
          {
              "id": 1,
              "name": "surpass",
              "sex": true,
              "age": 18,
              "class_num": "301",
              "description": "爱彩菇凉的小蘑菇"
          },
          {
              "id": 2,
              "name": "surpass",
              "sex": true,
              "age": 18,
              "class_num": "301",
              "description": "爱彩菇凉的小蘑菇"
          },
          {
              "id": 3,
              "name": "surpass",
              "sex": true,
              "age": 18,
              "class_num": "301",
              "description": "爱彩菇凉的小蘑菇"
          }
      ]
      
    2. POST请求测试(增加一条记录)

      POST  http://127.0.0.1:8000/students/stu/
      

      body JSON(application/json)

      {
        "name": "djy",
        "sex": false,
        "age": 18,
        "class_num": "303",
        "description": "爱彩菇凉的小蘑菇"
      }
      

      返回数据

      {
          "id": 5,
          "name": "djy",
          "sex": false,
          "age": 18,
          "class_num": "303",
          "description": "爱彩菇凉的小蘑菇"
      }
      

      查询id为 5的学生数据

      GET  http://127.0.0.1:8000/students/stu/5/
      

      返回数据

      {
          "id": 5,
          "name": "djy",
          "sex": false,
          "age": 18,
          "class_num": "303",
          "description": "爱彩菇凉的小蘑菇"
      }
      
    3. PUT 请求测试

      update一条数据

      PUT http://127.0.0.1:8000/students/stu/5/
      

      要修改的数据 body JSON(application/json)

      {
          "name": "djy_xfc",
          "sex": false,
          "age": 16,
          "class_num": "303",
          "description": "笑口常开"
      }
      

      返回数据

      {
          "id": 5,
          "name": "djy_xfc",
          "sex": false,
          "age": 16,
          "class_num": "303",
          "description": "笑口常开"
      }
      

      查询更新后的数据

      GET  http://127.0.0.1:8000/students/stu/5/
      

      返回数据

      {
          "id": 5,
          "name": "djy_xfc",
          "sex": false,
          "age": 16,
          "class_num": "303",
          "description": "笑口常开"
      }
      
    4. DELETE 请求测试

      删除一条数据

      DELETE  http://127.0.0.1:8000/students/stu/5/
      

      查询删除后数据

      GET  http://127.0.0.1:8000/students/stu/5/
      

      返回数据

      {
          "detail": "Not found."
      }
      
  • 相关阅读:
    Ubuntu12.04 下安装QQ
    python下sqlite增删查改方法(转)
    你有哪些想要分享的 PyCharm 使用技巧?
    PEP 8
    macos 下安装virtualenv,virtualenvwrapper,然后在pycharm中正常配置方法日志
    最全Python爬虫总结(转载)
    Git 常用命令详解
    Python 扩展技术总结(转)
    使用setup.py安装python包和卸载python包的方法
    IPython3 notebook 成功配置Python2和Python3内核(Kernel)
  • 原文地址:https://www.cnblogs.com/surpass123/p/13184831.html
Copyright © 2020-2023  润新知