update api export for executive and fixing closing cycle flow

This commit is contained in:
Alberto-Audrix committed 2026-09-15 16:53:25 +07:00
1 parent d0d1ae7d24
commit 07d36081ce
23 files changed
+1378 -101

No files matched your search

+13 -8
View File
@@ -190,7 +190,7 @@ class FarmAPITests(TestCase):
self.assertEqual(cycle.status, Cycle.STATUS_PENDING_CLOSE)
def test_apply_close_decision_approve(self):
from django.test import override_settings
from apps.accounts.models import ApiKey
start = date(2026, 8, 1)
end = start + timedelta(days=34)
@@ -204,13 +204,18 @@ class FarmAPITests(TestCase):
status=Cycle.STATUS_PENDING_CLOSE,
proposed_end_date=end,
)
with override_settings(PUSAT_API_KEY="pusat-test-key"):
response = self.client.post(
f"/api/v1/cycles/{cycle.pk}/apply-close-decision/",
{"decision": "approve", "end_date": end.isoformat()},
format="json",
HTTP_X_API_KEY="pusat-test-key",
)
site_key = "site-close-callback-key"
api_key, _ = ApiKey.generate(self.user, "site")
api_key.prefix = site_key[:8]
api_key.key_hash = ApiKey.hash_key(site_key)
api_key.save(update_fields=["prefix", "key_hash", "updated_at"])
response = self.client.post(
f"/api/v1/cycles/{cycle.pk}/apply-close-decision/",
{"decision": "approve", "end_date": end.isoformat()},
format="json",
HTTP_X_API_KEY=site_key,
)
self.assertEqual(response.status_code, 200, response.data)
self.assertEqual(response.data["status"], Cycle.STATUS_CLOSED)
self.assertEqual(response.data["end_date"], end.isoformat())