Example #1
0
 def test_cleans_title(self):
     form = forms.ProductReviewForm(product=self.product,
                                    user=self.reviewer,
                                    data=self.data)
     self.assertTrue(form.is_valid())
     review = form.save()
     self.assertEqual("This product is lovely", review.title)
Example #2
0
 def test_cleans_title(self):
     instance = self.product.reviews.model(
         product=self.product)
     form = forms.ProductReviewForm(data=self.data, instance=instance)
     self.assertTrue(form.is_valid())
     review = form.save()
     self.assertEquals("This product is lovely", review.title)
 def test_validates_correctly(self):
     data = {
         'title': 'This product is lovely',
         'body': 'I really like this cheese',
         'score': 0,
         'name': 'JR Hartley',
         'email': '*****@*****.**'
     }
     form = forms.ProductReviewForm(product=None, user=None, data=data)
     assert form.is_valid()
    def test_cleans_title(self):
        product = create_product()
        reviewer = UserFactory()
        data = {
            'title': '  This product is lovely',
            'body': 'I really like this cheese',
            'score': 0,
            'name': 'JR Hartley',
            'email': '*****@*****.**'
        }
        form = forms.ProductReviewForm(product=product,
                                       user=reviewer,
                                       data=data)

        assert form.is_valid()

        review = form.save()
        assert review.title == "This product is lovely"
Example #5
0
 def test_validates_empty_data_correctly(self):
     forms.ProductReviewForm(product=None, user=None, data={}).is_valid()
Example #6
0
 def form(self, **kwargs):
     data = self.data.copy()
     data.update(kwargs)
     return forms.ProductReviewForm(product=None, user=None, data=data)
Example #7
0
 def test_validates_empty_data_correctly(self):
     forms.ProductReviewForm(data={}).is_valid()