def test_get_slug(self): review = ReviewFactory(title='Test Review Title') self.assertEqual( review.get_slug(), u'unpublished-test-review-title', ) review.published_on = datetime(2017, 1, 3) self.assertEqual( review.get_slug(), u'20170103-test-review-title', )
def test_save(self): review = ReviewFactory(pk=None, title=None, slug=None) with patch('django.db.models.Model.save') as mock_save: review.save() self.assertEqual(review.title, review.get_title()) self.assertEqual(review.slug, review.get_slug()) mock_save.assert_called_once_with()