def test_ads_all_inputs_missing(self): form = AdvertisementForm(data={}) self.assertFalse(form.is_valid()) self.assertEquals( len(form.errors), 4) # checks that all 4 errors occurred for missing fields
def test_ads_form_no_product_description(self): form = AdvertisementForm( data={ 'product_name': 'Car', 'price': 10, 'category': Category.objects.get(name='TestCategory') }) self.assertFalse(form.is_valid())
def test_ads_form_no_product_name(self): form = AdvertisementForm( data={ 'product_description': 'I want to sell my Chevrolet 1980 model', 'price': 10, 'category': Category.objects.get(name='TestCategory') }) self.assertFalse(form.is_valid())
def setUp(self): """Make an advertisement in test db""" form = AdvertisementForm( data={ 'product_name': 'Car', 'product_description': 'I want to sell my Chevrolet 1980 model', 'price': 1000000 }) self.factory = RequestFactory()