"""
@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"