Skip to content

Commit

Permalink
ref: use a TypedDict for a few test case dicts (#73207)
Browse files Browse the repository at this point in the history
fixes some errors when model types are checked

<!-- Describe your PR here. -->
  • Loading branch information
asottile-sentry authored Jun 24, 2024
1 parent 38833ad commit 897f0f2
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/sentry/testutils/cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from contextlib import contextmanager
from datetime import UTC, datetime, timedelta
from io import BytesIO
from typing import Any, Literal, Union
from typing import Any, Literal, TypedDict, Union
from unittest import mock
from urllib.parse import urlencode
from uuid import uuid4
Expand Down Expand Up @@ -2584,30 +2584,39 @@ def assert_commit(self, commit, key):
assert commit.key == key


class _QueryDict(TypedDict):
name: str
fields: list[str]
aggregates: list[str]
columns: list[str]
fieldAliases: list[str]
conditions: str


class OrganizationDashboardWidgetTestCase(APITestCase):
def setUp(self):
super().setUp()
self.login_as(self.user)
self.dashboard = Dashboard.objects.create(
title="Dashboard 1", created_by_id=self.user.id, organization=self.organization
)
self.anon_users_query = {
self.anon_users_query: _QueryDict = {
"name": "Anonymous Users",
"fields": ["count()"],
"aggregates": ["count()"],
"columns": [],
"fieldAliases": ["Count Alias"],
"conditions": "!has:user.email",
}
self.known_users_query = {
self.known_users_query: _QueryDict = {
"name": "Known Users",
"fields": ["count_unique(user.email)"],
"aggregates": ["count_unique(user.email)"],
"columns": [],
"fieldAliases": [],
"conditions": "has:user.email",
}
self.geo_errors_query = {
self.geo_errors_query: _QueryDict = {
"name": "Errors by Geo",
"fields": ["count()", "geo.country_code"],
"aggregates": ["count()"],
Expand Down

0 comments on commit 897f0f2

Please sign in to comment.