Exemplo n.º 1
0
 def test_get_paginate_form(self):
     """Test form creation."""
     mixin = PaginateByMixin()
     mixin.request = self.request_factory.get('/?per_page=100')
     form = mixin.get_paginate_form()
     self.assertIsInstance(form, PaginateByForm)
     self.assertEqual(form.initial['per_page'], '100')
 def test_get_paginate_form(self):
     """Test form creation."""
     mixin = PaginateByMixin()
     mixin.request = self.request_factory.get('/?per_page=100')
     form = mixin.get_paginate_form()
     self.assertIsInstance(form, PaginateByForm)
     self.assertEqual(form.initial['per_page'], '100')
Exemplo n.º 3
0
 def test_get_paginate_by_not_digit(self):
     """Test get_get_paginate_by when per_page is not a digit."""
     mixin = PaginateByMixin()
     mixin.request = self.request_factory.get('/?per_page=abc')
     self.assertEqual(mixin.get_paginate_by([]), None)
Exemplo n.º 4
0
 def test_get_paginate_by_not_in_querystring(self):
     """Test get_paginate_by when per_page is not provided."""
     mixin = PaginateByMixin()
     mixin.request = self.request_factory.get('/')
     self.assertEqual(mixin.get_paginate_by([]), None)
Exemplo n.º 5
0
 def test_get_paginate_by(self):
     """Test get_paginate_by."""
     mixin = PaginateByMixin()
     mixin.request = self.request_factory.get('/?per_page=100')
     self.assertEqual(mixin.get_paginate_by([]), 100)
Exemplo n.º 6
0
 def test_get_context_data(self):
     """Test adding form to context."""
     mixin = PaginateByMixin()
     mixin.request = self.request_factory.get('/')
     self.assertIsInstance(mixin.get_context_data()['paginate_by_form'],
                           PaginateByForm)
Exemplo n.º 7
0
 def test_get_paginate_form_initial(self):
     """Test getting form initial values."""
     mixin = PaginateByMixin()
     mixin.request = self.request_factory.get('/?per_page=100')
     initial = mixin.get_paginate_form_initial()
     self.assertEqual(initial['per_page'], '100')
Exemplo n.º 8
0
 def test_get_paginate_form_kwargs(self):
     """Test getting form kwargs."""
     mixin = PaginateByMixin()
     mixin.request = self.request_factory.get('/?per_page=100')
     kwargs = mixin.get_paginate_form_kwargs()
     self.assertEqual(kwargs['initial']['per_page'], '100')
 def test_get_paginate_by_not_digit(self):
     """Test get_get_paginate_by when per_page is not a digit."""
     mixin = PaginateByMixin()
     mixin.request = self.request_factory.get('/?per_page=abc')
     self.assertEqual(mixin.get_paginate_by([]), None)
Exemplo n.º 10
0
 def test_get_paginate_by_not_in_querystring(self):
     """Test get_paginate_by when per_page is not provided."""
     mixin = PaginateByMixin()
     mixin.request = self.request_factory.get('/')
     self.assertEqual(mixin.get_paginate_by([]), None)
Exemplo n.º 11
0
 def test_get_paginate_by(self):
     """Test get_paginate_by."""
     mixin = PaginateByMixin()
     mixin.request = self.request_factory.get('/?per_page=100')
     self.assertEqual(mixin.get_paginate_by([]), 100)
Exemplo n.º 12
0
 def test_get_context_data(self):
     """Test adding form to context."""
     mixin = PaginateByMixin()
     mixin.request = self.request_factory.get('/')
     self.assertIsInstance(
         mixin.get_context_data()['paginate_by_form'], PaginateByForm)
Exemplo n.º 13
0
 def test_get_paginate_form_initial(self):
     """Test getting form initial values."""
     mixin = PaginateByMixin()
     mixin.request = self.request_factory.get('/?per_page=100')
     initial = mixin.get_paginate_form_initial()
     self.assertEqual(initial['per_page'], '100')
Exemplo n.º 14
0
 def test_get_paginate_form_kwargs(self):
     """Test getting form kwargs."""
     mixin = PaginateByMixin()
     mixin.request = self.request_factory.get('/?per_page=100')
     kwargs = mixin.get_paginate_form_kwargs()
     self.assertEqual(kwargs['initial']['per_page'], '100')