Skip to content

Commit

Permalink
Added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ZuluPro committed Jan 18, 2018
1 parent b48a379 commit 9b4dde7
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ class SimpleView(DispatchHookMixin, tables.SingleTableView):
model = Region # required for ListView


class SimpleNoTableClassView(DispatchHookMixin, tables.SingleTableView):
model = Region # required for ListView


class SimplePaginatedView(DispatchHookMixin, tables.SingleTableView):
table_class = SimpleTable
table_pagination = {'per_page': 1}
Expand Down Expand Up @@ -102,13 +106,6 @@ def get_queryset(self):
assert len(table.rows) == 1
assert table.rows[0].get_cell('name') == 'Queensland'

def test_should_raise_without_tableclass(self):
class WithoutTableclassView(tables.SingleTableView):
model = Region

with self.assertRaises(ImproperlyConfigured):
WithoutTableclassView.as_view()(build_request('/'))

def test_should_support_explicit_table_data(self):
class ExplicitDataView(SimplePaginatedView):
table_data = MEMORY_DATA
Expand Down Expand Up @@ -197,6 +194,16 @@ def get_queryset(self):

TestView.as_view()(build_request())

def test_get_tables_class(self):
view = SimpleView()
table_class = view.get_table_class()
self.assertEqual(table_class, view.table_class)

def test_get_tables_class_auto(self):
view = SimpleNoTableClassView()
table_class = view.get_table_class()
self.assertEqual(table_class.__name__, 'RegionTable')


class SingleTableMixinTest(TestCase):
def test_with_non_paginated_view(self):
Expand Down

0 comments on commit 9b4dde7

Please sign in to comment.