mirror of https://github.com/zulip/zulip.git
realm_export: Return export id from POST which create it.
This commit is contained in:
parent
7811e99548
commit
3160c3cce0
|
@ -20,6 +20,11 @@ format used by the Zulip server that they are interacting with.
|
||||||
|
|
||||||
## Changes in Zulip 7.0
|
## Changes in Zulip 7.0
|
||||||
|
|
||||||
|
**Feature level 182**
|
||||||
|
|
||||||
|
* `POST /export/realm`: This endpoint now returns the ID of the data
|
||||||
|
export object created by the request.
|
||||||
|
|
||||||
**Feature level 181**
|
**Feature level 181**
|
||||||
|
|
||||||
* [`GET /scheduled_messages`](/api/get-scheduled-messages), [`GET
|
* [`GET /scheduled_messages`](/api/get-scheduled-messages), [`GET
|
||||||
|
|
|
@ -33,7 +33,7 @@ DESKTOP_WARNING_VERSION = "5.4.3"
|
||||||
# Changes should be accompanied by documentation explaining what the
|
# Changes should be accompanied by documentation explaining what the
|
||||||
# new level means in api_docs/changelog.md, as well as "**Changes**"
|
# new level means in api_docs/changelog.md, as well as "**Changes**"
|
||||||
# entries in the endpoint's documentation in `zulip.yaml`.
|
# entries in the endpoint's documentation in `zulip.yaml`.
|
||||||
API_FEATURE_LEVEL = 181
|
API_FEATURE_LEVEL = 182
|
||||||
|
|
||||||
# Bump the minor PROVISION_VERSION to indicate that folks should provision
|
# Bump the minor PROVISION_VERSION to indicate that folks should provision
|
||||||
# only when going from an old version of the code to a newer version. Bump
|
# only when going from an old version of the code to a newer version. Bump
|
||||||
|
|
|
@ -159,7 +159,7 @@ class RealmExportTest(ZulipTestCase):
|
||||||
result = self.client_post("/json/export/realm")
|
result = self.client_post("/json/export/realm")
|
||||||
self.assertTrue("INFO:root:Completed data export for zulip in " in info_logs.output[0])
|
self.assertTrue("INFO:root:Completed data export for zulip in " in info_logs.output[0])
|
||||||
mock_export.assert_called_once()
|
mock_export.assert_called_once()
|
||||||
self.assert_json_success(result)
|
data = self.assert_json_success(result)
|
||||||
self.assertFalse(os.path.exists(tarball_path))
|
self.assertFalse(os.path.exists(tarball_path))
|
||||||
|
|
||||||
# Get the entry and test that iago initiated it.
|
# Get the entry and test that iago initiated it.
|
||||||
|
@ -167,6 +167,7 @@ class RealmExportTest(ZulipTestCase):
|
||||||
event_type=RealmAuditLog.REALM_EXPORTED
|
event_type=RealmAuditLog.REALM_EXPORTED
|
||||||
).first()
|
).first()
|
||||||
assert audit_log_entry is not None
|
assert audit_log_entry is not None
|
||||||
|
self.assertEqual(audit_log_entry.id, data["id"])
|
||||||
self.assertEqual(audit_log_entry.acting_user_id, admin.id)
|
self.assertEqual(audit_log_entry.acting_user_id, admin.id)
|
||||||
|
|
||||||
# Test that the file is hosted, and the contents are as expected.
|
# Test that the file is hosted, and the contents are as expected.
|
||||||
|
@ -226,14 +227,15 @@ class RealmExportTest(ZulipTestCase):
|
||||||
)
|
)
|
||||||
mock_export.assert_called_once()
|
mock_export.assert_called_once()
|
||||||
# This is a success because the failure is swallowed in the queue worker
|
# This is a success because the failure is swallowed in the queue worker
|
||||||
self.assert_json_success(result)
|
data = self.assert_json_success(result)
|
||||||
|
export_id = data["id"]
|
||||||
|
|
||||||
# Check that the export shows up as failed
|
# Check that the export shows up as failed
|
||||||
result = self.client_get("/json/export/realm")
|
result = self.client_get("/json/export/realm")
|
||||||
response_dict = self.assert_json_success(result)
|
response_dict = self.assert_json_success(result)
|
||||||
export_dict = response_dict["exports"]
|
export_dict = response_dict["exports"]
|
||||||
self.assert_length(export_dict, 1)
|
self.assert_length(export_dict, 1)
|
||||||
export_id = export_dict[0]["id"]
|
self.assertEqual(export_dict[0]["id"], export_id)
|
||||||
self.assertEqual(export_dict[0]["pending"], False)
|
self.assertEqual(export_dict[0]["pending"], False)
|
||||||
self.assertIsNone(export_dict[0]["export_url"])
|
self.assertIsNone(export_dict[0]["export_url"])
|
||||||
self.assertIsNone(export_dict[0]["deleted_timestamp"])
|
self.assertIsNone(export_dict[0]["deleted_timestamp"])
|
||||||
|
|
|
@ -85,7 +85,7 @@ def export_realm(request: HttpRequest, user: UserProfile) -> HttpResponse:
|
||||||
"id": row.id,
|
"id": row.id,
|
||||||
}
|
}
|
||||||
transaction.on_commit(lambda: queue_json_publish("deferred_work", event))
|
transaction.on_commit(lambda: queue_json_publish("deferred_work", event))
|
||||||
return json_success(request)
|
return json_success(request, data={"id": row.id})
|
||||||
|
|
||||||
|
|
||||||
@require_realm_admin
|
@require_realm_admin
|
||||||
|
|
Loading…
Reference in New Issue