Example #1
0
    def test_delete_empty_instances(self):
        artist = Artist.objects.create(name="Brian")
        Album.objects.create(title="Spam", artist=artist)
        album2 = Album.objects.create(title="Eggs", artist=artist)
        song = Song.objects.create(title="A song", album=album2, bitrate=128000)

        delete_empty_instances()

        # Check that the album 'Spam' has been deleted
        self.assertRaises(Album.DoesNotExist, Album.objects.get, title="Spam")

        # Check that Album.DoesNotExist if not raised for album2
        Album.objects.get(title="Eggs")

        song.delete()
        delete_empty_instances()

        # Check that album2 and artist have been deleted
        self.assertRaises(Album.DoesNotExist, Album.objects.get, title="Eggs")
        self.assertRaises(Artist.DoesNotExist, Artist.objects.get, name="Brian")
Example #2
0
 def handle_noargs(self, **options):
     delete_empty_instances()
     sync_song_files()
     sync_cover_images()
     remove_empty_directories()