-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
tests/sentry/migrations/test_0647_apitoken_add_hashed_columns.py
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from django.db import router | ||
|
||
from sentry.silo import unguarded_write | ||
from sentry.testutils.cases import TestMigrations | ||
from sentry.testutils.silo import no_silo_test | ||
|
||
|
||
@no_silo_test | ||
class AddHashedColumnsApiToken(TestMigrations): | ||
migrate_from = "0646_create_notification_message_table" | ||
migrate_to = "0647_apitoken_add_hashed_columns" | ||
|
||
def setUp(self): | ||
from sentry.models.apitoken import ApiToken | ||
|
||
with unguarded_write(using=router.db_for_write(ApiToken)): | ||
super().setUp() | ||
|
||
def setup_before_migration(self, apps): | ||
ApiToken = apps.get_model("sentry", "ApiToken") | ||
self.api_token = ApiToken.objects.create( | ||
user_id=self.user.id, | ||
) | ||
self.api_token.save() | ||
|
||
def test(self): | ||
from sentry.models.apitoken import ApiToken | ||
|
||
api_token = ApiToken.objects.get() | ||
assert api_token.hashed_token is None | ||
assert api_token.hashed_refresh_token is None |