Exemple #1
0
 def setUp(self):
     self.user = self.__create_test_user("user", "pass", True)
     self.client = PatchClient()
     create_basic_workflow(self)
     self.author = Author.objects.create(id=100, name="Test author",
         slug="1st")
     self.author_two = Author.objects.create(id=101, name="2nd author",
         slug="2nd")
    def setUp(self):
        self.client = PatchClient()
        create_basic_workflow(self)

        self.admin_user, self.banned_user, self.role_user = self.__create_test_users(self.test_role)

        self.article_model_ct = None
        self.photo_filename = self.__create_tmp_image(".test_image.jpg")

        self.new_author = json.dumps({
            "description": "this is descr.",
            "email": "*****@*****.**",
            "id": 100,
            "name": "dumb_name",
            "resource_uri": "/admin-api/author/100/",
            "slug": "dumb-name",
            "text": "this is text",
        })

        self.new_user = json.dumps({
            "email": "*****@*****.**",
            "first_name": "test",
            "id": 100,
            "is_staff": True,
            "is_superuser": True,
            "last_name": "user",
            "password": "******",
            "resource_uri": "/admin-api/user/100/",
            "username": "******",
        })

        self.new_category = json.dumps({
            "content": "this is content",
            "description": "this is a category description",
            "id": 100,
            "resource_uri": "/admin-api/category/100/",
            "site": "/admin-api/site/100/",
            "slug": "category1",
            "template": "category.html",
            "title": "category100",
            "tree_path": "category100",
            "app_data": None,
        })

        self.new_article = json.dumps({
            "authors": [{
                "description": "this is descr.",
                "email": "*****@*****.**",
                "id": 100,
                "name": "dumb_name",
                "resource_uri": "/admin-api/author/100/",
                "slug": "dumb-name",
                "text": "this is text",
            }],
            "category": "/admin-api/category/100/",
            "content": "this is awesome new-article content",
            "description": "this is awesome description",
            "id": 100,
            "publish_from": "2012-08-07T14:51:29",
            "publish_to": "2012-08-15T14:51:35",
            "resource_uri": "/admin-api/article/100/",
            "slug": "test-article",
            "title": "test_article",
            "app_data": None,
        })

        self.new_photo = {
            "title": "photo1",
            "authors": ["/admin-api/author/100/"],
            "image": "attached_object_id:" + os.path.basename(self.photo_filename),
            "id": 100,
            "resource_uri": "/admin-api/photo/100/",
            "description": "this is description",
            "app_data": None,
        }

        self.new_site = json.dumps({
            "domain": "test_domain.com",
            "id": 100,
            "name": "test_domain.com",
            "resource_uri": "/admin-api/site/100/",
        })

        self.new_format = json.dumps({
            "id": 100,
            "resource_uri": "/admin-api/format/100/",
            "flexible_height": False,
            "flexible_max_height": None,
            "max_height": 200,
            "max_width": 200,
            "name": "format_name",
            "nocrop": True,
            "resample_quality": 95,
            "sites": ["/admin-api/site/100/"],
            "stretch": True,
        })

        self.new_formatedphoto = json.dumps({
            "id": 100,
            "resource_uri": "/admin-api/formatedphoto/100/",
            "crop_height": 0,
            "crop_left": 0,
            "crop_top": 0,
            "crop_width": 0,
            "format": "/admin-api/format/100/",
            "height": 200,
            "photo": "/admin-api/photo/100/",
            "width": 200,
        })

        self.new_listing = json.dumps({
            "category": "/admin-api/category/100/",
            "commercial": "false",
            "id": 100,
            "publish_from": "2012-08-07T14:51:29",
            "publish_to": "2012-08-15T14:51:35",
            "resource_uri": "/admin-api/listing/100/",
            "publishable": "/admin-api/article/100/",
        })