Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delegate Fulfillment instead of using FulfillmentInfo (PP-1641) #2035

Merged
merged 3 commits into from
Sep 6, 2024

Conversation

jonathangreen
Copy link
Member

Description

Refactor FulfillmentInfo class which just contained information about a fufillment, but had multiple methods to override how fulfillment was done, to be a new class called Fulfillment which the loans controller delegates fulfillment to.

This lets each API control how fulfillment is done, and reduces the amount of if / then we need to have in the loan controller. We define several types of Fulfillment, corresponding to the logic that used to exist in the loans controller, and update the API classes to use them.

The goal of this PR is the have fulfillment for each API act the same way before and after, just refactoring to use the new structure.

Motivation and Context

This refactor builds on #2034 and is part of the work needed for #2033. We are already effectively delegating control of the fulfillment, but not being explicit about it, so I think this refactor makes it easier to reason about how fulfillment will work.

How Has This Been Tested?

  • Running unit tests

Checklist

  • I have updated the documentation accordingly.
  • All new and existing tests passed.

@jonathangreen jonathangreen requested a review from a team September 6, 2024 15:13
Copy link

codecov bot commented Sep 6, 2024

Codecov Report

Attention: Patch coverage is 94.44444% with 7 lines in your changes missing coverage. Please review.

Project coverage is 90.75%. Comparing base (f8440a8) to head (86acbb0).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
src/palace/manager/api/circulation.py 93.75% 2 Missing and 1 partial ⚠️
src/palace/manager/api/enki.py 50.00% 1 Missing and 1 partial ⚠️
src/palace/manager/api/axis.py 97.43% 0 Missing and 1 partial ⚠️
src/palace/manager/api/controller/loan.py 88.88% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2035      +/-   ##
==========================================
+ Coverage   90.72%   90.75%   +0.03%     
==========================================
  Files         342      342              
  Lines       40572    40516      -56     
  Branches     8796     8771      -25     
==========================================
- Hits        36808    36772      -36     
+ Misses       2503     2486      -17     
+ Partials     1261     1258       -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Base automatically changed from chore/refactor-bad-response-exception to main September 6, 2024 16:22
@jonathangreen jonathangreen force-pushed the chore/refactor-fulfillment branch from 1fdb345 to d166625 Compare September 6, 2024 16:23
Copy link
Contributor

@tdilauro tdilauro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me.

There are a couple of small comments below, but nothing super important.

A broader comment is that some of the test and fixture classes still have "FulfillmentInfo" in their names.

active attempt to fulfill the loan.
:param locked_to: A DeliveryMechanismInfo object representing the
delivery mechanism to which this loan is 'locked'.
"""
super().__init__(collection, data_source_name, identifier_type, identifier)
self.start_date = start_date
self.end_date = end_date
self.fulfillment_info = fulfillment_info
self.fulfillment = fulfillment
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Self fulfillment is sooooo important! 🙃

debug_message=error_details,
)
def __init__(
self, content_link: str, content_type: str | None, verify: bool
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this content_type default to DeliveryMechanism.ADOBE_DRM? Would we be calling this with any others?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. I'll change that.

@jonathangreen
Copy link
Member Author

jonathangreen commented Sep 6, 2024

A broader comment is that some of the test and fixture classes still have "FulfillmentInfo" in their names.

@tdilauro I think I got all the ones that need to be changed. Its a bit annoying, the axis API has an API call named FulfillmentInfo, so there are some references in the Axis classes that are valid, and some that need to be changed. I'll go go through a search again and see if I missed any.

fulfillment_endpoint = "getfullfillmentInfo/v2"

@jonathangreen
Copy link
Member Author

@tdilauro you were right, I did miss some references to FulfillmentInfo that should have been updated. I think I got them all now in 86acbb0.

@jonathangreen jonathangreen changed the title Refactor FulfillmentInfo (PP-1641) Delegate Fulfillment instead of using FulfillmentInfo (PP-1641) Sep 6, 2024
@jonathangreen jonathangreen merged commit 5fb1411 into main Sep 6, 2024
20 checks passed
@jonathangreen jonathangreen deleted the chore/refactor-fulfillment branch September 6, 2024 17:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants