Example #1
0
    def test_grid_search(self):
        from c2cgeoform.views import grid
        _add_test_persons()

        request = testing.DummyRequest()
        request.matchdict['schema'] = 'tests_persons'
        request.POST['current'] = '1'
        request.POST['rowCount'] = '5'
        request.POST['sort[name]'] = 'asc'
        request.POST['searchPhrase'] = 'sha'
        response = grid(request)

        self.assertEquals(1, response['current'])
        self.assertEquals(5, response['rowCount'])
        self.assertEquals(4, response['total'])

        request.POST['searchPhrase'] = '   Smith  '
        response = grid(request)
        self.assertEquals(1, response['total'])

        request.POST['searchPhrase'] = 'NOT FOUND'
        response = grid(request)
        self.assertEquals(0, response['total'])

        # only text fields tagged with 'admin_list' are searched
        request.POST['searchPhrase'] = 'Peter'
        response = grid(request)
        self.assertEquals(0, response['total'])
Example #2
0
    def test_grid_search(self):
        from c2cgeoform.views import grid
        _add_test_persons()

        request = self._get_request()
        request.matchdict['schema'] = 'tests_persons'
        request.POST['current'] = '1'
        request.POST['rowCount'] = '5'
        request.POST['sort[name]'] = 'asc'
        request.POST['searchPhrase'] = 'sha'
        response = grid(request)

        self.assertEquals(1, response['current'])
        self.assertEquals(5, response['rowCount'])
        self.assertEquals(4, response['total'])

        request.POST['searchPhrase'] = '   Smith  '
        response = grid(request)
        self.assertEquals(1, response['total'])

        request.POST['searchPhrase'] = 'NOT FOUND'
        response = grid(request)
        self.assertEquals(0, response['total'])

        # only text fields tagged with 'admin_list' are searched
        request.POST['searchPhrase'] = 'Peter'
        response = grid(request)
        self.assertEquals(0, response['total'])
Example #3
0
    def test_grid_paging(self):
        from c2cgeoform.views import grid
        _add_test_persons()

        request = testing.DummyRequest()
        request.matchdict['schema'] = 'tests_persons'
        request.POST['current'] = '2'
        request.POST['rowCount'] = '5'
        request.POST['sort[name]'] = 'asc'
        response = grid(request)

        self.assertEquals(2, response['current'])
        self.assertEquals(5, response['rowCount'])
        self.assertEquals(22, response['total'])

        rows = response['rows']
        self.assertEquals('Elda', rows[0]['name'])
        self.assertEquals('Eloise', rows[1]['name'])

        # invalid page
        request.POST['current'] = '99'
        response = grid(request)
        self.assertEquals(5, response['current'])
Example #4
0
    def test_grid_paging(self):
        from c2cgeoform.views import grid
        _add_test_persons()

        request = self._get_request()
        request.matchdict['schema'] = 'tests_persons'
        request.POST['current'] = '2'
        request.POST['rowCount'] = '5'
        request.POST['sort[name]'] = 'asc'
        response = grid(request)

        self.assertEquals(2, response['current'])
        self.assertEquals(5, response['rowCount'])
        self.assertEquals(22, response['total'])

        rows = response['rows']
        self.assertEquals('Elda', rows[0]['name'])
        self.assertEquals('Eloise', rows[1]['name'])

        # invalid page
        request.POST['current'] = '99'
        response = grid(request)
        self.assertEquals(5, response['current'])
Example #5
0
    def test_grid_sort(self):
        from c2cgeoform.views import grid
        _add_test_persons()

        request = testing.DummyRequest()
        request.matchdict['schema'] = 'tests_persons'
        request.POST['current'] = '1'
        request.POST['rowCount'] = '5'
        request.POST['sort[name]'] = 'asc'
        response = grid(request)

        self.assertEquals(1, response['current'])
        self.assertEquals(5, response['rowCount'])
        self.assertEquals(22, response['total'])

        rows = response['rows']
        self.assertEquals('Bess', rows[0]['name'])
        self.assertEquals('Claudio', rows[1]['name'])
Example #6
0
    def test_grid(self):
        from c2cgeoform.views import grid
        _add_test_persons()

        request = testing.DummyRequest()
        request.matchdict['schema'] = 'tests_persons'
        request.POST['current'] = '1'
        request.POST['rowCount'] = '5'
        response = grid(request)

        self.assertEquals(1, response['current'])
        self.assertEquals(5, response['rowCount'])
        self.assertEquals(22, response['total'])

        rows = response['rows']
        self.assertEquals(5, len(rows))
        self.assertTrue('_id_' in rows[0])
        self.assertEquals('Smith', rows[0]['name'])
Example #7
0
    def test_grid_sort(self):
        from c2cgeoform.views import grid
        _add_test_persons()

        request = self._get_request()
        request.matchdict['schema'] = 'tests_persons'
        request.POST['current'] = '1'
        request.POST['rowCount'] = '5'
        request.POST['sort[name]'] = 'asc'
        response = grid(request)

        self.assertEquals(1, response['current'])
        self.assertEquals(5, response['rowCount'])
        self.assertEquals(22, response['total'])

        rows = response['rows']
        self.assertEquals('Bess', rows[0]['name'])
        self.assertEquals('Claudio', rows[1]['name'])
Example #8
0
    def test_grid(self):
        from c2cgeoform.views import grid
        _add_test_persons()

        request = self._get_request()
        request.matchdict['schema'] = 'tests_persons'
        request.POST['current'] = '1'
        request.POST['rowCount'] = '5'
        response = grid(request)

        self.assertEquals(1, response['current'])
        self.assertEquals(5, response['rowCount'])
        self.assertEquals(22, response['total'])

        rows = response['rows']
        self.assertEquals(5, len(rows))
        self.assertTrue('_id_' in rows[0])
        self.assertEquals('Smith', rows[0]['name'])