def test_pagination(self):
        # create several students
        rv, json = self.client.post('/api/v1.0/students/',
                                    data={'name': 'one'})
        self.assertTrue(rv.status_code == 201)
        one_url = rv.headers['Location']
        rv, json = self.client.post('/api/v1.0/students/',
                                    data={'name': 'two'})
        self.assertTrue(rv.status_code == 201)
        two_url = rv.headers['Location']
        rv, json = self.client.post('/api/v1.0/students/',
                                    data={'name': 'three'})
        self.assertTrue(rv.status_code == 201)
        three_url = rv.headers['Location']
        rv, json = self.client.post('/api/v1.0/students/',
                                    data={'name': 'four'})
        self.assertTrue(rv.status_code == 201)
        four_url = rv.headers['Location']
        rv, json = self.client.post('/api/v1.0/students/',
                                    data={'name': 'five'})
        self.assertTrue(rv.status_code == 201)
        five_url = rv.headers['Location']

        # get collection in pages
        rv, json = self.client.get('/api/v1.0/students/?page=1&per_page=2')
        self.assertTrue(rv.status_code == 200)
        self.assertTrue(one_url in json['urls'])
        self.assertTrue(two_url in json['urls'])
        self.assertTrue(len(json['urls']) == 2)
        self.assertTrue('total' in json['meta'])
        self.assertTrue(json['meta']['total'] == 5)
        self.assertTrue('prev' in json['meta'])
        self.assertTrue(json['meta']['prev'] is None)
        first_url = json['meta']['first'].replace('http://localhost', '')
        last_url = json['meta']['last'].replace('http://localhost', '')
        next_url = json['meta']['next'].replace('http://localhost', '')

        rv, json = self.client.get(first_url)
        self.assertTrue(rv.status_code == 200)
        self.assertTrue(one_url in json['urls'])
        self.assertTrue(json['urls'] in two_url)
        self.assertTrue(len(json['urls']) == 2)

        rv, json = self.client.get(next_url)
        self.assertTrue(rv.status_code == 200)
        self.assertTrue(three_url in json['urls'])
        self.assertTrue(four_url in json['urls'])
        self.assertTrue(len(json['urls']) == 2)
        next_url = json['meta']['next'].replace('http://localhost', '')

        rv, json = self.client.get(next_url)
        self.assertTrue(rv.status_code == 200)
        self.assertTrue(five_url in json['urls'])
        self.assertTrue(len(json['urls']) == 1)

        rv, json = self.client.get(last_url)
        self.assertTrue(rv.status_code == 200)
        self.assertTrue(five_url in json['urls'])
        self.assertTrue(len(json['urls']) == 1)
dataset/ETHPy150Open miguelgrinberg/api-pycon2014/tests/test_api.py/TestAPI.test_pagination/swapped operands of `in`