def test_crud(self):
        """
        Tests CRUD for user model.
        """
        import json

        def create():
            self.login(admin_username, admin_password)
            self.username = "crudtest"
            body = json.dumps({
                "username": self.username,
                "password": "CRUD test",
                "email": "test@test",
            })
            response = self.client.post(path=api_url + "/user/",
                                        data=body,
                                        content_type="application/json",
                                        HTTP_X_AUTH_TOKEN=self.x_auth_token)
            self.assertEqual(response.status_code, 200)
            self.assertIn("location", response._headers)

            self.login(test1_username, test1_password)
            response = self.client.post(path=api_url + "/user/",
                                        data=body,
                                        content_type="application/json",
                                        HTTP_X_AUTH_TOKEN=self.x_auth_token)
            self.assertEqual(response.status_code, 403)

        def read():
            self.login(admin_username, admin_password)
            response = self.client.get(path=api_url + "/user/" + self.username,
                                       HTTP_X_AUTH_TOKEN=self.x_auth_token)
            self.assertEqual(response.status_code, 200)

            response = self.client.get(path=api_url + "/user/",
                                       HTTP_X_AUTH_TOKEN=self.x_auth_token)
            self.assertEqual(response.status_code, 200)

            self.login(test1_username, test1_password)
            response = self.client.get(path=api_url + "/user/",
                                       HTTP_X_AUTH_TOKEN=self.x_auth_token)
            self.assertEqual(response.status_code, 403)

        def update():
            self.login(admin_username, admin_password)
            body = json.dumps({"email": "test1@test1"})
            response = self.client.put(path=api_url + "/user/" + self.username,
                                       data=body,
                                       content_type="application/json",
                                       HTTP_X_AUTH_TOKEN=self.x_auth_token)
            self.assertEqual(response.status_code, 200)

            self.login(test1_username, test1_password)
            response = self.client.put(path=api_url + "/user/" + self.username,
                                     data=body,
                                     content_type="application/json",
                                     HTTP_X_AUTH_TOKEN=self.x_auth_token)
            self.assertEqual(response.status_code, 403)

        def delete():
            self.login(test1_username, test1_password)
            response = self.client.delete(path=api_url + "/user/" + self.username,
                                          HTTP_X_AUTH_TOKEN=self.x_auth_token)
            self.assertEqual(response.status_code, 403)

            self.login(admin_username, admin_password)
            response = self.client.delete(path=api_url + "/user/" + self.username,
                                          HTTP_X_AUTH_TOKEN=self.x_auth_token)
            self.assertEqual(response.status_code, 200)


        print("Testing CREATE in %s" % self.__class__)
        create()

        print("Testing READ in %s" % self.__class__)
        read()

        print("Testing UPDATE in %s" % self.__class__)
        update()

        print(self.__class__ % "Testing DELETE in %s")
        delete()
dataset/ETHPy150Open emccode/heliosburn/heliosburn/django/hbproject/api/tests.py/UserViewTestCase.test_crud/swapped operands of `%`