def _build(self): mapper = LabelMapper(delivery=self.delivery, vendor=self.vendor) create = self.label_form.cleaned_data['create'] if create: # Création d'un nouvel artiste return mapper.create() else: # Liaison avec un artiste existant mdx_label = Label.objects.get(pk=self.label_form.cleaned_data['mdx_label_id']) return mapper.link(mdx_label=mdx_label)
def test_link(self): local_label = Label.objects.create(name='label_name') mapper = LabelMapper(delivery=self.delivery, vendor=self.vendor) produced_label = mapper.link(mdx_label=local_label) self.assertEqual(local_label, produced_label) self._check_label_vendor(produced_label)
def test_create(self): mapper = LabelMapper(delivery=self.delivery, vendor=self.vendor) produced_label = mapper.create() self.assertEqual(self.delivery.label.name, produced_label.name) self.assertEqual(date.today(), produced_label.created) self._check_label_vendor(produced_label)