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

        def create():
            body = json.dumps({
                "name": "CRUD test for recording",
            })
            self.login(admin_username, admin_password)
            response = self.client.post(path=api_url + "/recording/",
                                        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)
            in_json = json.loads(response.content)
            self.assertIn("id", in_json)
            self.recording_id = in_json['id']

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

        def update():
            body = json.dumps({
                "name": "CRUD test for recording, updated",
                "description": "description...",
            })
            self.login(admin_username, admin_password)
            response = self.client.put(path=api_url + "/recording/" + self.recording_id,
                                       data=body,
                                       content_type="application/json",
                                       HTTP_X_AUTH_TOKEN=self.x_auth_token)
            self.assertEqual(response.status_code, 200)

        def delete():
            self.login(admin_username, admin_password)
            response = self.client.delete(path=api_url + "/recording/" + self.recording_id,
                                          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("Testing DELETE in %s" % self.__class__)
        delete()
dataset/ETHPy150Open emccode/heliosburn/heliosburn/django/hbproject/api/tests.py/RecordingViewTestCase.test_crud/original