def test_can_create_journal_and_publisher(self): publisher = create_or_update_publisher("123456", "dcormier") journal = create_or_update_journal( publisher, "123", "Journal of journals", "joj", "", "", None ) self.assertEquals( journal.edinum_id, "123" )
def handle(self, *args, **options): self.created_or_updated_publishers = [] self.created_or_updated_journals = [] for publisher_row in fetch_publishers_from_edinum(): (person_id, publisher_name, series_id, journal_id, journal_name, journal_shortname, journal_localidentifier, coll_id, journal_subtitle) = publisher_row if person_id not in self.created_or_updated_publishers: publisher = create_or_update_publisher( person_id, publisher_name ) self.created_or_updated_publishers.append(person_id) try: journal_collection = Collection.objects.get(edinum_id=coll_id) except: journal_collection = None create_or_update_journal( publisher, journal_id, journal_name, journal_shortname, journal_localidentifier, journal_subtitle, journal_collection ) self.created_or_updated_journals.append(journal_shortname) publisher_journals = fetch_publisher_journals_from_edinum() for journal_sn in self.created_or_updated_journals: journal = Journal.objects.get(code=journal_sn) # journal.publishers.all().delete() for publisher_id, journal_id in publisher_journals: if journal_id == journal.edinum_id: publisher = Publisher.objects.get(edinum_id=publisher_id) journal.publishers.add(publisher)
def test_cannot_create_journal_if_nonedinum_journal_exists(self): """ Cannot create a journal if a non edinum journal with the same shortname exists """ publisher = PublisherFactory.create() journal = JournalFactory.create(code='testj', edinum_id="123", publishers=[publisher]) journal = create_or_update_journal( publisher, "123", "test", "testj", "", "", None ) self.assertIsNone(journal)