-
-
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.
feat(demo-mode): identify demo users via id
- Loading branch information
1 parent
a13ce7b
commit 5cfd725
Showing
2 changed files
with
13 additions
and
15 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 |
---|---|---|
|
@@ -6,23 +6,23 @@ | |
from sentry.utils.demo_mode import get_readonly_user, is_demo_org, is_readonly_user | ||
|
||
|
||
@override_options({"demo-mode.enabled": True, "demo-mode.users": ["[email protected]"]}) | ||
@override_options({"demo-mode.enabled": True, "demo-mode.users": [1]}) | ||
@django_db_all | ||
def test_is_readonly_user_demo_mode_enabled_none(): | ||
assert not is_readonly_user(None) | ||
|
||
|
||
@override_options({"demo-mode.enabled": True, "demo-mode.users": ["[email protected]"]}) | ||
@override_options({"demo-mode.enabled": True, "demo-mode.users": [1]}) | ||
@django_db_all | ||
def test_is_readonly_user_demo_mode_enabled_readonly_user(): | ||
user = Factories.create_user("[email protected]") | ||
user = Factories.create_user(id=1) | ||
assert is_readonly_user(user) | ||
|
||
|
||
@override_options({"demo-mode.enabled": True, "demo-mode.users": ["[email protected]"]}) | ||
@override_options({"demo-mode.enabled": True, "demo-mode.users": [1]}) | ||
@django_db_all | ||
def test_is_readonly_user_demo_mode_enabled_non_readonly_user(): | ||
user = Factories.create_user("[email protected]") | ||
user = Factories.create_user(id=2) | ||
assert not is_readonly_user(user) | ||
|
||
|
||
|
@@ -35,14 +35,14 @@ def test_is_readonly_user_demo_mode_disabled_none(): | |
@override_options({"demo-mode.enabled": False}) | ||
@django_db_all | ||
def test_is_readonly_user_demo_mode_disabled_readonly_user(): | ||
user = Factories.create_user("[email protected]") | ||
user = Factories.create_user(id=1) | ||
assert not is_readonly_user(user) | ||
|
||
|
||
@override_options({"demo-mode.enabled": False}) | ||
@django_db_all | ||
def test_is_readonly_user_demo_mode_disabled_non_readonly_user(): | ||
user = Factories.create_user("[email protected]") | ||
user = Factories.create_user(id=2) | ||
assert not is_readonly_user(user) | ||
|
||
|
||
|
@@ -79,10 +79,10 @@ def test_get_readonly_user_demo_mode_disabled(): | |
assert get_readonly_user() is None | ||
|
||
|
||
@override_options({"demo-mode.enabled": True, "demo-mode.users": ["[email protected]"]}) | ||
@override_options({"demo-mode.enabled": True, "demo-mode.users": [1]}) | ||
@django_db_all | ||
def test_get_readonly_user_demo_mode_enabled(): | ||
user = Factories.create_user("[email protected]") | ||
user = Factories.create_user(id=1) | ||
with patch("sentry.utils.demo_mode.User.objects.get", return_value=user) as mock_user_get: | ||
assert get_readonly_user() == user | ||
mock_user_get.assert_called_once_with(email="[email protected]") | ||
mock_user_get.assert_called_once_with(id=1) |