-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wrote some early tests using Alex's schema (#52778)
WIP of tests for exportable models. related prs are #52669 --------- Co-authored-by: Alex Zaslavsky <[email protected]>
- Loading branch information
1 parent
4705814
commit 47d7971
Showing
1 changed file
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,15 @@ | |
PendingIncidentSnapshot, | ||
TimeSeriesSnapshot, | ||
) | ||
from sentry.models import ( | ||
ApiApplication, | ||
ApiAuthorization, | ||
ApiKey, | ||
ApiToken, | ||
Authenticator, | ||
AuthIdentity, | ||
AuthProvider, | ||
) | ||
from sentry.models.actor import ACTOR_TYPES, Actor | ||
from sentry.models.counter import Counter | ||
from sentry.models.dashboard import Dashboard, DashboardTombstone | ||
|
@@ -299,6 +308,60 @@ def test_organization(self): | |
self.create_organization(owner=user) | ||
return self.import_export_then_validate() | ||
|
||
@targets_models(Actor) | ||
def test_actor(self): | ||
self.create_user(email="[email protected]") | ||
self.create_team(name="pre save team", organization=self.organization) | ||
return self.import_export_then_validate() | ||
|
||
@targets_models(ApiAuthorization, ApiApplication) | ||
def test_api_authorization_application(self): | ||
user = self.create_user() | ||
app = ApiApplication.objects.create(name="test", owner=user) | ||
ApiAuthorization.objects.create( | ||
application=app, user=self.create_user("[email protected]") | ||
) | ||
return self.import_export_then_validate() | ||
|
||
@targets_models(ApiToken) | ||
def test_apitoken(self): | ||
user = self.create_user() | ||
app = ApiApplication.objects.create( | ||
owner=user, redirect_uris="http://example.com\nhttp://sub.example.com/path" | ||
) | ||
ApiToken.objects.create(application=app, user=user, token=uuid4().hex, expires_at=None) | ||
return self.import_export_then_validate() | ||
|
||
@targets_models(ApiKey) | ||
def test_apikey(self): | ||
user = self.create_user() | ||
org = self.create_organization(owner=user) | ||
ApiKey.objects.create(key=uuid4().hex, organization_id=org.id) | ||
return self.import_export_then_validate() | ||
|
||
@targets_models(Authenticator) | ||
def test_authenticator(self): | ||
user = self.create_user() | ||
Authenticator.objects.create(user=user, type=1) | ||
return self.import_export_then_validate() | ||
|
||
@targets_models(AuthIdentity, AuthProvider) | ||
def test_auth_identity_provider(self): | ||
user = self.create_user() | ||
test_data = { | ||
"key1": "value1", | ||
"key2": 42, | ||
"key3": [1, 2, 3], | ||
"key4": {"nested_key": "nested_value"}, | ||
} | ||
AuthIdentity.objects.create( | ||
user=user, | ||
auth_provider=AuthProvider.objects.create(organization_id=1, provider="sentry"), | ||
ident="123456789", | ||
data=test_data, | ||
) | ||
return self.import_export_then_validate() | ||
|
||
@targets_models(OrganizationAccessRequest, OrganizationMember, OrganizationMemberTeam, Team) | ||
def test_organization_membership(self): | ||
organization = self.create_organization(name="test_org", owner=self.user) | ||
|