-
-
Notifications
You must be signed in to change notification settings - Fork 0
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
3 changed files
with
58 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
"""Admin class for tests""" | ||
from tornadmin.backends.base import BaseModelAdmin | ||
from tornadmin.utils.text import split_camel, slugify | ||
|
||
class TestModelAdmin(BaseModelAdmin): | ||
def __init__(self, model, **kwargs): | ||
name = model.__name__ | ||
|
||
self.model = model | ||
self.name = kwargs.get('name', ' '.join(split_camel(name))) | ||
self.slug = kwargs.get('slug', name.lower()) | ||
self.app = kwargs['app'] | ||
self.app_slug = slugify(self.app) |
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 unittest.mock import MagicMock | ||
from tornado import testing, web, httputil | ||
from tornadmin import BaseAdminSite, AdminRouter, uimodules | ||
|
||
from admin import TestModelAdmin | ||
|
||
|
||
class UserAdmin(TestModelAdmin): | ||
pass | ||
|
||
class UserModel(MagicMock): | ||
__name__ = 'User' | ||
|
||
|
||
class AdminSite(BaseAdminSite): | ||
pass | ||
|
||
admin_site = AdminSite(base_url='/admin') | ||
|
||
admin_site.register(UserAdmin(model=UserModel, app='general', slug='user')) | ||
|
||
|
||
|
||
app = web.Application( | ||
[AdminRouter(admin_site)], | ||
ui_modules=[uimodules], | ||
debut=True, | ||
) | ||
|
||
|
||
class CommonHandlerTests(testing.AsyncHTTPTestCase): | ||
def setUp(self): | ||
list_route = '/admin/general/user/' | ||
create_route = '/admin/general/user/add/' | ||
delete_route = '/admin/general/' | ||
|
||
|
||
class ListHandlerTests(testing.AsyncHTTPTestCase): | ||
def get_app(self): | ||
return app | ||
|
||
def _test_list_headers(self): | ||
# Must work with callables, string fields and methods | ||
self.fetch('/admin/general/user') |
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 |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
from tornadmin.sites import BaseAdminSite | ||
|
||
|
||
__version__ = "1.0.dev" | ||
__version__ = "0.9.1" | ||
|
||
|
||
__all__ = [ | ||
|