Skip to content

Commit

Permalink
test sort
Browse files Browse the repository at this point in the history
  • Loading branch information
aspicer committed Oct 25, 2024
1 parent defa3d6 commit 4eb0bea
Showing 1 changed file with 20 additions and 19 deletions.
39 changes: 20 additions & 19 deletions posthog/api/test/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,35 +371,36 @@ def test_update_plugin_auth(self, mock_sync_from_plugin_archive, mock_get, mock_
self.assertEqual(response.status_code, 403)
self.assertEqual(mock_sync_from_plugin_archive.call_count, 2) # Not extracted on auth failure

@freeze_time("2021-08-25T22:09:14.252Z")
def test_delete_plugin_auth(self, mock_get, mock_reload):
repo_url = "https://github.com/PostHog/helloworldplugin"
response = self.client.post("/api/organizations/@current/plugins/", {"url": repo_url})
self.assertEqual(response.status_code, 201)
with freeze_time("2021-08-25T22:09:14.252Z"):
repo_url = "https://github.com/PostHog/helloworldplugin"
response = self.client.post("/api/organizations/@current/plugins/", {"url": repo_url})
self.assertEqual(response.status_code, 201)

plugin_id = response.json()["id"]
with freeze_time("2021-08-25T22:09:14.253Z"):
plugin_id = response.json()["id"]

api_url = "/api/organizations/@current/plugins/{}".format(response.json()["id"])
api_url = "/api/organizations/@current/plugins/{}".format(response.json()["id"])

for level in (
Organization.PluginsAccessLevel.NONE,
Organization.PluginsAccessLevel.CONFIG,
):
self.organization.plugins_access_level = level
for level in (
Organization.PluginsAccessLevel.NONE,
Organization.PluginsAccessLevel.CONFIG,
):
self.organization.plugins_access_level = level
self.organization.save()
response = self.client.delete(api_url)
self.assertEqual(response.status_code, 403)

self.organization.plugins_access_level = Organization.PluginsAccessLevel.INSTALL
self.organization.save()
response = self.client.delete(api_url)
self.assertEqual(response.status_code, 403)

self.organization.plugins_access_level = Organization.PluginsAccessLevel.INSTALL
self.organization.save()
response = self.client.delete(api_url)
self.assertEqual(response.status_code, 204)
self.assert_plugin_activity(
[
{
"user": {"first_name": "", "email": "[email protected]"},
"activity": "installed",
"created_at": "2021-08-25T22:09:14.252000Z",
"activity": "uninstalled",
"created_at": "2021-08-25T22:09:14.253000Z",
"scope": "Plugin",
"item_id": str(plugin_id),
"detail": {
Expand All @@ -412,7 +413,7 @@ def test_delete_plugin_auth(self, mock_get, mock_reload):
},
{
"user": {"first_name": "", "email": "[email protected]"},
"activity": "uninstalled",
"activity": "installed",
"created_at": "2021-08-25T22:09:14.252000Z",
"scope": "Plugin",
"item_id": str(plugin_id),
Expand Down

0 comments on commit 4eb0bea

Please sign in to comment.