import pytest
import requests
@pytest.fixture
def get_weather():
url = “https://jisutqybmf.market.alicloudapi.com/weather/query”
query = {
"city": "上海"
}
header = {
"Authorization": "APPCODE 36a6d64593884af1971d218d14a23f9d"
}
r = requests.get(url=url, params=query, headers=header)
return r.json()
def test_create_topic(get_weather):
result = get_weather[‘result’]
city = result['city']
date = result['date']
week = result['week']
weather = result['weather']
content = f'今天是{date},{week},这里是{city},今天天气{weather}。\n'
index_values = result['index']
for val in index_values:
content += f'{val["iname"]}-{val["ivalue"]}-{val["detail"]}\n'
print(content)
url = 'http://49.233.108.117:3000/api/v1/topics'
json_data