def test_classes(self):
        # get collection
        rv, json = self.client.get('/api/v1.0/classes/')
        self.assertTrue(rv.status_code == 200)
        self.assertTrue(json['urls'] == [])

        # create new
        rv, json = self.client.post('/api/v1.0/classes/',
                                    data={'name': 'algebra'})
        self.assertTrue(rv.status_code == 201)
        algebra_url = rv.headers['Location']

        # get
        rv, json = self.client.get(algebra_url)
        self.assertTrue(rv.status_code == 200)
        self.assertTrue(json['name'] == 'algebra')
        self.assertTrue(json['url'] == algebra_url)

        # create new
        rv, json = self.client.post('/api/v1.0/classes/',
                                    data={'name': 'lit'})
        self.assertTrue(rv.status_code == 201)
        lit_url = rv.headers['Location']

        # get
        rv, json = self.client.get(lit_url)
        self.assertTrue(rv.status_code == 200)
        self.assertTrue(json['name'] == 'lit')
        self.assertTrue(json['url'] == lit_url)

        # create bad
        rv,json = self.client.post('/api/v1.0/classes/', data={})
        self.assertTrue(rv.status_code == 400)

        self.assertRaises(ValidationError, lambda:
            self.client.post('/api/v1.0/classes/', data={'not-name': 'lit'}))

        # modify
        rv, json = self.client.put(lit_url, data={'name': 'lit2'})
        self.assertTrue(rv.status_code == 200)

        # get
        rv, json = self.client.get(lit_url)
        self.assertTrue(rv.status_code == 200)
        self.assertTrue(json['name'] == 'lit2')

        # get collection
        rv, json = self.client.get('/api/v1.0/classes/')
        self.assertTrue(rv.status_code == 200)
        self.assertTrue(algebra_url in json['urls'])
        self.assertTrue(lit_url in json['urls'])
        self.assertTrue(len(json['urls']) == 2)

        # delete
        rv, json = self.client.delete(lit_url)
        self.assertTrue(rv.status_code == 200)

        # get collection
        rv, json = self.client.get('/api/v1.0/classes/')
        self.assertTrue(rv.status_code == 200)
        self.assertTrue(json['urls'] in algebra_url)
        self.assertFalse(lit_url in json['urls'])
        self.assertTrue(len(json['urls']) == 1)
dataset/ETHPy150Open miguelgrinberg/api-pycon2014/tests/test_api.py/TestAPI.test_classes/swapped operands of `in`