From b6c64f7e02f1226190ef3784de3f5ca53345c4a4 Mon Sep 17 00:00:00 2001 From: Surbhi Date: Mon, 23 Dec 2024 10:33:58 -0500 Subject: [PATCH] debugging tests --- posthog/api/team.py | 3 ++- posthog/api/test/test_team.py | 27 ++++++--------------------- 2 files changed, 8 insertions(+), 22 deletions(-) diff --git a/posthog/api/team.py b/posthog/api/team.py index ad0d4d82edd64..8fc028cc65933 100644 --- a/posthog/api/team.py +++ b/posthog/api/team.py @@ -1,4 +1,6 @@ import json +import posthoganalytics + from datetime import UTC, datetime, timedelta from functools import cached_property from typing import Any, Optional, cast @@ -52,7 +54,6 @@ get_ip_address, get_week_start_for_country_code, ) -import posthoganalytics class PremiumMultiProjectPermissions(BasePermission): # TODO: Rename to include "Env" in name diff --git a/posthog/api/test/test_team.py b/posthog/api/test/test_team.py index 30256b3aee79f..32c35f8f14b78 100644 --- a/posthog/api/test/test_team.py +++ b/posthog/api/test/test_team.py @@ -1228,36 +1228,21 @@ def _patch_linked_flag_config( def test_access_control_toggle_capture(self, mock_capture): self.organization_membership.level = OrganizationMembership.Level.ADMIN self.organization_membership.save() - mock_capture.reset_mock() - response = self.client.patch(f"/api/environments/@current/", {"access_control": True}) - self.assertEqual(response.status_code, status.HTTP_200_OK) - - mock_capture.assert_called_with( - str(self.user.distinct_id), - "project access control toggled", - properties={ - "enabled": True, - "project_id": str(self.team.id), - "project_name": self.team.name, - "organization_id": str(self.organization.id), - "organization_name": self.organization.name, - "user_role": OrganizationMembership.Level.ADMIN, - }, - groups=groups(self.organization), - ) + response = self.client.get("/api/environments/@current/") + assert response.status_code == status.HTTP_200_OK - # Test toggling back to false - mock_capture.reset_mock() - response = self.client.patch(f"/api/environments/@current/", {"access_control": False}) + current_access_control = response.json()["access_control"] + new_setting = not current_access_control + response = self.client.patch(f"/api/environments/@current/", {"access_control": new_setting}) self.assertEqual(response.status_code, status.HTTP_200_OK) mock_capture.assert_called_with( str(self.user.distinct_id), "project access control toggled", properties={ - "enabled": False, + "enabled": new_setting, "project_id": str(self.team.id), "project_name": self.team.name, "organization_id": str(self.organization.id),