Example #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())
Example #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()
Example #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())
Example #4
0
 def test_must_have_image(self):
     sponsor = Sponsor(url="http://google.com", name="foo")
     with self.assertRaises(ValidationError):
         sponsor.full_clean()
Example #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()