Ejemplo n.º 1
0
 def test_create_label(self):
     label_form = LabelForm(data={'pk': self.delivery.label.pk, 'create': 1, 
                             'name_hidden': 'label_name', 'release_title_hidden': 'release_title'})
     label_form.is_valid()
     label_processor = LabelProcessor(delivery=self.delivery, label_form=label_form, vendor=self.vendor)
     produced_label = label_processor.build()
     expected_label = Label.objects.get(labelvendor__external_label_id=self.delivery.label.pk)
     self.assertEqual(expected_label, produced_label)
     self._report_check(expected_label, label_form)
Ejemplo n.º 2
0
 def test_link_label(self):
     label_id = 12
     local_label = Label.objects.create(pk=label_id)
     label_form = LabelForm({'pk': self.delivery.label.pk, 'create': 0, 
                             'name_hidden': 'label_name', 'release_title_hidden': 'release_title',
                             'mdx_label_id': label_id})
     label_form.is_valid()
     label_processor = LabelProcessor(delivery=self.delivery, label_form=label_form, vendor=self.vendor)
     self.assertEqual(local_label, label_processor.build())
     self._report_check(local_label, label_form)
Ejemplo n.º 3
0
 def test_fail_incorrect_pk_type(self):
     delivery_label = self.delivery.label
     delivery_label.pk = 'pk'
     label_form = LabelForm(data={'pk': delivery_label.pk, 'create': 1, 
                             'name_hidden': delivery_label.name, 'release_title_hidden': 'release_title'})
     label_form.is_valid()
     label_processor = LabelProcessor(delivery=self.delivery, label_form=label_form, vendor=self.vendor)
     label = label_processor.build()
     self.assertEquals(None, label)
     self.assertFalse(label_form.report.success)
     self.assertTrue(label_form.report.error)
Ejemplo n.º 4
0
 def process(self):
     if self.artist_formset.is_valid() \
         and self.label_formset.is_valid() \
         and self.release_formset.is_valid():
         for form in self.release_formset.forms:
             delivery = self.batch.get_delivery(release_pk=form.cleaned_data['pk'])
             vendor = Vendor.objects.get(pk=delivery.vendor_id)
             artist = None # Pour pouvoir passer None au ReleaseProcessor dans le cas d'une compil
             # Process Artist
             if delivery.artist:
                 try:
                     # Artiste déjà connu
                     artist = Artist.objects.get(artistvendor__external_artist_id=delivery.artist.pk)
                 except Artist.DoesNotExist:
                     artist_form = self.artist_formset.get_by_pk(delivery.artist.pk)
                     if artist_form:
                         artist_processor = ArtistProcessor(delivery=delivery, artist_form=artist_form, 
                                                        vendor=vendor)
                         artist = artist_processor.build()
                     else:
                         # Si pas de formulaire et artiste inconnu -> compilation, c'est le release processor 
                         # qui créera l'artiste
                         pass
             # Process Label
             try:
                 label = Label.objects.get(labelvendor__external_label_id=delivery.label.pk)
             except Label.DoesNotExist:
                 label_form = self.label_formset.get_by_pk(delivery.label.pk)
                 delivery_label = delivery.label
                 label_processor = LabelProcessor(delivery=delivery, label_form=label_form, vendor=vendor)
                 label = label_processor.build()
             # Process Release                    
             if label:
                 disc = Disc.objects.get(status='default')
                 release_processor = ReleaseProcessor(delivery=delivery, release_form=form, artist=artist,
                                                      label=label, disc=disc, vendor=vendor)
                 album = release_processor.build()