def test_create(self): """ Test create a review with the serializer """ serializer = ReviewSerializer(data=self.data) serializer.context = self.context serializer.is_valid(raise_exception=True) serializer.save() self.assertTrue(Review.objects.filter(**self.data).exists()) # Check the permissions perms = ('reviews.report_review', 'reviews.reply_review', 'reviews.read_review') self.activity.organizer.user.has_perms(perms)
def test_validate_calendar_initial_date(self): """ Now() should be grater than calendar.initial_date """ # Set the initial_date 10 days ahead self.order.calendar.initial_date = (now() + timedelta(days=10)).date() self.order.calendar.save() with self.assertRaisesMessage( ValidationError, "{'non_field_errors': ['La orden no cumple con los " "requerimientos para crear un review']}"): serializer = ReviewSerializer(data=self.data) serializer.context = self.context serializer.is_valid(raise_exception=True)