def _build(self): mapper = ArtistMapper(delivery=self.delivery, vendor=self.vendor) """ if not self.artist_form: assert self.delivery.release.compil, "Formulaire artiste absent" return mapper.create() """ create = self.artist_form.cleaned_data['create'] if create: # Création d'un nouvel artist return mapper.create(url=self.artist_form.cleaned_data['url']) else: # Liaison avec un artiste existant return mapper.link(mdx_artist=Artist.objects.get(pk=self.artist_form.cleaned_data['mdx_artist_id']))
def test_link(self): local_artist = Artist.objects.create(pk=56) artist_mapper = ArtistMapper(vendor=self.idol_vendor, delivery=self.delivery) produced_artist = artist_mapper.link(mdx_artist=local_artist) self.assertEqual(local_artist, produced_artist) self._check_artist_vendor(produced_artist)