-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactored users models * added tests
- Loading branch information
Vladislav Denisov
authored
Oct 4, 2023
1 parent
09ec299
commit a19b17b
Showing
2 changed files
with
27 additions
and
8 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
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
from redash import redis_connection | ||
from redash.models import User, db | ||
from redash.models import ApiUser, User, db | ||
from redash.models.users import LAST_ACTIVE_KEY, sync_last_active_at | ||
from redash.utils import dt_from_timestamp | ||
from tests import BaseTestCase, authenticated_user | ||
|
@@ -103,3 +103,16 @@ def test_sync(self): | |
user_reloaded = User.query.filter(User.id == user.id).first() | ||
self.assertIn("active_at", user_reloaded.details) | ||
self.assertEqual(user_reloaded.active_at, timestamp) | ||
|
||
|
||
class TestUserGetActualUser(BaseTestCase): | ||
def test_default_user(self): | ||
user_email = "[email protected]" | ||
user = self.factory.create_user(email=user_email) | ||
self.assertEqual(user.get_actual_user(), user_email) | ||
|
||
def test_api_user(self): | ||
user_email = "[email protected]" | ||
user = self.factory.create_user(email=user_email) | ||
api_user = ApiUser(user.api_key, user.org, user.group_ids) | ||
self.assertEqual(api_user.get_actual_user(), repr(api_user)) |