def test_process_checkout_data(self): data, json = self.sample_json("shelf_with_book_already_fulfilled_on_kindle.json") [on_kindle, not_on_kindle] = json["checkouts"] # The book already fulfilled on Kindle doesn't get turned into # LoanInfo at all. eq_(None, MockOverdriveAPI.process_checkout_data(on_kindle, self.collection)) # The book not yet fulfilled does show up as a LoanInfo. loan_info = MockOverdriveAPI.process_checkout_data(not_on_kindle, self.collection) eq_("2fadd2ac-a8ec-4938-a369-4c3260e8922b", loan_info.identifier) # Since there are two usable formats (Adobe EPUB and Adobe # PDF), the LoanInfo is not locked to any particular format. eq_(None, loan_info.locked_to) # A book that's on loan and locked to a specific format has a # DeliveryMechanismInfo associated with that format. data, format_locked_in = self.sample_json("checkout_response_locked_in_format.json") loan_info = MockOverdriveAPI.process_checkout_data(format_locked_in, self.collection) delivery = loan_info.locked_to eq_(Representation.EPUB_MEDIA_TYPE, delivery.content_type) eq_(DeliveryMechanism.ADOBE_DRM, delivery.drm_scheme) # This book is on loan and the choice between Kindle and Adobe # EPUB has not yet been made, but as far as we're concerned, # Adobe EPUB is the only *usable* format, so it's effectively # locked. data, no_format_locked_in = self.sample_json("checkout_response_no_format_locked_in.json") loan_info = MockOverdriveAPI.process_checkout_data(no_format_locked_in, self.collection) assert loan_info != None delivery = loan_info.locked_to eq_(Representation.EPUB_MEDIA_TYPE, delivery.content_type) eq_(DeliveryMechanism.ADOBE_DRM, delivery.drm_scheme)
def test_process_checkout_data(self): data, json = self.sample_json( "shelf_with_book_already_fulfilled_on_kindle.json") [on_kindle, not_on_kindle] = json["checkouts"] # The book already fulfilled on Kindle doesn't get turned into # LoanInfo. eq_(None, MockOverdriveAPI.process_checkout_data(on_kindle)) # The book not yet fulfilled does show up as a LoanInfo. loan_info = MockOverdriveAPI.process_checkout_data(not_on_kindle) eq_("2fadd2ac-a8ec-4938-a369-4c3260e8922b", loan_info.identifier) data, format_locked_in = self.sample_json( "checkout_response_locked_in_format.json") # A book that's on loan with a format locked in shows up. loan_info = MockOverdriveAPI.process_checkout_data(format_locked_in) assert loan_info != None data, no_format_locked_in = self.sample_json( "checkout_response_no_format_locked_in.json") # A book that's on loan with no format locked in also shows up. loan_info = MockOverdriveAPI.process_checkout_data(no_format_locked_in) assert loan_info != None
def test_process_checkout_data(self): data, json = self.sample_json("shelf_with_book_already_fulfilled_on_kindle.json") [on_kindle, not_on_kindle] = json["checkouts"] # The book already fulfilled on Kindle doesn't get turned into # LoanInfo at all. eq_(None, MockOverdriveAPI.process_checkout_data(on_kindle, self.collection)) # The book not yet fulfilled does show up as a LoanInfo. loan_info = MockOverdriveAPI.process_checkout_data(not_on_kindle, self.collection) eq_("2fadd2ac-a8ec-4938-a369-4c3260e8922b", loan_info.identifier) # Since there are two usable formats (Adobe EPUB and Adobe # PDF), the LoanInfo is not locked to any particular format. eq_(None, loan_info.locked_to) # A book that's on loan and locked to a specific format has a # DeliveryMechanismInfo associated with that format. data, format_locked_in = self.sample_json("checkout_response_locked_in_format.json") loan_info = MockOverdriveAPI.process_checkout_data(format_locked_in, self.collection) delivery = loan_info.locked_to eq_(Representation.EPUB_MEDIA_TYPE, delivery.content_type) eq_(DeliveryMechanism.ADOBE_DRM, delivery.drm_scheme) # This book is on loan and the choice between Kindle and Adobe # EPUB has not yet been made, but as far as we're concerned, # Adobe EPUB is the only *usable* format, so it's effectively # locked. data, no_format_locked_in = self.sample_json("checkout_response_no_format_locked_in.json") loan_info = MockOverdriveAPI.process_checkout_data(no_format_locked_in, self.collection) assert loan_info != None delivery = loan_info.locked_to eq_(Representation.EPUB_MEDIA_TYPE, delivery.content_type) eq_(DeliveryMechanism.ADOBE_DRM, delivery.drm_scheme)