parastoo-dashboards/parastoo_dashboard/test_sync.py

49 lines
1.6 KiB
Python

import json, urllib.request
BASE = "https://parastoo.zebellkhan.com"
def post(path, payload):
req = urllib.request.Request(BASE + path, data=json.dumps(payload).encode(),
method="POST", headers={"Content-Type": "application/json"})
with urllib.request.urlopen(req, timeout=180) as r:
return json.loads(r.read().decode())
# 1) Write a single test task to the Google Sheet
sheet_payload = {"tasks": [{
"id": "test-1",
"title": "تست اتصال داشبورد پرستو — طراحی کاور ریلز",
"cat": "design",
"date": "2026-09-22",
"est": 1.5,
"act": 2,
"status": "done",
"adhoc": True,
"note": "تست خودکار اتصال شیت — این ردیف قابل حذف است",
"jira": ""
}]}
print("=== SHEET PUSH ===")
try:
r = post("/api/sheet/push", sheet_payload)
print(json.dumps(r, ensure_ascii=False, indent=2)[:700])
except Exception as e:
print("SHEET ERROR:", str(e)[:400])
# 2) Write a single test task to Jira
jira_payload = {"tasks": [{
"id": "test-2",
"title": "تست اتصال داشبورد پرستو — بررسی و حذف",
"cat": "analytics",
"date": "2026-09-22",
"est": 0.5,
"act": 0.5,
"status": "todo",
"adhoc": False,
"note": "تست خودکار اتصال جیرا از داشبورد پرستو",
"jira": ""
}]}
print("\n=== JIRA PUSH ===")
try:
r = post("/api/jira/push", jira_payload)
print(json.dumps(r, ensure_ascii=False, indent=2)[:700])
except Exception as e:
print("JIRA ERROR:", str(e)[:400])