コード例 #1
0
    def test_should_work_no_start_no_batch(self):
        displayer = BatchingDisplayType(self.gallery, self.request)
        displayer.adapter.settings.batch_size = 5

        self.assertEquals(displayer.start_image_index, 0)
        self.assertEquals(displayer.b_start, 0)
        self.assertEquals(displayer.get_page(), 0)
コード例 #2
0
    def test_should_work_no_start_no_batch(self):
        displayer = BatchingDisplayType(self.gallery, self.request)
        displayer.adapter.settings.batch_size = 5

        self.assertEqual(displayer.start_image_index, 0)
        self.assertEqual(displayer.b_start, 0)
        self.assertEqual(displayer.get_page(), 0)
コード例 #3
0
    def test_with_b_start_specified(self):
        self.request.form.update({'b_start': '10'})
        displayer = BatchingDisplayType(self.gallery, self.request)
        displayer.adapter.settings.batch_size = 5

        self.assertEquals(displayer.start_image_index, 0)
        self.assertEquals(displayer.b_start, 10)
        self.assertEquals(displayer.get_page(), 0)
コード例 #4
0
    def test_should_handle_exceeding_batch_size(self):
        self.request.form.update({'start_image': 'Title for 14'})
        displayer = BatchingDisplayType(self.gallery, self.request)
        displayer.adapter.settings.batch_size = 5

        self.assertEquals(displayer.start_image_index, 3)
        self.assertEquals(displayer.b_start, 10)
        self.assertEquals(displayer.get_page(), 2)
コード例 #5
0
    def test_with_b_start_specified(self):
        self.request.form.update({'b_start': '10'})
        displayer = BatchingDisplayType(self.gallery, self.request)
        displayer.adapter.settings.batch_size = 5

        self.assertEqual(displayer.start_image_index, 0)
        self.assertEqual(displayer.b_start, 10)
        self.assertEqual(displayer.get_page(), 0)
コード例 #6
0
    def test_should_handle_exceeding_batch_size(self):
        self.request.form.update({'start_image': 'Title for 14'})
        displayer = BatchingDisplayType(self.gallery, self.request)
        displayer.adapter.settings.batch_size = 5

        self.assertEqual(displayer.start_image_index, 3)
        self.assertEqual(displayer.b_start, 10)
        self.assertEqual(displayer.get_page(), 2)
コード例 #7
0
    def test_should_work_normally_if_no_start_image_is_selected_and_no_batch(self):
        adapter = getMultiAdapter(
            (self.portal['test_gallery'], TestRequest()),
            name=named_adapter_prefix + 'basic'
        )
        adapter.settings.batch_size = 5
        displayer = BatchingDisplayType(adapter)

        self.failUnless(displayer.start_image_index == 0)
        self.failUnless(displayer.b_start == 0)
        self.failUnless(displayer.get_page() == 0)
コード例 #8
0
    def test_should_automatically_bring_you_to_correct_batch_if_image_exceeds_batch_size(self):
        adapter = getMultiAdapter(
            (
                self.portal['test_gallery'],
                TestRequest(form={'start_image': 'Title for 14'})
            ),
            name=named_adapter_prefix + 'basic'
        )
        adapter.settings.batch_size = 5
        displayer = BatchingDisplayType(adapter)

        self.failUnless(displayer.start_image_index == 3)
        self.failUnless(displayer.b_start == 10)
        self.failUnless(displayer.get_page() == 2)
コード例 #9
0
    def test_with_b_start_specified(self):
        adapter = getMultiAdapter(
            (
                self.portal['test_gallery'],
                TestRequest(form={'b_start': '10'})
            ),
            name=named_adapter_prefix + 'basic'
        )
        adapter.settings.batch_size = 5
        displayer = BatchingDisplayType(adapter)

        self.failUnless(displayer.start_image_index == 0)
        self.failUnless(displayer.b_start == 10)
        self.failUnless(displayer.get_page() == 0)