예제 #1
0
 def test_success_change_from_no_owner(self):
     self.form = EditThemeOwnerForm({'owner': '*****@*****.**'},
                                    instance=self.instance)
     eq_(self.form.is_valid(), True, self.form.errors)
     self.form.save()
     eq_(self.instance.addonuser_set.all()[0].user.email,
         '*****@*****.**')
예제 #2
0
    def test_initial(self):
        self.form = EditThemeOwnerForm(None, instance=self.instance)
        eq_(self.form.initial, {})

        self.instance.addonuser_set.create(user_id=999)
        eq_(self.instance.addonuser_set.all()[0].user.email, "*****@*****.**")
        self.form = EditThemeOwnerForm(None, instance=self.instance)
        eq_(self.form.initial, {"owner": "*****@*****.**"})
예제 #3
0
    def test_initial(self):
        self.form = EditThemeOwnerForm(None, instance=self.instance)
        eq_(self.form.initial, {})

        self.instance.addonuser_set.create(user_id=999)
        eq_(self.instance.addonuser_set.all()[0].user.email,
            '*****@*****.**')
        self.form = EditThemeOwnerForm(None, instance=self.instance)
        eq_(self.form.initial, {'owner': '*****@*****.**'})
예제 #4
0
 def test_success_change_from_no_owner(self):
     self.form = EditThemeOwnerForm({'owner': '*****@*****.**'},
                                    instance=self.instance)
     eq_(self.form.is_valid(), True, self.form.errors)
     self.form.save()
     eq_(self.instance.addonuser_set.all()[0].user.email,
         '*****@*****.**')
예제 #5
0
class TestEditThemeOwnerForm(amo.tests.TestCase):
    fixtures = ['base/users']

    def setUp(self):
        super(TestEditThemeOwnerForm, self).setUp()
        self.instance = Addon.objects.create(type=amo.ADDON_PERSONA,
                                             status=amo.STATUS_PUBLIC,
                                             slug='swag-overload',
                                             name='Bands Make Me Dance',
                                             description='tha description')
        Persona.objects.create(persona_id=0,
                               addon_id=self.instance.id,
                               license=amo.LICENSE_CC_BY.id,
                               accentcolor='C0FFEE',
                               textcolor='EFFFFF')

    def test_initial(self):
        self.form = EditThemeOwnerForm(None, instance=self.instance)
        eq_(self.form.initial, {})

        self.instance.addonuser_set.create(user_id=999)
        eq_(self.instance.addonuser_set.all()[0].user.email,
            '*****@*****.**')
        self.form = EditThemeOwnerForm(None, instance=self.instance)
        eq_(self.form.initial, {'owner': '*****@*****.**'})

    def test_success_change_from_no_owner(self):
        self.form = EditThemeOwnerForm({'owner': '*****@*****.**'},
                                       instance=self.instance)
        eq_(self.form.is_valid(), True, self.form.errors)
        self.form.save()
        eq_(self.instance.addonuser_set.all()[0].user.email,
            '*****@*****.**')

    def test_success_replace_owner(self):
        self.instance.addonuser_set.create(user_id=999)
        self.form = EditThemeOwnerForm({'owner': '*****@*****.**'},
                                       instance=self.instance)
        eq_(self.form.is_valid(), True, self.form.errors)
        self.form.save()
        eq_(self.instance.addonuser_set.all()[0].user.email,
            '*****@*****.**')

    def test_error_invalid_user(self):
        self.form = EditThemeOwnerForm({'owner': '*****@*****.**'},
                                       instance=self.instance)
        eq_(self.form.is_valid(), False)
예제 #6
0
class TestEditThemeOwnerForm(amo.tests.TestCase):
    fixtures = ['base/users']

    def setUp(self):
        super(TestEditThemeOwnerForm, self).setUp()
        self.instance = Addon.objects.create(
            type=amo.ADDON_PERSONA,
            status=amo.STATUS_PUBLIC, slug='swag-overload',
            name='Bands Make Me Dance', description='tha description')
        Persona.objects.create(
            persona_id=0, addon_id=self.instance.id,
            license=amo.LICENSE_CC_BY.id, accentcolor='C0FFEE',
            textcolor='EFFFFF')

    def test_initial(self):
        self.form = EditThemeOwnerForm(None, instance=self.instance)
        eq_(self.form.initial, {})

        self.instance.addonuser_set.create(user_id=999)
        eq_(self.instance.addonuser_set.all()[0].user.email,
            '*****@*****.**')
        self.form = EditThemeOwnerForm(None, instance=self.instance)
        eq_(self.form.initial, {'owner': '*****@*****.**'})

    def test_success_change_from_no_owner(self):
        self.form = EditThemeOwnerForm({'owner': '*****@*****.**'},
                                       instance=self.instance)
        eq_(self.form.is_valid(), True, self.form.errors)
        self.form.save()
        eq_(self.instance.addonuser_set.all()[0].user.email,
            '*****@*****.**')

    def test_success_replace_owner(self):
        self.instance.addonuser_set.create(user_id=999)
        self.form = EditThemeOwnerForm({'owner': '*****@*****.**'},
                                       instance=self.instance)
        eq_(self.form.is_valid(), True, self.form.errors)
        self.form.save()
        eq_(self.instance.addonuser_set.all()[0].user.email,
            '*****@*****.**')

    def test_error_invalid_user(self):
        self.form = EditThemeOwnerForm({'owner': '*****@*****.**'},
                                       instance=self.instance)
        eq_(self.form.is_valid(), False)
예제 #7
0
class TestEditThemeOwnerForm(amo.tests.TestCase):
    fixtures = ["base/users"]

    def setUp(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",
        )
        Persona.objects.create(
            persona_id=0,
            addon_id=self.instance.id,
            license=amo.LICENSE_CC_BY.id,
            accentcolor="C0FFEE",
            textcolor="EFFFFF",
        )

    def test_initial(self):
        self.form = EditThemeOwnerForm(None, instance=self.instance)
        eq_(self.form.initial, {})

        self.instance.addonuser_set.create(user_id=999)
        eq_(self.instance.addonuser_set.all()[0].user.email, "*****@*****.**")
        self.form = EditThemeOwnerForm(None, instance=self.instance)
        eq_(self.form.initial, {"owner": "*****@*****.**"})

    def test_success_change_from_no_owner(self):
        self.form = EditThemeOwnerForm({"owner": "*****@*****.**"}, instance=self.instance)
        eq_(self.form.is_valid(), True, self.form.errors)
        self.form.save()
        eq_(self.instance.addonuser_set.all()[0].user.email, "*****@*****.**")

    def test_success_replace_owner(self):
        self.instance.addonuser_set.create(user_id=999)
        self.form = EditThemeOwnerForm({"owner": "*****@*****.**"}, instance=self.instance)
        eq_(self.form.is_valid(), True, self.form.errors)
        self.form.save()
        eq_(self.instance.addonuser_set.all()[0].user.email, "*****@*****.**")

    def test_error_invalid_user(self):
        self.form = EditThemeOwnerForm({"owner": "*****@*****.**"}, instance=self.instance)
        eq_(self.form.is_valid(), False)
예제 #8
0
 def test_error_invalid_user(self):
     self.form = EditThemeOwnerForm({'owner': '*****@*****.**'},
                                    instance=self.instance)
     eq_(self.form.is_valid(), False)
예제 #9
0
 def test_error_invalid_user(self):
     self.form = EditThemeOwnerForm({'owner': '*****@*****.**'},
                                    instance=self.instance)
     eq_(self.form.is_valid(), False)
예제 #10
0
 def test_success_replace_owner(self):
     self.instance.addonuser_set.create(user_id=999)
     self.form = EditThemeOwnerForm({"owner": "*****@*****.**"}, instance=self.instance)
     eq_(self.form.is_valid(), True, self.form.errors)
     self.form.save()
     eq_(self.instance.addonuser_set.all()[0].user.email, "*****@*****.**")