Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): Upgrade to Django 5 #23626

Merged
merged 25 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
13b8e6f
Upgrade to Django 5
webjunkie Jul 11, 2024
f493130
Update django-two-factor-auth
webjunkie Jul 11, 2024
9b999b9
Merge branch 'master' into chore/Django-5
webjunkie Jul 15, 2024
6e0ff3a
Use django-upgrade
webjunkie Jul 15, 2024
c65c188
Fix timezone issues
webjunkie Jul 15, 2024
a1ae4d8
Fix test issues
webjunkie Jul 15, 2024
90d9811
Fix types
webjunkie Jul 15, 2024
3c5354b
Fix logout (?)
webjunkie Jul 15, 2024
9ed5e70
Fix timezone issues
webjunkie Jul 15, 2024
bc5141e
Merge branch 'master' into chore/Django-5
webjunkie Aug 22, 2024
9d77fc0
Fix test
webjunkie Aug 22, 2024
503cd68
Fix GET logout deprecation
webjunkie Aug 22, 2024
fcd4ab8
Update UI snapshots for `chromium` (1)
github-actions[bot] Aug 22, 2024
58a36bd
Update UI snapshots for `chromium` (2)
github-actions[bot] Aug 22, 2024
fa036ab
Make tests use logout button
webjunkie Aug 26, 2024
95f66d4
Merge branch 'master' into chore/Django-5
webjunkie Aug 27, 2024
d8caec0
Fix missing pk error
webjunkie Aug 27, 2024
87bf0e5
Fix cypress logout problems
webjunkie Aug 27, 2024
18eed12
Fix invites.cy tests
webjunkie Aug 27, 2024
526975a
Merge branch 'master' into chore/Django-5
webjunkie Aug 28, 2024
f23e152
Use POST to fix /logout in test, remove need to return
webjunkie Aug 28, 2024
d711fa2
Move login
webjunkie Aug 28, 2024
9a87196
Merge branch 'master' into chore/Django-5
webjunkie Aug 29, 2024
6ddc2d8
Update webdriver manager
webjunkie Aug 29, 2024
f4fa0e9
Update UI snapshots for `chromium` (2)
github-actions[bot] Aug 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions ee/api/test/test_action.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import datetime
from typing import cast

import pytest
from django.utils import timezone
from rest_framework import status

from posthog.cloud_utils import is_cloud
Expand All @@ -19,7 +19,7 @@ def test_create_action_update_delete_tags(self):
super(LicenseManager, cast(LicenseManager, License.objects)).create(
key="key_123",
plan="enterprise",
valid_until=timezone.datetime(2038, 1, 19, 3, 14, 7),
valid_until=datetime.datetime(2038, 1, 19, 3, 14, 7),
)

response = self.client.post(f"/api/projects/{self.team.id}/actions/", data={"name": "user signed up"})
Expand Down Expand Up @@ -47,7 +47,7 @@ def test_create_action_with_tags(self):
super(LicenseManager, cast(LicenseManager, License.objects)).create(
key="key_123",
plan="enterprise",
valid_until=timezone.datetime(2038, 1, 19, 3, 14, 7),
valid_until=datetime.datetime(2038, 1, 19, 3, 14, 7),
)

response = self.client.post(
Expand All @@ -66,7 +66,7 @@ def test_actions_does_not_nplus1(self):
super(LicenseManager, cast(LicenseManager, License.objects)).create(
key="key_123",
plan="enterprise",
valid_until=timezone.datetime(2038, 1, 19, 3, 14, 7),
valid_until=datetime.datetime(2038, 1, 19, 3, 14, 7),
)

# Ensure the cloud check is cached to not affect the number of queries
Expand All @@ -91,7 +91,7 @@ def test_actions_no_duplicate_tags(self):
super(LicenseManager, cast(LicenseManager, License.objects)).create(
key="key_123",
plan="enterprise",
valid_until=timezone.datetime(2038, 1, 19, 3, 14, 7),
valid_until=datetime.datetime(2038, 1, 19, 3, 14, 7),
)
response = self.client.post(
f"/api/projects/{self.team.id}/actions/",
Expand Down
4 changes: 2 additions & 2 deletions ee/api/test/test_dashboard.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import datetime
from typing import cast

from django.utils import timezone
from rest_framework import status

from ee.api.test.base import APILicensedTest
Expand Down Expand Up @@ -232,7 +232,7 @@ def test_dashboard_no_duplicate_tags(self):
super(LicenseManager, cast(LicenseManager, License.objects)).create(
key="key_123",
plan="enterprise",
valid_until=timezone.datetime(2038, 1, 19, 3, 14, 7),
valid_until=datetime.datetime(2038, 1, 19, 3, 14, 7),
)
dashboard = Dashboard.objects.create(team=self.team, name="Edit-restricted dashboard", created_by=self.user)

Expand Down
24 changes: 12 additions & 12 deletions ee/api/test/test_event_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def setUpTestData(cls):

def test_list_event_definitions(self):
super(LicenseManager, cast(LicenseManager, License.objects)).create(
plan="enterprise", valid_until=timezone.datetime(2500, 1, 19, 3, 14, 7)
plan="enterprise", valid_until=datetime(2500, 1, 19, 3, 14, 7)
)

response = self.client.get("/api/projects/@current/event_definitions/")
Expand Down Expand Up @@ -90,7 +90,7 @@ def test_list_event_definitions(self):

def test_retrieve_existing_event_definition(self):
super(LicenseManager, cast(LicenseManager, License.objects)).create(
plan="enterprise", valid_until=timezone.datetime(2500, 1, 19, 3, 14, 7)
plan="enterprise", valid_until=datetime(2500, 1, 19, 3, 14, 7)
)
event = EnterpriseEventDefinition.objects.create(team=self.demo_team, name="enterprise event", owner=self.user)
tag = Tag.objects.create(name="deprecated", team_id=self.demo_team.id)
Expand All @@ -112,7 +112,7 @@ def test_retrieve_existing_event_definition(self):

def test_retrieve_create_event_definition(self):
super(LicenseManager, cast(LicenseManager, License.objects)).create(
plan="enterprise", valid_until=timezone.datetime(2500, 1, 19, 3, 14, 7)
plan="enterprise", valid_until=datetime(2500, 1, 19, 3, 14, 7)
)
event = EventDefinition.objects.create(team=self.demo_team, name="event")
response = self.client.get(f"/api/projects/@current/event_definitions/{event.id}")
Expand All @@ -125,7 +125,7 @@ def test_retrieve_create_event_definition(self):

def test_search_event_definition(self):
super(LicenseManager, cast(LicenseManager, License.objects)).create(
plan="enterprise", valid_until=timezone.datetime(2500, 1, 19, 3, 14, 7)
plan="enterprise", valid_until=datetime(2500, 1, 19, 3, 14, 7)
)
enterprise_property = EnterpriseEventDefinition.objects.create(
team=self.demo_team, name="enterprise event", owner=self.user
Expand Down Expand Up @@ -170,7 +170,7 @@ def test_search_event_definition(self):

def test_update_event_definition(self):
super(LicenseManager, cast(LicenseManager, License.objects)).create(
plan="enterprise", valid_until=timezone.datetime(2038, 1, 19, 3, 14, 7)
plan="enterprise", valid_until=datetime(2038, 1, 19, 3, 14, 7)
)
event = EnterpriseEventDefinition.objects.create(team=self.demo_team, name="enterprise event", owner=self.user)
response = self.client.patch(
Expand Down Expand Up @@ -226,7 +226,7 @@ def test_update_event_without_license(self):

def test_with_expired_license(self):
super(LicenseManager, cast(LicenseManager, License.objects)).create(
plan="enterprise", valid_until=timezone.datetime(2010, 1, 19, 3, 14, 7)
plan="enterprise", valid_until=datetime(2010, 1, 19, 3, 14, 7)
)
event = EnterpriseEventDefinition.objects.create(team=self.demo_team, name="description test")
response = self.client.patch(
Expand All @@ -241,7 +241,7 @@ def test_with_expired_license(self):

def test_can_get_event_verification_data(self):
super(LicenseManager, cast(LicenseManager, License.objects)).create(
plan="enterprise", valid_until=timezone.datetime(2500, 1, 19, 3, 14, 7)
plan="enterprise", valid_until=datetime(2500, 1, 19, 3, 14, 7)
)
event = EnterpriseEventDefinition.objects.create(team=self.demo_team, name="enterprise event", owner=self.user)
response = self.client.get(f"/api/projects/@current/event_definitions/{event.id}")
Expand All @@ -258,7 +258,7 @@ def test_can_get_event_verification_data(self):

def test_verify_then_unverify(self):
super(LicenseManager, cast(LicenseManager, License.objects)).create(
plan="enterprise", valid_until=timezone.datetime(2500, 1, 19, 3, 14, 7)
plan="enterprise", valid_until=datetime(2500, 1, 19, 3, 14, 7)
)
event = EnterpriseEventDefinition.objects.create(team=self.demo_team, name="enterprise event", owner=self.user)
response = self.client.get(f"/api/projects/@current/event_definitions/{event.id}")
Expand Down Expand Up @@ -288,7 +288,7 @@ def test_verify_then_unverify(self):

def test_verify_then_verify_again_no_change(self):
super(LicenseManager, cast(LicenseManager, License.objects)).create(
plan="enterprise", valid_until=timezone.datetime(2500, 1, 19, 3, 14, 7)
plan="enterprise", valid_until=datetime(2500, 1, 19, 3, 14, 7)
)
event = EnterpriseEventDefinition.objects.create(team=self.demo_team, name="enterprise event", owner=self.user)
response = self.client.get(f"/api/projects/@current/event_definitions/{event.id}")
Expand Down Expand Up @@ -327,7 +327,7 @@ def test_verify_then_verify_again_no_change(self):

def test_cannot_update_verified_meta_properties_directly(self):
super(LicenseManager, cast(LicenseManager, License.objects)).create(
plan="enterprise", valid_until=timezone.datetime(2500, 1, 19, 3, 14, 7)
plan="enterprise", valid_until=datetime(2500, 1, 19, 3, 14, 7)
)
event = EnterpriseEventDefinition.objects.create(team=self.demo_team, name="enterprise event", owner=self.user)
response = self.client.get(f"/api/projects/@current/event_definitions/{event.id}")
Expand Down Expand Up @@ -358,7 +358,7 @@ def test_event_definition_no_duplicate_tags(self):
super(LicenseManager, cast(LicenseManager, License.objects)).create(
key="key_123",
plan="enterprise",
valid_until=timezone.datetime(2038, 1, 19, 3, 14, 7),
valid_until=datetime(2038, 1, 19, 3, 14, 7),
)
event = EnterpriseEventDefinition.objects.create(team=self.demo_team, name="enterprise event")
response = self.client.patch(
Expand All @@ -370,7 +370,7 @@ def test_event_definition_no_duplicate_tags(self):

def test_event_type_event(self):
super(LicenseManager, cast(LicenseManager, License.objects)).create(
plan="enterprise", valid_until=timezone.datetime(2500, 1, 19, 3, 14, 7)
plan="enterprise", valid_until=datetime(2500, 1, 19, 3, 14, 7)
)
EnterpriseEventDefinition.objects.create(team=self.demo_team, name="rated_app")
EnterpriseEventDefinition.objects.create(team=self.demo_team, name="installed_app")
Expand Down
4 changes: 2 additions & 2 deletions ee/api/test/test_insight.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import datetime
import json
from datetime import timedelta
from typing import cast, Optional
from django.test import override_settings
from django.utils import timezone
from freezegun import freeze_time
from rest_framework import status

Expand Down Expand Up @@ -319,7 +319,7 @@ def test_event_definition_no_duplicate_tags(self):
super(LicenseManager, cast(LicenseManager, License.objects)).create(
key="key_123",
plan="enterprise",
valid_until=timezone.datetime(2038, 1, 19, 3, 14, 7),
valid_until=datetime.datetime(2038, 1, 19, 3, 14, 7),
)
dashboard = Dashboard.objects.create(team=self.team, name="Edit-restricted dashboard")
insight = Insight.objects.create(team=self.team, name="XYZ", created_by=self.user)
Expand Down
10 changes: 5 additions & 5 deletions ee/api/test/test_license.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def test_can_list_and_retrieve_licenses(self):
self.assertEqual(response_data["results"][0]["key"], "12345::67890")
self.assertEqual(
response_data["results"][0]["valid_until"],
timezone.datetime(2038, 1, 19, 3, 14, 7, tzinfo=ZoneInfo("UTC")).isoformat().replace("+00:00", "Z"),
datetime.datetime(2038, 1, 19, 3, 14, 7, tzinfo=ZoneInfo("UTC")).isoformat().replace("+00:00", "Z"),
)

retrieve_response = self.client.get(f"/api/license/{response_data['results'][0]['id']}")
Expand Down Expand Up @@ -91,13 +91,13 @@ def test_highest_activated_license_is_used_after_upgrade(self):
License.objects.create(
key="old",
plan="scale",
valid_until=timezone.datetime.now() + timezone.timedelta(days=30),
valid_until=datetime.datetime.now() + timezone.timedelta(days=30),
)
with freeze_time("2022-06-03T12:00:00.000Z"):
License.objects.create(
key="new",
plan="enterprise",
valid_until=timezone.datetime.now() + timezone.timedelta(days=30),
valid_until=datetime.datetime.now() + timezone.timedelta(days=30),
)

with freeze_time("2022-06-03T13:00:00.000Z"):
Expand All @@ -112,13 +112,13 @@ def test_highest_activated_license_is_used_after_renewal_to_lower(self):
License.objects.create(
key="new",
plan="enterprise",
valid_until=timezone.datetime.now() + timezone.timedelta(days=30),
valid_until=datetime.datetime.now() + timezone.timedelta(days=30),
)
with freeze_time("2022-06-27T12:00:00.000Z"):
License.objects.create(
key="old",
plan="scale",
valid_until=timezone.datetime.now() + timezone.timedelta(days=30),
valid_until=datetime.datetime.now() + timezone.timedelta(days=30),
)

with freeze_time("2022-06-27T13:00:00.000Z"):
Expand Down
29 changes: 15 additions & 14 deletions ee/api/test/test_property_definition.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import datetime
from typing import cast, Optional
from freezegun import freeze_time
import pytest
Expand Down Expand Up @@ -37,7 +38,7 @@ def test_errors_on_invalid_property_type(self):

def test_retrieve_existing_property_definition(self):
super(LicenseManager, cast(LicenseManager, License.objects)).create(
plan="enterprise", valid_until=timezone.datetime(2500, 1, 19, 3, 14, 7)
plan="enterprise", valid_until=datetime.datetime(2500, 1, 19, 3, 14, 7)
)
property = EnterprisePropertyDefinition.objects.create(team=self.team, name="enterprise property")
tag = Tag.objects.create(name="deprecated", team_id=self.team.id)
Expand All @@ -51,7 +52,7 @@ def test_retrieve_existing_property_definition(self):

def test_retrieve_create_property_definition(self):
super(LicenseManager, cast(LicenseManager, License.objects)).create(
plan="enterprise", valid_until=timezone.datetime(2500, 1, 19, 3, 14, 7)
plan="enterprise", valid_until=datetime.datetime(2500, 1, 19, 3, 14, 7)
)
property = PropertyDefinition.objects.create(team=self.team, name="property")
response = self.client.get(f"/api/projects/@current/property_definitions/{property.id}")
Expand All @@ -64,7 +65,7 @@ def test_retrieve_create_property_definition(self):

def test_search_property_definition(self):
super(LicenseManager, cast(LicenseManager, License.objects)).create(
plan="enterprise", valid_until=timezone.datetime(2500, 1, 19, 3, 14, 7)
plan="enterprise", valid_until=datetime.datetime(2500, 1, 19, 3, 14, 7)
)
tag = Tag.objects.create(name="deprecated", team_id=self.team.id)
EventProperty.objects.create(team=self.team, event="$pageview", property="enterprise property")
Expand Down Expand Up @@ -136,7 +137,7 @@ def test_search_property_definition(self):

def test_update_property_definition(self):
super(LicenseManager, cast(LicenseManager, License.objects)).create(
plan="enterprise", valid_until=timezone.datetime(2038, 1, 19, 3, 14, 7)
plan="enterprise", valid_until=datetime.datetime(2038, 1, 19, 3, 14, 7)
)
property = EnterprisePropertyDefinition.objects.create(team=self.team, name="enterprise property")
response = self.client.patch(
Expand Down Expand Up @@ -180,7 +181,7 @@ def test_update_property_definition(self):

def test_update_property_definition_property_type(self):
super(LicenseManager, cast(LicenseManager, License.objects)).create(
plan="enterprise", valid_until=timezone.datetime(2038, 1, 19, 3, 14, 7)
plan="enterprise", valid_until=datetime.datetime(2038, 1, 19, 3, 14, 7)
)

property = PropertyDefinition.objects.create(team=self.team, name="property")
Expand All @@ -197,7 +198,7 @@ def test_update_property_definition_property_type(self):

def test_update_property_definition_non_numeric(self):
super(LicenseManager, cast(LicenseManager, License.objects)).create(
plan="enterprise", valid_until=timezone.datetime(2038, 1, 19, 3, 14, 7)
plan="enterprise", valid_until=datetime.datetime(2038, 1, 19, 3, 14, 7)
)

property = PropertyDefinition.objects.create(
Expand Down Expand Up @@ -279,7 +280,7 @@ def test_cannot_update_more_than_property_type_without_license(self):

def test_with_expired_license(self):
super(LicenseManager, cast(LicenseManager, License.objects)).create(
plan="enterprise", valid_until=timezone.datetime(2010, 1, 19, 3, 14, 7)
plan="enterprise", valid_until=datetime.datetime(2010, 1, 19, 3, 14, 7)
)
property = EnterprisePropertyDefinition.objects.create(team=self.team, name="description test")
response = self.client.patch(
Expand All @@ -294,7 +295,7 @@ def test_with_expired_license(self):

def test_filter_property_definitions(self):
super(LicenseManager, cast(LicenseManager, License.objects)).create(
plan="enterprise", valid_until=timezone.datetime(2500, 1, 19, 3, 14, 7)
plan="enterprise", valid_until=datetime.datetime(2500, 1, 19, 3, 14, 7)
)
EnterprisePropertyDefinition.objects.create(team=self.team, name="plan")
EnterprisePropertyDefinition.objects.create(team=self.team, name="purchase")
Expand All @@ -313,7 +314,7 @@ def test_event_property_definition_no_duplicate_tags(self):
super(LicenseManager, cast(LicenseManager, License.objects)).create(
key="key_123",
plan="enterprise",
valid_until=timezone.datetime(2038, 1, 19, 3, 14, 7),
valid_until=datetime.datetime(2038, 1, 19, 3, 14, 7),
)
property = EnterprisePropertyDefinition.objects.create(team=self.team, name="description test")
response = self.client.patch(
Expand All @@ -326,7 +327,7 @@ def test_event_property_definition_no_duplicate_tags(self):
@freeze_time("2021-08-25T22:09:14.252Z")
def test_can_get_property_verification_data(self):
super(LicenseManager, cast(LicenseManager, License.objects)).create(
plan="enterprise", valid_until=timezone.datetime(2500, 1, 19, 3, 14, 7)
plan="enterprise", valid_until=datetime.datetime(2500, 1, 19, 3, 14, 7)
)
event = EnterprisePropertyDefinition.objects.create(team=self.team, name="enterprise property")
response = self.client.get(f"/api/projects/@current/property_definitions/{event.id}")
Expand All @@ -344,7 +345,7 @@ def test_can_get_property_verification_data(self):
@freeze_time("2021-08-25T22:09:14.252Z")
def test_verify_then_unverify(self):
super(LicenseManager, cast(LicenseManager, License.objects)).create(
plan="enterprise", valid_until=timezone.datetime(2500, 1, 19, 3, 14, 7)
plan="enterprise", valid_until=datetime.datetime(2500, 1, 19, 3, 14, 7)
)
event = EnterprisePropertyDefinition.objects.create(team=self.team, name="enterprise property")
response = self.client.get(f"/api/projects/@current/property_definitions/{event.id}")
Expand Down Expand Up @@ -380,7 +381,7 @@ def test_verify_then_unverify(self):

def test_verify_then_verify_again_no_change(self):
super(LicenseManager, cast(LicenseManager, License.objects)).create(
plan="enterprise", valid_until=timezone.datetime(2500, 1, 19, 3, 14, 7)
plan="enterprise", valid_until=datetime.datetime(2500, 1, 19, 3, 14, 7)
)
event = EnterprisePropertyDefinition.objects.create(team=self.team, name="enterprise property")
response = self.client.get(f"/api/projects/@current/property_definitions/{event.id}")
Expand Down Expand Up @@ -420,7 +421,7 @@ def test_verify_then_verify_again_no_change(self):
@freeze_time("2021-08-25T22:09:14.252Z")
def test_cannot_update_verified_meta_properties_directly(self):
super(LicenseManager, cast(LicenseManager, License.objects)).create(
plan="enterprise", valid_until=timezone.datetime(2500, 1, 19, 3, 14, 7)
plan="enterprise", valid_until=datetime.datetime(2500, 1, 19, 3, 14, 7)
)
event = EnterprisePropertyDefinition.objects.create(team=self.team, name="enterprise property")
response = self.client.get(f"/api/projects/@current/property_definitions/{event.id}")
Expand All @@ -447,7 +448,7 @@ def test_cannot_update_verified_meta_properties_directly(self):

def test_list_property_definitions(self):
super(LicenseManager, cast(LicenseManager, License.objects)).create(
plan="enterprise", valid_until=timezone.datetime(2500, 1, 19, 3, 14, 7)
plan="enterprise", valid_until=datetime.datetime(2500, 1, 19, 3, 14, 7)
)

properties: list[dict] = [
Expand Down
Loading
Loading