def test_link_or_page(self): """Test a validator: you can enter a url or a page_link, but not both.""" page_data = self.get_new_page_data() response = self.client.post(URL_CMS_PAGE_ADD, page_data) page = Page.objects.all()[0] picture = Picture(url="test") # Note: don't call full_clean as it will check ALL fields - including # the image, which we haven't defined. Call clean() instead which # just validates the url and page_link fields. picture.clean() picture.page_link = page picture.url = None picture.clean() picture.url = "test" self.assertRaises(ValidationError, picture.clean)