示例#1
0
 def test_create_object(self):
     count = Sponsor.objects.count()
     sponsor = Sponsor(name="Foo",
                       url="http://google.com",
                       logo=self.image.name)
     try:
         sponsor.full_clean()
     except ValidationError:
         self.fail("Full clean failed")
     sponsor.save()
     self.assertEqual(count + 1, Sponsor.objects.count())
示例#2
0
 def test_object_must_have_valid_url(self):
     sponsor = Sponsor(name="foo", logo=self.image.name, url="goo.baz")
     with self.assertRaises(ValidationError):
         sponsor.full_clean()
示例#3
0
 def test_do_not_need_url(self):
     count = Sponsor.objects.count()
     sponsor = Sponsor(name='foo', logo=self.image.name)
     sponsor.full_clean()
     sponsor.save()
     self.assertEqual(count + 1, Sponsor.objects.count())
示例#4
0
 def test_must_have_image(self):
     sponsor = Sponsor(url="http://google.com", name="foo")
     with self.assertRaises(ValidationError):
         sponsor.full_clean()
示例#5
0
 def test_object_must_have_name(self):
     sponsor = Sponsor(url="http://google.com", logo=self.image.name)
     with self.assertRaises(ValidationError):
         sponsor.full_clean()