refactor: split bulk-sync into backend/routers/sync.py

This commit is contained in:
2026-04-19 12:37:09 +03:00
parent 90e9a60640
commit 6dc300d339
5 changed files with 86 additions and 74 deletions

View File

@@ -19,7 +19,7 @@ class TestOfflineSync:
user = test_db.query(User).filter(User.username == "user").first()
operation_uuid = str(uuid4())
response = test_client.post(
"/operations/bulk-sync",
"/sync/bulk-sync",
json={
"user_id": user.id,
"operations": [
@@ -65,7 +65,7 @@ class TestOfflineSync:
# First sync
response1 = test_client.post(
"/operations/bulk-sync", json=payload,
"/sync/bulk-sync", json=payload,
headers={"Authorization": f"Bearer {user_token}"}
)
assert response1.status_code == status.HTTP_200_OK
@@ -73,7 +73,7 @@ class TestOfflineSync:
# Second sync (same UUID) — returns "Already synced" note
response2 = test_client.post(
"/operations/bulk-sync", json=payload,
"/sync/bulk-sync", json=payload,
headers={"Authorization": f"Bearer {user_token}"}
)
assert response2.status_code == status.HTTP_200_OK
@@ -90,7 +90,7 @@ class TestOfflineSync:
user = test_db.query(User).filter(User.username == "user").first()
response = test_client.post(
"/operations/bulk-sync",
"/sync/bulk-sync",
json={
"user_id": user.id,
"operations": [

View File

@@ -103,7 +103,7 @@ class TestBulkSync:
user = test_db.query(User).filter(User.username == "user").first()
response = test_client.post(
"/operations/bulk-sync",
"/sync/bulk-sync",
json={
"user_id": user.id,
"operations": [
@@ -141,7 +141,7 @@ class TestBulkSync:
# Sync once
response1 = test_client.post(
"/operations/bulk-sync", json=operation,
"/sync/bulk-sync", json=operation,
headers={"Authorization": f"Bearer {user_token}"}
)
assert response1.status_code == status.HTTP_200_OK
@@ -149,7 +149,7 @@ class TestBulkSync:
# Sync again with same UUID — should be idempotent (returns "Already synced")
response2 = test_client.post(
"/operations/bulk-sync", json=operation,
"/sync/bulk-sync", json=operation,
headers={"Authorization": f"Bearer {user_token}"}
)
assert response2.status_code == status.HTTP_200_OK