Пример #1
0
 def test_slugs_are_of_appropriate_size(self):
     """
     Song slug must not exceed the specified length.
     """
     slug_length = 5
     song = Song(title='Random Song', artist=create_artist())
     song.save(slug_max_length=slug_length)
     self.assertLessEqual(len(song.slug), slug_length)
Пример #2
0
 def test_slugs_are_unique(self):
     """
     Song slugs must be always unique, even when they have the same title.
     """
     song1 = create_song()
     song2 = Song(title=song1.title, artist=song1.artist)
     song2.save()
     self.assertNotEqual(song1.slug, song2.slug)
Пример #3
0
def create_song(title='Random Song', artist=None, sender=None, published=True,
                tabs=False, genre=None):
    song = Song(title=title, artist=artist, sender=sender, tabs=tabs)
    if published:
        song.publish()
    if genre is not None:
        song.genre = genre
    song.save()
    return song