def test_creation(self): title = NYTBestSellerListTitle(self.one_list_title) edition = title.to_edition(self._db, self.metadata_client) eq_("9780698185395", edition.primary_identifier.identifier) # The alternate ISBN is marked as equivalent to the primary identifier, # but at a greatly reduced strength. [equivalency] = [x for x in edition.primary_identifier.equivalencies] eq_("9781594633669", equivalency.output.identifier) eq_(0.5, equivalency.strength) # That strength is not enough to make the alternate ISBN an equivalent # identifier for the edition. equivalent_identifiers = [(x.type, x.identifier) for x in edition.equivalent_identifiers()] eq_([("ISBN", "9780698185395")], sorted(equivalent_identifiers)) eq_(datetime.datetime(2015, 2, 1, 0, 0), edition.published) # The list said the author was 'Paula Hawkins', but we couldn't # find a sort name based on that, so no Contributor was created, # so the book has no known author. # # See below for cases where we are able to find a sort name. eq_("[Unknown]", edition.author) eq_("[Unknown]", edition.sort_author) eq_("Riverhead", edition.publisher)
def test_to_edition_sets_sort_author_name_if_obvious(self): [contributor], ignore = Contributor.lookup(self._db, u"Hawkins, Paula") contributor.display_name = u"Paula Hawkins" title = NYTBestSellerListTitle(self.one_list_title) edition = title.to_edition(self._db, self.metadata_client) eq_(contributor.sort_name, edition.sort_author) eq_(contributor.display_name, edition.author) assert edition.permanent_work_id is not None
def test_to_edition_sets_sort_author_name_if_metadata_client_provides_it(self): # Set the metadata client up for success. self.metadata_client.lookups["Paula Hawkins"] = "Hawkins, Paula Z." title = NYTBestSellerListTitle(self.one_list_title, Edition.BOOK_MEDIUM) edition = title.to_edition(self._db, self.metadata_client) eq_("Hawkins, Paula Z.", edition.sort_author) assert edition.permanent_work_id is not None
def test_to_edition_sets_sort_author_name_if_obvious(self): [contributor], ignore = Contributor.lookup( self._db, u"Hawkins, Paula") contributor.display_name = u"Paula Hawkins" title = NYTBestSellerListTitle(self.one_list_title, Edition.BOOK_MEDIUM) edition = title.to_edition(self._db, self.metadata_client) eq_(contributor.sort_name, edition.sort_author) eq_(contributor.display_name, edition.author) assert edition.permanent_work_id is not None
def test_creation(self): title = NYTBestSellerListTitle(self.one_list_title) edition = title.to_edition(self._db, self.metadata_client) eq_("9780698185395", edition.primary_identifier.identifier) # The alternate ISBN is marked as equivalent to the primary identifier, # but at a greatly reduced strength. [equivalency] = [x for x in edition.primary_identifier.equivalencies] eq_("9781594633669", equivalency.output.identifier) eq_(0.5, equivalency.strength) # That strength is not enough to make the alternate ISBN an equivalent # identifier for the edition. equivalent_identifiers = [(x.type, x.identifier) for x in edition.equivalent_identifiers()] eq_([("ISBN", "9780698185395")], sorted(equivalent_identifiers)) eq_(datetime.datetime(2015, 2, 1, 0, 0), edition.published) eq_("Paula Hawkins", edition.author) eq_("Hawkins, Paula", edition.sort_author) eq_("Riverhead", edition.publisher)
def test_creation(self): title = NYTBestSellerListTitle(self.one_list_title, Edition.BOOK_MEDIUM) edition = title.to_edition(self._db, self.metadata_client) eq_("9780698185395", edition.primary_identifier.identifier) # The alternate ISBN is marked as equivalent to the primary identifier, # but at a greatly reduced strength. [equivalency] = [x for x in edition.primary_identifier.equivalencies] eq_("9781594633669", equivalency.output.identifier) eq_(0.5, equivalency.strength) # That strength is not enough to make the alternate ISBN an equivalent # identifier for the edition. equivalent_identifiers = [ (x.type, x.identifier) for x in edition.equivalent_identifiers() ] eq_([("ISBN", "9780698185395")], sorted(equivalent_identifiers)) eq_(datetime.datetime(2015, 2, 1, 0, 0), edition.published) eq_("Paula Hawkins", edition.author) eq_("Hawkins, Paula", edition.sort_author) eq_("Riverhead", edition.publisher)
def test_creation(self): title = NYTBestSellerListTitle(self.one_list_title, Edition.BOOK_MEDIUM) edition = title.to_edition(self._db, self.metadata_client) assert "9780698185395" == edition.primary_identifier.identifier # The alternate ISBN is marked as equivalent to the primary identifier, # but at a greatly reduced strength. [equivalency] = [x for x in edition.primary_identifier.equivalencies] assert "9781594633669" == equivalency.output.identifier assert 0.5 == equivalency.strength # That strength is not enough to make the alternate ISBN an equivalent # identifier for the edition. equivalent_identifiers = [(x.type, x.identifier) for x in edition.equivalent_identifiers()] assert [("ISBN", "9780698185395")] == sorted(equivalent_identifiers) assert datetime.date(2015, 2, 1) == edition.published assert "Paula Hawkins" == edition.author assert "Hawkins, Paula" == edition.sort_author assert "Riverhead" == edition.publisher