def test_get_title(self): audition = AuditionFactory() self.assertEqual(audition.get_title(), u'Auditions') audition = AuditionFactory(title='Test Title') self.assertEqual(audition.get_title(), u'Test Title') audition = AuditionFactory(play=PlayFactory()) self.assertEqual(audition.get_title(), u'Auditions for {}'.format(str(audition.play))) audition = AuditionFactory( production_company=ProductionCompanyFactory()) self.assertEqual( audition.get_title(), u'Auditions for {}'.format(str(audition.production_company))) audition = AuditionFactory( play=PlayFactory(), production_company=ProductionCompanyFactory(), ) self.assertEqual( audition.get_title(), u'Auditions for {play}, by {company}'.format( play=str(audition.play), company=str(audition.production_company), ))
def test_save(self): audition = AuditionFactory(pk=None, title=None, slug=None) with patch('django.db.models.Model.save') as mock_save: audition.save() mock_save.assert_called_once_with() self.assertEqual(audition.title, audition.get_title()) self.assertEqual(audition.slug, audition.get_slug())
def test_unicode(self): audition = AuditionFactory() self.assertEqual(audition.__unicode__(), unicode(audition.get_title()))