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