Пример #1
0
 def test_succeed_link(self):
     local_artist = Artist.objects.create(name='artist_name')
     artist_form = ArtistForm(data={'pk': self.pk, 'create': 0, 'name_hidden': self.artist_name, 
                                    'release_title_hidden': 'release_title','mdx_artist_id': local_artist.pk})
     artist_form.is_valid()
     artist_processor = ArtistProcessor(delivery=self.delivery, artist_form=artist_form, vendor=self.vendor)
     artist  = artist_processor.build()
     self.assertEquals(local_artist, artist)
     self. _report_check(local_artist, artist_form.report)
Пример #2
0
 def test_succeed_create(self):
     artist_form = ArtistForm(data={'pk': self.pk, 'create': 1, 'name_hidden': self.artist_name, 
                               'release_title_hidden': 'release_title', 'url': self.url})
     artist_form.is_valid()
     artist_processor = ArtistProcessor(delivery=self.delivery, artist_form=artist_form, vendor=self.vendor)
     produced_artist = artist_processor.build()
     expected_artist = Artist.objects.get(artistvendor__external_artist_id=self.pk)
     self.assertEquals(expected_artist, produced_artist)
     self. _report_check(expected_artist, artist_form.report)       
Пример #3
0
 def test_fail_incorrect_pk_type(self):
     delivery_artist = self.delivery.artist
     delivery_artist.pk = 'pk'
     artist_form = ArtistForm(data={'pk': self.pk, 'create': 1, 'name_hidden': self.artist_name, 
                                    'url': self.url, 'release_title_hidden': self.delivery.release.title,})
     artist_form.is_valid()
     artist_processor = ArtistProcessor(delivery=self.delivery, artist_form=artist_form, vendor=self.vendor)
     artist  = artist_processor.build()
     self.assertEquals(None, artist)
     self.assertFalse(artist_form.report.success)
     self.assertTrue(artist_form.report.error)
Пример #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()