def test_from_endpoints(self): f1 = EndpointsField() self.assertEqual(f1.from_endpoints([u"foo", u"bar"]), u"foo,bar") self.assertEqual(f1.from_endpoints([]), u"") f2 = EndpointsField(separator=u"+") self.assertEqual(f2.from_endpoints([u"foo", u"bar"]), u"foo+bar")
def test_clean_two_endpoints(self): f = EndpointsField() self.assertEqual(f.clean(u"foo, bar"), [u"foo", u"bar"])
def test_clean_invalid_endpoint(self): f = EndpointsField() self.assertRaises(forms.ValidationError, f.clean, u"foo:bar")
def test_clean_invalid_type(self): f = EndpointsField() self.assertRaises(forms.ValidationError, f.clean, 5)
def test_clean_one_endpoint(self): f = EndpointsField() self.assertEqual(f.clean(u"foo"), [u"foo"])
def test_clean_none(self): f = EndpointsField() self.assertEqual(f.clean(None), [])
def test_clean_empty_string(self): f = EndpointsField() self.assertEqual(f.clean(""), [])