Ejemplo n.º 1
0
 def test_crash_bad_deliverytrack(self):
     from django.conf import settings
     release_form = ReleaseForm({'pk': self.delivery.release.pk, 'title_hidden': 'release_title',
                                 'artist_name_hidden': 'artist', 'label_name_hidden': 'label'})
     release_form.is_valid()
     # Modify the delivery in order to crash
     self.delivery.tracks[1].pk = 'aaa'
     release_processor = ReleaseProcessor(delivery=self.delivery, release_form=release_form, 
                                          artist=self.artist, label=self.label, disc=self.disc,
                                          vendor=self.vendor)
     # Test
     # No Album
     self.assertEqual(None, release_processor.build())
     self.assertFalse(self.artist.album_set.all())
     # No tracks
     for (index,track) in enumerate(self.delivery.tracks):
         if index != 1:
             self.assertRaises(Track.DoesNotExist, Track.objects.get, trackvendor__external_track_id=track.pk)
     # No imagefile
     self.assertEqual(0, ImageFile.objects.count())
     # No Files
     self.assertFalse(os.listdir(self.album_directory))
     # Error in the release_form
     self.assertFalse(release_form.report.success)
     self.assertTrue(release_form.report.error)
Ejemplo n.º 2
0
 def test_remove(self):
     release_form = ReleaseForm({'pk': self.delivery.release.pk, 'remove': True})
     release_form.is_valid()
     release_processor = ReleaseProcessor(delivery=self.delivery, release_form=release_form, 
                                          artist=self.artist, label=self.label,
                                          disc=self.disc, vendor=self.vendor)
     release_processor.remove()
     self.assertFalse(os.listdir(self.album_directory))
Ejemplo n.º 3
0
 def test_annuler(self):
     release_form = ReleaseForm(data={'pk': self.delivery.release.pk, 'annuler': True})
     release_form.is_valid()
     release_processor = ReleaseProcessor(delivery=self.delivery, release_form=release_form, 
                                          artist=self.artist, label=self.label,
                                          disc=self.disc, vendor=self.vendor)
     release_processor.remove()
     self.assertRaises(Album.DoesNotExist, Album.objects.get,
                       albumvendor__external_album_id=self.delivery.release.pk)
     self.assertFalse(os.path.exists(self.delivery.path))
     self.assertTrue(release_form.report.success)
Ejemplo n.º 4
0
 def test_build_(self):
     release_form = ReleaseForm({'pk': self.delivery.release.pk})
     release_form.is_valid()
     release_processor = ReleaseProcessor(delivery=self.delivery, release_form=release_form, 
                                          label=self.label, disc=self.disc, vendor=self.vendor)
     produced_release = release_processor.build()
     expected_release = Album.objects.get(albumvendor__external_album_id=self.delivery.release.pk)
     # Test album
     self.assertEqual(expected_release, produced_release)
     produced_abumvendor = produced_release.albumvendor_set.get()
     # Test album_vendor
     self.assertEqual(self.delivery.release.pk, produced_abumvendor.external_album_id)
     self.assertEqual(self.vendor, produced_abumvendor.vendor)
     # Test artist
     produced_artist = produced_release.artist
     self.assertEqual(naming.COMPIL_FLAG, produced_artist.type)
     self.assertEqual("%s %s" % (produced_release.title, naming.COMPIL_POSTFIX), produced_artist.name)
     # No Files Left   
     self.assertFalse(os.path.exists(self.delivery_path))
     # Reports
     self._check_album_report(expected_release, release_form.report)
     self._check_artist_report(produced_artist, release_form.artist_report)
     expected_admin_artist_url = ADMIN_ARTIST_URL + str(produced_release.artist.pk)
     self.assertEqual(expected_admin_artist_url, release_form.report.admin_artist_url)
Ejemplo n.º 5
0
 def test_build(self):
     release_form = ReleaseForm({'pk': self.delivery.release.pk})
     release_form.is_valid()
     release_processor = ReleaseProcessor(delivery=self.delivery, release_form=release_form, 
                                          artist=self.artist, label=self.label,
                                          disc=self.disc, vendor=self.vendor)
     produced_release = release_processor.build()
     expected_release = Album.objects.get(albumvendor__external_album_id=self.delivery.release.pk)
     self.assertEqual(expected_release, produced_release)
     # Test audiofiles
     produced_tracks = produced_release.track_set.all()
     produced_audiofiles = []
     for track in produced_tracks:
         produced_audiofiles.extend(list(track.audiofile_set.all())) 
     delivery_audiofiles = self.delivery.audiofiles()
     self.assertEqual(len(delivery_audiofiles), len(produced_audiofiles))
     for audiofile in produced_audiofiles:
         self.assertTrue(os.path.exists(audiofile.full_path()))
     # Test images
     self.check_album_images(produced_release, self.disc)
     # No Files Left   
     self.assertFalse(os.path.exists(self.delivery_path))
     # Reports
     self._check_album_report(expected_release, release_form.report)
Ejemplo n.º 6
0
 def test_no_pk(self):
     release_form = ReleaseForm(data={'title': 'eede'})
     self.assertFalse(release_form.is_valid())
Ejemplo n.º 7
0
 def test_no_field(self):
     release_form = ReleaseForm(data={})
     self.assertFalse(release_form.is_valid())
Ejemplo n.º 8
0
 def test_valid(self):
     release_form = ReleaseForm(data={'pk': 12, 'title_hidden': 'title', 
                                 'artist_name_hidden': 'artist_name',
                                 'label_name_hidden': 'label_name'})
     self.assertTrue(release_form.is_valid())
Ejemplo n.º 9
0
 def test_no_title(self):
     release_form = ReleaseForm(data={'pk': 12, 'annuler': True})
     self.assertFalse(release_form.is_valid())
Ejemplo n.º 10
0
 def test_pk_wrong_type(self):
     release_form = ReleaseForm(data={'pk': 'aaa'})
     self.assertFalse(release_form.is_valid())