From 4eb0bea104ca8c4ec603749d54f6790fd9221211 Mon Sep 17 00:00:00 2001 From: Alexander Spicer Date: Fri, 25 Oct 2024 12:38:22 -0700 Subject: [PATCH] test sort --- posthog/api/test/test_plugin.py | 39 +++++++++++++++++---------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/posthog/api/test/test_plugin.py b/posthog/api/test/test_plugin.py index f92350045a38c..10967d63bb873 100644 --- a/posthog/api/test/test_plugin.py +++ b/posthog/api/test/test_plugin.py @@ -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": "user1@posthog.com"}, - "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": { @@ -412,7 +413,7 @@ def test_delete_plugin_auth(self, mock_get, mock_reload): }, { "user": {"first_name": "", "email": "user1@posthog.com"}, - "activity": "uninstalled", + "activity": "installed", "created_at": "2021-08-25T22:09:14.252000Z", "scope": "Plugin", "item_id": str(plugin_id),