-
Notifications
You must be signed in to change notification settings - Fork 205
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: show/hide history & view on site (#201)
- Loading branch information
1 parent
5a940bc
commit edb5932
Showing
5 changed files
with
59 additions
and
6 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
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
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,44 @@ | ||
from django.contrib.auth.models import AnonymousUser | ||
from django.test import TestCase | ||
from django.test.client import RequestFactory | ||
from django.test.utils import override_settings | ||
from unfold.settings import CONFIG_DEFAULTS, get_config | ||
from unfold.sites import UnfoldAdminSite | ||
|
||
|
||
class ShowTestCase(TestCase): | ||
@override_settings(UNFOLD={**CONFIG_DEFAULTS}) | ||
def test_show_history_default(self): | ||
admin_site = UnfoldAdminSite() | ||
request = RequestFactory().get("/rand") | ||
request.user = AnonymousUser() | ||
context = admin_site.each_context(request) | ||
self.assertTrue(context.get("show_history")) | ||
get_config.cache_clear() | ||
|
||
@override_settings(UNFOLD={**CONFIG_DEFAULTS, **{"SHOW_HISTORY": False}}) | ||
def test_show_history_hide(self): | ||
admin_site = UnfoldAdminSite() | ||
request = RequestFactory().get("/rand") | ||
request.user = AnonymousUser() | ||
context = admin_site.each_context(request) | ||
self.assertFalse(context.get("show_history")) | ||
get_config.cache_clear() | ||
|
||
@override_settings(UNFOLD={**CONFIG_DEFAULTS}) | ||
def test_show_view_on_site_default(self): | ||
admin_site = UnfoldAdminSite() | ||
request = RequestFactory().get("/rand") | ||
request.user = AnonymousUser() | ||
context = admin_site.each_context(request) | ||
self.assertTrue(context.get("show_view_on_site")) | ||
get_config.cache_clear() | ||
|
||
@override_settings(UNFOLD={**CONFIG_DEFAULTS, **{"SHOW_VIEW_ON_SITE": False}}) | ||
def test_show_view_on_site_hide(self): | ||
admin_site = UnfoldAdminSite() | ||
request = RequestFactory().get("/rand") | ||
request.user = AnonymousUser() | ||
context = admin_site.each_context(request) | ||
self.assertFalse(context.get("show_view_on_site")) | ||
get_config.cache_clear() |