Files
chat/tests/setup_mobile_test.py
Andrew K. Choi 537e7b363f
All checks were successful
continuous-integration/drone/push Build is passing
main commit
2025-10-16 16:30:25 +09:00

47 lines
2.4 KiB
Python
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env python
import json
import requests
import sys
import traceback
from datetime import date
# Запрашиваем токен авторизации (предполагается, что он уже есть в системе)
TOKEN = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIyOSIsImVtYWlsIjoidGVzdDJAZXhhbXBsZS5jb20iLCJleHAiOjE3NTg4NjY5ODJ9._AXkBLeMI4zxC9shFUS3744miuyO8CDnJD1X1AqbLsw"
# Данные для мобильного запроса
mobile_data = {
"date": date.today().isoformat(),
"type": "MENSTRUATION",
"flow_intensity": 3,
"symptoms": ["CRAMPS", "HEADACHE"],
"mood": "NORMAL",
"notes": "Запись из мобильного приложения"
}
# Заголовки с токеном авторизации
headers = {
"Content-Type": "application/json",
"Authorization": f"Bearer {TOKEN}"
}
# Сохраняем токен в файл для повторного использования
with open('auth_token.txt', 'w') as f:
f.write(TOKEN)
print(f"Токен сохранен в файл auth_token.txt")
print(f"Данные для запроса к мобильному API сохранены в переменной mobile_data")
print("\nПример использования:")
print('curl -v -X POST http://localhost:8004/api/v1/calendar/entries/mobile -H "Content-Type: application/json" -H "Authorization: Bearer $(cat auth_token.txt)" -d \'{"date": "2025-09-26", "type": "MENSTRUATION", "flow_intensity": 3, "symptoms": ["CRAMPS", "HEADACHE"], "mood": "NORMAL", "notes": "Тестовая запись"}\'')
# Сохраняем пример запроса в файл для удобства
with open('mobile_api_example.sh', 'w') as f:
f.write('#!/bin/bash\n\n')
f.write('# Пример запроса к мобильному API календарного сервиса\n')
f.write('curl -v -X POST http://localhost:8004/api/v1/calendar/entries/mobile \\\n')
f.write(' -H "Content-Type: application/json" \\\n')
f.write(' -H "Authorization: Bearer $(cat auth_token.txt)" \\\n')
f.write(' -d \'{"date": "2025-09-26", "type": "MENSTRUATION", "flow_intensity": 3, "symptoms": ["CRAMPS", "HEADACHE"], "mood": "NORMAL", "notes": "Тестовая запись"}\'\n')
print("\nПример запроса также сохранен в файле mobile_api_example.sh")
print("Можно выполнить: chmod +x mobile_api_example.sh && ./mobile_api_example.sh")