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