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

ref: use a TypedDict for a few test case dicts #73207

Merged
merged 1 commit into from
Jun 24, 2024
Merged
Changes from all commits
Commits
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
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
Loading