Ejemplo n.º 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,
         '*****@*****.**')
Ejemplo n.º 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": "*****@*****.**"})
Ejemplo n.º 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': '*****@*****.**'})
Ejemplo n.º 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,
         '*****@*****.**')
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 8
0
 def test_error_invalid_user(self):
     self.form = EditThemeOwnerForm({'owner': '*****@*****.**'},
                                    instance=self.instance)
     eq_(self.form.is_valid(), False)
Ejemplo n.º 9
0
 def test_error_invalid_user(self):
     self.form = EditThemeOwnerForm({'owner': '*****@*****.**'},
                                    instance=self.instance)
     eq_(self.form.is_valid(), False)
Ejemplo n.º 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, "*****@*****.**")