首页 > 其他分享 >test_django_service_post

test_django_service_post

时间:2024-04-30 18:24:33浏览次数:21  
标签:service resp json test post data app

"""
@Name: test_django_service_01.py
@Author: zengchuanyin
@Date 2024/2/25-10:56
"""

import pytest
import logging
import json

from config import get_env_msg
from service.console.djangoservice_post_console import DjangoServicePost
from service_base import ServiceBase

logging.basicConfig(level=logging.INFO)


def test_django_service_post():
data = get_env_msg()
url = f"http://{data['host']['ip']}:{data['host']['port']}"
post_data = {'aaa': 'qwe'}
header = {
'Content-Type': 'application/json'
}

app_service = ServiceBase(host=url, vpath='/service/')

resp = app_service._post(url=app_service.host + app_service.vpath, json=json.dumps(post_data), headers=header)

# 将原生http响应转为str
resp = resp.json()

# 将str转为python处理的dict
resp = json.loads(resp)

print(type(resp))

assert resp["aaa"] == "qwe1"

标签:service,resp,json,test,post,data,app
From: https://www.cnblogs.com/yinzone/p/18168536

相关文章

  • 2020-2021 ICPC NERC (NEERC), North-Western Russia Regional Contest (Northern Sub
    E-EasyCompare-and-Set题意给定n个条件,如果存在一个合法序列使得这n个判断条件成立,则输出Yes和这个合法序列,否则输出No。分析首先可以发现对于\(w_i=0\)的操作我们可以在处理完\(w_i=1\)的操作之后讨论一下即可。发现\(a_i\)和\(b_i\)很大需要对其进行离散化操作。离......
  • PostgreSQL 简单使用
    切换到postgres用户:默认情况下,以postgres用户身份登录可以获得数据库的完全访问权限:sudosu-postgres登录到PostgreSQL:psql系统会提示您输入之前设置的postgres用户的密码。登录后,您可以创建新的数据库和用户,或者执行其他数据库操作。例如,创建一个名为mydatabas......
  • k8s的Service详解
    一、Service基本了解Service存在的意义?引入Service主要是解决Pod的动态变化,通过创建Service,可以为一组具有相同功能的容器应用提供一个统一的入口地址,并且将请求负载分发到后端的各个容器应用上。若提供服务的容器应用是分布式,所以存在多个pod副本,而Pod副本......
  • Get、Post区别
    参考:https://www.cnblogs.com/coderwcb/p/16090602.html区别语义不同,GET是获取数据,POST是提交数据。GET请求会把附加参数带在URL上,而POST请求会把提交数据放在报文内。post更安全(不会作为url的一部分,不会被缓存、保存在服务器日志、以及浏览器浏览记录中)post发送的数据更大(g......
  • pytest 学习 - 00 环境安装配置
    前言pytest是一个非常好用且成熟的全功能Python测试框架,个人觉得比传统的Unitest好多用了,现在面试如果写只会Unitest会被鄙视的。主要有以下特点:1.简单灵活,容易上手,参数化灵活。2.测试用例支持很多机制像skip、xfail、自动失败重试等处理。3.能够......
  • [postgres]序列
    前言序列都是用createsequence命令创建的单行表,常用于为表的行生成唯一的标识符。相关函数函数作用nextval()递增序列并返回新值currval()返回最近一次用nextval()函数获取的指定序列的值lastval()返回最近一次用nextval()函数获取的任何序列的值setval(......
  • Mysql启动报错:Job for mysqld.service failed because the control process exited wi
      该方法会删除mysql数据,慎用centos7上使用yum安装mysql后,启动报错[root@localhost~]#systemctlstartmysqldJobformysqld.servicefailedbecausethecontrolprocessexitedwitherrorcode.See"systemctlstatusmysqld.service"and"journalctl-xe"for......
  • nginx cache test.md
    NginxCache简要配置#使用CentOS7作为基础镜像FROMcentos:7#安装依赖RUNyum-yupdate&&\yum-yinstallepel-release&&\yum-yinstallgccgcc-c++makezlib-develpcre-developenssl-devel#下载Nginx和ngx_cache_purge模块RUNcurl-O......
  • [FBCTF2019]RCEService
    [FBCTF2019]RCEService打开环境,提示输入JSON格式输入{"cmd":"ls"},只有一个index,php,而且不能读取到这卡住了,找了师傅们的WP发现源码<?phpputenv('PATH=/home/rceservice/jail');if(isset($_REQUEST['cmd'])){$json=$_REQUEST['cmd'];......
  • PostCss
    PostCss类似于一个编译器,可以将样式源码编译成最终的CSS代码PostCss和LESS、SASS的思路不同,它其实只做一些代码分析之类的事情,将分析的结果交给插件,具体的代码转换操作是插件去完成的。官方的一张图更能说明postcss的处理流程:这一点有点像webpack,webpack本身仅做依赖分析、......