当前位置: 首页>>代码示例>>Python>>正文


Python forms.EditThemeForm类代码示例

本文整理汇总了Python中addons.forms.EditThemeForm的典型用法代码示例。如果您正苦于以下问题:Python EditThemeForm类的具体用法?Python EditThemeForm怎么用?Python EditThemeForm使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了EditThemeForm类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_localize_name_description

 def test_localize_name_description(self):
     data = self.get_dict(name_de='name_de',
                          description_de='description_de')
     self.form = EditThemeForm(data, request=self.request,
                               instance=self.instance)
     eq_(self.form.is_valid(), True, self.form.errors)
     self.form.save()
开发者ID:srachit,项目名称:olympia,代码行数:7,代码来源:test_forms.py

示例2: test_reupload

    def test_reupload(self, save_persona_image_mock,
                      create_persona_preview_images_mock,
                      make_checksum_mock):
        make_checksum_mock.return_value = 'checksumbeforeyouwrecksome'
        data = self.get_dict(header_hash='y0l0', footer_hash='abab')
        self.form = EditThemeForm(data, request=self.request,
                                  instance=self.instance)
        eq_(self.form.is_valid(), True)
        self.form.save()

        dst = os.path.join(user_media_path('addons'), str(self.instance.id))
        header_src = os.path.join(settings.TMP_PATH, 'persona_header',
                                  u'y0l0')
        footer_src = os.path.join(settings.TMP_PATH, 'persona_footer',
                                  u'abab')

        eq_(save_persona_image_mock.mock_calls,
            [mock.call(src=header_src,
                       full_dst=os.path.join(dst, 'pending_header.png')),
             mock.call(src=footer_src,
                       full_dst=os.path.join(dst, 'pending_footer.png'))])

        rqt = RereviewQueueTheme.objects.filter(theme=self.instance.persona)
        eq_(rqt.count(), 1)
        eq_(rqt[0].header, 'pending_header.png')
        eq_(rqt[0].footer, 'pending_footer.png')
        assert not rqt[0].dupe_persona
开发者ID:srachit,项目名称:olympia,代码行数:27,代码来源:test_forms.py

示例3: test_initial

    def test_initial(self):
        self.form = EditThemeForm(None, request=self.request, instance=self.instance)

        # Compare form initial data with post data.
        eq_data = self.get_dict()
        for k in [k for k in self.form.initial.keys() if k not in ["name", "description"]]:
            eq_(self.form.initial[k], eq_data[k])
开发者ID:abhiii5459,项目名称:olympia,代码行数:7,代码来源:test_forms.py

示例4: save_success

    def save_success(self):
        other_cat = Category.objects.create(type=amo.ADDON_PERSONA)
        self.data = {
            'accentcolor': '#EFF0FF',
            'category': other_cat.id,
            'license': amo.LICENSE_CC_BY_NC_SA.id,
            'slug': 'swag-lifestyle',
            'tags': 'ag',
            'textcolor': '#CACACA',

            'name_en-us': 'All Day I Dream About Swag',
            'description_en-us': 'ADIDAS',
        }
        self.form = EditThemeForm(self.data, request=self.request,
                                  instance=self.instance)

        # Compare form initial data with post data.
        eq_data = self.get_dict()
        for k in [k for k in self.form.initial.keys()
                  if k not in ['name', 'description']]:
            eq_(self.form.initial[k], eq_data[k])

        eq_(self.form.data, self.data)
        eq_(self.form.is_valid(), True, self.form.errors)
        self.form.save()
开发者ID:srachit,项目名称:olympia,代码行数:25,代码来源:test_forms.py

示例5: test_name_unique

 def test_name_unique(self):
     data = self.get_dict(name='Bands Make You Dance')
     Addon.objects.create(type=amo.ADDON_PERSONA, status=amo.STATUS_PUBLIC,
                          name=data['name'])
     self.form = EditThemeForm(data, request=self.request,
                               instance=self.instance)
     eq_(self.form.is_valid(), False)
     eq_(self.form.errors,
         {'name': ['This name is already in use. Please choose another.']})
开发者ID:JohnTheBeloved,项目名称:zamboni,代码行数:9,代码来源:test_forms.py

示例6: test_reupload_duplicate

    def test_reupload_duplicate(self, make_checksum_mock):
        make_checksum_mock.return_value = "checksumbeforeyouwrecksome"

        theme = amo.tests.addon_factory(type=amo.ADDON_PERSONA)
        theme.persona.checksum = "checksumbeforeyouwrecksome"
        theme.persona.save()

        data = self.get_dict(header_hash="head", footer_hash="foot")
        self.form = EditThemeForm(data, request=self.request, instance=self.instance)
        eq_(self.form.is_valid(), True)
        self.form.save()

        rqt = RereviewQueueTheme.objects.get(theme=self.instance.persona)
        eq_(rqt.dupe_persona, theme.persona)
开发者ID:abhiii5459,项目名称:olympia,代码行数:14,代码来源:test_forms.py

示例7: save_success

 def save_success(self):
     other_cat = Category.objects.create(type=amo.ADDON_PERSONA)
     self.data = {
         'accentcolor': '#EFF0FF',
         'category': other_cat.id,
         'license': amo.LICENSE_CC_BY_NC_SA.id,
         'name': 'All Day I Dream About Swag',
         'slug': 'swag-lifestyle',
         'summary': 'ADIDAS',
         'tags': 'ag',
         'textcolor': '#CACACA'
     }
     self.form = EditThemeForm(self.data, request=self.request,
                               instance=self.instance)
     eq_(self.form.initial, self.get_dict())
     eq_(self.form.data, self.data)
     eq_(self.form.is_valid(), True, self.form.errors)
     self.form.save()
开发者ID:JohnTheBeloved,项目名称:zamboni,代码行数:18,代码来源:test_forms.py

示例8: save_success

    def save_success(self):
        other_cat = Category.objects.create(type=amo.ADDON_PERSONA)
        self.data = {
            "accentcolor": "#EFF0FF",
            "category": other_cat.id,
            "license": amo.LICENSE_CC_BY_NC_SA.id,
            "slug": "swag-lifestyle",
            "tags": "ag",
            "textcolor": "#CACACA",
            "name_en-us": "All Day I Dream About Swag",
            "description_en-us": "ADIDAS",
        }
        self.form = EditThemeForm(self.data, request=self.request, instance=self.instance)

        # Compare form initial data with post data.
        eq_data = self.get_dict()
        for k in [k for k in self.form.initial.keys() if k not in ["name", "description"]]:
            eq_(self.form.initial[k], eq_data[k])

        eq_(self.form.data, self.data)
        eq_(self.form.is_valid(), True, self.form.errors)
        self.form.save()
开发者ID:abhiii5459,项目名称:olympia,代码行数:22,代码来源:test_forms.py

示例9: test_reupload_legacy_header_only

    def test_reupload_legacy_header_only(self):
        """
        STR the bug this test fixes:

        - Reupload a legacy theme (/w footer == leg.png) legacy, header only.
        - The header would get saved as 'pending_header.png'.
        - The footer would get saved as 'footer.png'.
        - On approving, it would see 'footer.png' !== 'leg.png'
        - It run move_stored_file('footer.png', 'leg.png').
        - But footer.png does not exist. BAM BUG.
        """
        self.theme.header = "Legacy-header3H.png"
        self.theme.footer = "Legacy-footer3H-Copy.jpg"
        self.theme.save()

        data = self.get_dict(header_hash="arthro")
        self.form = EditThemeForm(data, request=self.request, instance=self.instance)
        eq_(self.form.is_valid(), True)
        self.form.save()

        rqt = RereviewQueueTheme.objects.get()
        eq_(rqt.header, "pending_header.png")
        eq_(rqt.footer, "Legacy-footer3H-Copy.jpg")
开发者ID:abhiii5459,项目名称:olympia,代码行数:23,代码来源:test_forms.py

示例10: TestEditThemeForm

class TestEditThemeForm(amo.tests.TestCase):
    fixtures = ['base/user_2519']

    def setUp(self):
        self.populate()
        self.request = mock.Mock()
        self.request.groups = ()
        self.request.amo_user = mock.Mock()
        self.request.amo_user.username = 'swagyismymiddlename'
        self.request.amo_user.name = 'Sir Swag A Lot'
        self.request.amo_user.is_authenticated.return_value = True

    def populate(self):
        self.instance = Addon.objects.create(
            type=amo.ADDON_PERSONA, status=amo.STATUS_PUBLIC,
            slug='swag-overload', name='Bands Make Me Dance',
            description='tha description')
        self.cat = Category.objects.create(
            type=amo.ADDON_PERSONA, name='xxxx')
        self.instance.addoncategory_set.create(category=self.cat)
        self.license = amo.LICENSE_CC_BY.id
        self.theme = Persona.objects.create(
            persona_id=0, addon_id=self.instance.id, license=self.license,
            accentcolor='C0FFEE', textcolor='EFFFFF')
        Tag(tag_text='sw').save_tag(self.instance)
        Tag(tag_text='ag').save_tag(self.instance)

    def get_dict(self, **kw):
        data = {
            'accentcolor': '#C0FFEE',
            'category': self.cat.id,
            'license': self.license,
            'slug': self.instance.slug,
            'tags': 'ag, sw',
            'textcolor': '#EFFFFF',

            'name_en-us': unicode(self.instance.name),
            'description_en-us': unicode(self.instance.description),
        }
        data.update(**kw)
        return data

    def test_initial(self):
        self.form = EditThemeForm(None, request=self.request,
                                  instance=self.instance)

        # Compare form initial data with post data.
        eq_data = self.get_dict()
        for k in [k for k in self.form.initial.keys()
                  if k not in ['name', 'description']]:
            eq_(self.form.initial[k], eq_data[k])

    def save_success(self):
        other_cat = Category.objects.create(type=amo.ADDON_PERSONA)
        self.data = {
            'accentcolor': '#EFF0FF',
            'category': other_cat.id,
            'license': amo.LICENSE_CC_BY_NC_SA.id,
            'slug': 'swag-lifestyle',
            'tags': 'ag',
            'textcolor': '#CACACA',

            'name_en-us': 'All Day I Dream About Swag',
            'description_en-us': 'ADIDAS',
        }
        self.form = EditThemeForm(self.data, request=self.request,
                                  instance=self.instance)

        # Compare form initial data with post data.
        eq_data = self.get_dict()
        for k in [k for k in self.form.initial.keys()
                  if k not in ['name', 'description']]:
            eq_(self.form.initial[k], eq_data[k])

        eq_(self.form.data, self.data)
        eq_(self.form.is_valid(), True, self.form.errors)
        self.form.save()

    def test_success(self):
        self.save_success()
        self.instance = self.instance.reload()
        eq_(unicode(self.instance.persona.accentcolor),
            self.data['accentcolor'].lstrip('#'))
        eq_(self.instance.categories.all()[0].id, self.data['category'])
        eq_(self.instance.persona.license, self.data['license'])
        eq_(unicode(self.instance.name), self.data['name_en-us'])
        eq_(unicode(self.instance.description), self.data['description_en-us'])
        self.assertSetEqual(
            self.instance.tags.values_list('tag_text', flat=True),
            [self.data['tags']])
        eq_(unicode(self.instance.persona.textcolor),
            self.data['textcolor'].lstrip('#'))

    def test_success_twice(self):
        """Form should be just fine when POSTing twice."""
        self.save_success()
        self.form.save()

    def test_name_unique(self):
        data = self.get_dict(**{'name_en-us': 'Bands Make You Dance'})
#.........这里部分代码省略.........
开发者ID:srachit,项目名称:olympia,代码行数:101,代码来源:test_forms.py

示例11: test_initial

 def test_initial(self):
     self.form = EditThemeForm(None, request=self.request,
                               instance=self.instance)
     eq_(self.form.initial, self.get_dict())
开发者ID:JohnTheBeloved,项目名称:zamboni,代码行数:4,代码来源:test_forms.py

示例12: TestEditThemeForm

class TestEditThemeForm(amo.tests.TestCase):
    fixtures = ['base/apps', 'base/user_2519']

    def setUp(self):
        self.populate()
        self.request = mock.Mock()
        self.request.groups = ()
        self.request.amo_user = mock.Mock()
        self.request.amo_user.username = 'swagyismymiddlename'
        self.request.amo_user.name = 'Sir Swag A Lot'
        self.request.amo_user.is_authenticated.return_value = True

    def populate(self):
        self.instance = Addon.objects.create(
            type=amo.ADDON_PERSONA, status=amo.STATUS_PUBLIC,
            slug='swag-overload', name='Bands Make Me Dance',
            summary='tha summary')
        self.cat = Category.objects.create(
            type=amo.ADDON_PERSONA, name='xxxx')
        self.instance.addoncategory_set.create(category=self.cat)
        self.license = amo.LICENSE_CC_BY.id
        Persona.objects.create(
            persona_id=0, addon_id=self.instance.id, license=self.license,
            accentcolor='C0FFEE', textcolor='EFFFFF')
        Tag(tag_text='sw').save_tag(self.instance)
        Tag(tag_text='ag').save_tag(self.instance)

    def get_dict(self, **kw):
        data = {
            'accentcolor': '#C0FFEE',
            'category': self.cat.id,
            'license': self.license,
            'name': unicode(self.instance.name),
            'slug': self.instance.slug,
            'summary': self.instance.summary,
            'tags': 'ag, sw',
            'textcolor': '#EFFFFF'
        }
        data.update(**kw)
        return data

    def test_initial(self):
        self.form = EditThemeForm(None, request=self.request,
                                  instance=self.instance)
        eq_(self.form.initial, self.get_dict())

    def save_success(self):
        other_cat = Category.objects.create(type=amo.ADDON_PERSONA)
        self.data = {
            'accentcolor': '#EFF0FF',
            'category': other_cat.id,
            'license': amo.LICENSE_CC_BY_NC_SA.id,
            'name': 'All Day I Dream About Swag',
            'slug': 'swag-lifestyle',
            'summary': 'ADIDAS',
            'tags': 'ag',
            'textcolor': '#CACACA'
        }
        self.form = EditThemeForm(self.data, request=self.request,
                                  instance=self.instance)
        eq_(self.form.initial, self.get_dict())
        eq_(self.form.data, self.data)
        eq_(self.form.is_valid(), True, self.form.errors)
        self.form.save()

    def test_success(self):
        self.save_success()
        self.instance = self.instance.reload()
        eq_(unicode(self.instance.persona.accentcolor),
            self.data['accentcolor'].lstrip('#'))
        eq_(self.instance.categories.all()[0].id, self.data['category'])
        eq_(self.instance.persona.license, self.data['license'])
        eq_(unicode(self.instance.name), self.data['name'])
        eq_(unicode(self.instance.summary), self.data['summary'])
        self.assertSetEqual(
            self.instance.tags.values_list('tag_text', flat=True),
            [self.data['tags']])
        eq_(unicode(self.instance.persona.textcolor),
            self.data['textcolor'].lstrip('#'))

    def test_success_twice(self):
        """Form should be just fine when POSTing twice."""
        self.save_success()
        self.form.save()

    def test_name_unique(self):
        data = self.get_dict(name='Bands Make You Dance')
        Addon.objects.create(type=amo.ADDON_PERSONA, status=amo.STATUS_PUBLIC,
                             name=data['name'])
        self.form = EditThemeForm(data, request=self.request,
                                  instance=self.instance)
        eq_(self.form.is_valid(), False)
        eq_(self.form.errors,
            {'name': ['This name is already in use. Please choose another.']})

    @mock.patch('addons.tasks.make_checksum')
    @mock.patch('addons.tasks.create_persona_preview_images')
    @mock.patch('addons.tasks.save_persona_image')
    def test_reupload(self, save_persona_image_mock,
                      create_persona_preview_images_mock,
#.........这里部分代码省略.........
开发者ID:JohnTheBeloved,项目名称:zamboni,代码行数:101,代码来源:test_forms.py

示例13: TestEditThemeForm

class TestEditThemeForm(amo.tests.TestCase):
    fixtures = ['base/apps', 'base/user_2519']

    def setUp(self):
        self.populate()
        self.request = mock.Mock()
        self.request.groups = ()
        self.request.amo_user = mock.Mock()
        self.request.amo_user.username = 'swagyismymiddlename'
        self.request.amo_user.name = 'Sir Swag A Lot'
        self.request.amo_user.is_authenticated.return_value = True

    def populate(self):
        self.instance = Addon.objects.create(type=amo.ADDON_PERSONA,
            status=amo.STATUS_PUBLIC, slug='swag-overload',
            name='Bands Make Me Dance', summary='tha summary')
        self.cat = Category.objects.create(
            type=amo.ADDON_PERSONA, name='xxxx')
        self.instance.addoncategory_set.create(category=self.cat)
        self.license = amo.LICENSE_CC_BY.id
        Persona.objects.create(persona_id=0, addon_id=self.instance.id,
            license=self.license, accentcolor='C0FFEE', textcolor='EFFFFF')
        Tag(tag_text='sw').save_tag(self.instance)
        Tag(tag_text='ag').save_tag(self.instance)

    def get_dict(self, **kw):
        data = {
            'accentcolor': '#C0FFEE',
            'category': self.cat.id,
            'license': self.license,
            'name': unicode(self.instance.name),
            'slug': self.instance.slug,
            'summary': self.instance.summary.id,
            'tags': 'ag, sw',
            'textcolor': '#EFFFFF'
        }
        data.update(**kw)
        return data

    def test_initial(self):
        self.form = EditThemeForm(None, request=self.request,
                                  instance=self.instance)
        eq_(self.form.initial, self.get_dict())

    def save_success(self):
        other_cat = Category.objects.create(type=amo.ADDON_PERSONA)
        self.data = {
            'accentcolor': '#EFF0FF',
            'category': other_cat.id,
            'license': amo.LICENSE_CC_BY_NC_SA.id,
            'name': 'All Day I Dream About Swag',
            'slug': 'swag-lifestyle',
            'summary': 'ADIDAS',
            'tags': 'ag',
            'textcolor': '#CACACA'
        }
        self.form = EditThemeForm(self.data, request=self.request,
                                  instance=self.instance)
        eq_(self.form.initial, self.get_dict())
        eq_(self.form.data, self.data)
        eq_(self.form.is_valid(), True, self.form.errors)
        self.form.save()

    def test_success(self):
        self.save_success()
        self.instance = self.instance.reload()
        eq_(unicode(self.instance.persona.accentcolor),
            self.data['accentcolor'].lstrip('#'))
        eq_(self.instance.categories.all()[0].id, self.data['category'])
        eq_(self.instance.persona.license, self.data['license'])
        eq_(unicode(self.instance.name), self.data['name'])
        eq_(unicode(self.instance.summary), self.data['summary'])
        self.assertSetEqual(
            self.instance.tags.values_list('tag_text', flat=True),
            [self.data['tags']])
        eq_(unicode(self.instance.persona.textcolor),
            self.data['textcolor'].lstrip('#'))

    def test_success_twice(self):
        """Form should be just fine when POSTing twice."""
        self.save_success()
        self.form.save()

    def test_name_unique(self):
        data = self.get_dict(name='Bands Make You Dance')
        Addon.objects.create(type=amo.ADDON_PERSONA,
            status=amo.STATUS_PUBLIC, name=data['name'])
        self.form = EditThemeForm(data, request=self.request,
                                  instance=self.instance)
        eq_(self.form.is_valid(), False)
        eq_(self.form.errors,
            {'name': ['This name is already in use. Please choose another.']})
开发者ID:jvillalobos,项目名称:zamboni,代码行数:92,代码来源:test_forms.py

示例14: test_name_unique

 def test_name_unique(self):
     data = self.get_dict(**{"name_en-us": "Bands Make You Dance"})
     Addon.objects.create(type=amo.ADDON_PERSONA, status=amo.STATUS_PUBLIC, name=data["name_en-us"])
     self.form = EditThemeForm(data, request=self.request, instance=self.instance)
     eq_(self.form.is_valid(), False)
     eq_(self.form.errors, {"name": [("en-us", "This name is already in use. Please choose another.")]})
开发者ID:abhiii5459,项目名称:olympia,代码行数:6,代码来源:test_forms.py

示例15: TestEditThemeForm

class TestEditThemeForm(amo.tests.TestCase):
    fixtures = ["base/user_2519"]

    def setUp(self):
        self.populate()
        self.request = mock.Mock()
        self.request.groups = ()
        self.request.amo_user = mock.Mock()
        self.request.amo_user.username = "swagyismymiddlename"
        self.request.amo_user.name = "Sir Swag A Lot"
        self.request.amo_user.is_authenticated.return_value = True

    def populate(self):
        self.instance = Addon.objects.create(
            type=amo.ADDON_PERSONA,
            status=amo.STATUS_PUBLIC,
            slug="swag-overload",
            name="Bands Make Me Dance",
            description="tha description",
        )
        self.cat = Category.objects.create(type=amo.ADDON_PERSONA, name="xxxx")
        self.instance.addoncategory_set.create(category=self.cat)
        self.license = amo.LICENSE_CC_BY.id
        self.theme = Persona.objects.create(
            persona_id=0, addon_id=self.instance.id, license=self.license, accentcolor="C0FFEE", textcolor="EFFFFF"
        )
        Tag(tag_text="sw").save_tag(self.instance)
        Tag(tag_text="ag").save_tag(self.instance)

    def get_dict(self, **kw):
        data = {
            "accentcolor": "#C0FFEE",
            "category": self.cat.id,
            "license": self.license,
            "slug": self.instance.slug,
            "tags": "ag, sw",
            "textcolor": "#EFFFFF",
            "name_en-us": unicode(self.instance.name),
            "description_en-us": unicode(self.instance.description),
        }
        data.update(**kw)
        return data

    def test_initial(self):
        self.form = EditThemeForm(None, request=self.request, instance=self.instance)

        # Compare form initial data with post data.
        eq_data = self.get_dict()
        for k in [k for k in self.form.initial.keys() if k not in ["name", "description"]]:
            eq_(self.form.initial[k], eq_data[k])

    def save_success(self):
        other_cat = Category.objects.create(type=amo.ADDON_PERSONA)
        self.data = {
            "accentcolor": "#EFF0FF",
            "category": other_cat.id,
            "license": amo.LICENSE_CC_BY_NC_SA.id,
            "slug": "swag-lifestyle",
            "tags": "ag",
            "textcolor": "#CACACA",
            "name_en-us": "All Day I Dream About Swag",
            "description_en-us": "ADIDAS",
        }
        self.form = EditThemeForm(self.data, request=self.request, instance=self.instance)

        # Compare form initial data with post data.
        eq_data = self.get_dict()
        for k in [k for k in self.form.initial.keys() if k not in ["name", "description"]]:
            eq_(self.form.initial[k], eq_data[k])

        eq_(self.form.data, self.data)
        eq_(self.form.is_valid(), True, self.form.errors)
        self.form.save()

    def test_success(self):
        self.save_success()
        self.instance = self.instance.reload()
        eq_(unicode(self.instance.persona.accentcolor), self.data["accentcolor"].lstrip("#"))
        eq_(self.instance.categories.all()[0].id, self.data["category"])
        eq_(self.instance.persona.license, self.data["license"])
        eq_(unicode(self.instance.name), self.data["name_en-us"])
        eq_(unicode(self.instance.description), self.data["description_en-us"])
        self.assertSetEqual(self.instance.tags.values_list("tag_text", flat=True), [self.data["tags"]])
        eq_(unicode(self.instance.persona.textcolor), self.data["textcolor"].lstrip("#"))

    def test_success_twice(self):
        """Form should be just fine when POSTing twice."""
        self.save_success()
        self.form.save()

    def test_name_unique(self):
        data = self.get_dict(**{"name_en-us": "Bands Make You Dance"})
        Addon.objects.create(type=amo.ADDON_PERSONA, status=amo.STATUS_PUBLIC, name=data["name_en-us"])
        self.form = EditThemeForm(data, request=self.request, instance=self.instance)
        eq_(self.form.is_valid(), False)
        eq_(self.form.errors, {"name": [("en-us", "This name is already in use. Please choose another.")]})

    def test_localize_name_description(self):
        data = self.get_dict(name_de="name_de", description_de="description_de")
        self.form = EditThemeForm(data, request=self.request, instance=self.instance)
#.........这里部分代码省略.........
开发者ID:abhiii5459,项目名称:olympia,代码行数:101,代码来源:test_forms.py


注:本文中的addons.forms.EditThemeForm类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。