예제 #1
0
class SeparatedValuesFieldTestCase(amo.tests.TestCase):

    def setUp(self):
        super(SeparatedValuesFieldTestCase, self).setUp()
        self.field = SeparatedValuesField(forms.EmailField)

    def test_email_field(self):
        eq_(self.field.clean(u'[email protected], [email protected]'), u'[email protected], [email protected]')

    def test_email_field_w_empties(self):
        eq_(self.field.clean(u'[email protected],,   \n,[email protected]'), u'[email protected], [email protected]')

    def test_email_validation_error(self):
        with self.assertRaises(exceptions.ValidationError):
            self.field.clean(u'e')
        with self.assertRaises(exceptions.ValidationError):
            self.field.clean(u'[email protected], [email protected], e')

    def test_url_field(self):
        field = SeparatedValuesField(forms.URLField)
        eq_(field.clean(u'http://hy.fr/,,http://yo.lo'),
            u'http://hy.fr/, http://yo.lo/')

    def test_alt_separator(self):
        self.field = SeparatedValuesField(forms.EmailField, separator='#')
        eq_(self.field.clean(u'[email protected]#[email protected]'), u'[email protected], [email protected]')
예제 #2
0
class SeparatedValuesFieldTestCase(amo.tests.TestCase):

    def setUp(self):
        self.field = SeparatedValuesField(forms.EmailField)

    def test_email_field(self):
        eq_(self.field.clean(u'[email protected], [email protected]'), u'[email protected], [email protected]')

    def test_email_field_w_empties(self):
        eq_(self.field.clean(u'[email protected],,   \n,[email protected]'), u'[email protected], [email protected]')

    def test_email_validation_error(self):
        with self.assertRaises(exceptions.ValidationError):
            self.field.clean(u'e')
        with self.assertRaises(exceptions.ValidationError):
            self.field.clean(u'[email protected], [email protected], e')

    def test_url_field(self):
        field = SeparatedValuesField(forms.URLField)
        eq_(field.clean(u'http://hy.fr/,,http://yo.lo'),
            u'http://hy.fr/, http://yo.lo/')

    def test_alt_separator(self):
        self.field = SeparatedValuesField(forms.EmailField, separator='#')
        eq_(self.field.clean(u'[email protected]#[email protected]'), u'[email protected], [email protected]')
예제 #3
0
 def test_url_field(self):
     field = SeparatedValuesField(forms.URLField)
     eq_(field.clean(u'http://hy.fr/,,http://yo.lo'),
         u'http://hy.fr/, http://yo.lo/')
예제 #4
0
 def test_url_field(self):
     field = SeparatedValuesField(forms.URLField)
     eq_(field.clean(u'http://hy.fr/,,http://yo.lo'),
         u'http://hy.fr/, http://yo.lo/')