Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

fix: Enable enrollment code purchase with mobile seats #4130

Merged
merged 2 commits into from
Feb 16, 2024
Merged

Conversation

moeez96
Copy link
Contributor

@moeez96 moeez96 commented Feb 14, 2024

⛔️ MAIN BRANCH WARNING! 2U EMPLOYEES must make branches against the 2u/main BRANCH

  • I have checked the branch to which I would like to merge.

⛔️ DEPRECATION WARNING

This repository is deprecated and in maintainence-only operation while we work on a replacement, please see this announcement for more information.

Although we have stopped integrating new contributions, we always appreciate security disclosures and patches sent to [email protected]

Anyone internally merging to this repository is expected to release and monitor their changes; if you are not able to do this DO NOT MERGE, please coordinate with someone who can to ensure that the changes are released.

Description

Enable purchasing enrollment codes in presence of multiple enrollment codes for mobile.

Related Jira links:
https://2u-internal.atlassian.net/browse/REV-3857
https://2u-internal.atlassian.net/browse/LEARNER-9837

@moeez96 moeez96 requested a review from a team as a code owner February 14, 2024 11:42
Copy link
Contributor

@jawad-khan jawad-khan left a comment

Choose a reason for hiding this comment

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

Can we write test case for it?

@jawad-khan jawad-khan self-requested a review February 14, 2024 12:53
@@ -553,6 +554,7 @@ def fulfill_product(self, order, lines, email_opt_in=False):
attributes__name='course_key',
attribute_values__value_text=line.product.attr.course_key
).get(
~Q(stockrecords__partner_sku__icontains="mobile"),
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be good to have a unit test for this. Ideally, this should have been caught on unit test level. But since it was not, better to add it for the future.

Copy link
Contributor

Choose a reason for hiding this comment

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

+1 to what Dawoud says. we should have a unit test accompany this change

Copy link
Contributor

Choose a reason for hiding this comment

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

follow up question for @moeez96: if i am understanding this, is the only way we know whether or not a seat is mobile is if 'mobile' is in the sku? icontains tends to be a slower operation, which is likely fine given this is done in a job, but wanted to ask to see if there's something other than text search that indicates whether something is a mobile seat

additionally, what was the failure mode that prompted us to make this change? it looks like the Q() predicate you added will filter out mobile seats, which is good, but this get() could still fail if there are multiple objects returned. are you comfortable with this approach? or is there reason for us to be even more defensive here? (i am not familiar enough with Seats to have an definitive opinion, so i'm asking)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@christopappas That's right. We have a standard set for mobile SKUS format and it must contain the keyword mobile. This standard is integrated with the App Store and Plat Store product identifiers. Unfortunately there is nothing other than text search that indicates a seat is a mobile seat.

About the get(), we can replace this get() with a filter().first() but fulfilling a product requires a seat. If you go ahead in the method, the logic can not put up without a seat object. So if we do not have a seat, we want this to throw out an error/exception rather than fail silently.

Copy link
Contributor

Choose a reason for hiding this comment

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

great, thank you for answering my questions. in that case, this looks good to me. thank you for adding the test

@@ -553,6 +554,7 @@ def fulfill_product(self, order, lines, email_opt_in=False):
attributes__name='course_key',
attribute_values__value_text=line.product.attr.course_key
).get(
~Q(stockrecords__partner_sku__icontains="mobile"),
Copy link
Contributor

Choose a reason for hiding this comment

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

+1 to what Dawoud says. we should have a unit test accompany this change

@moeez96
Copy link
Contributor Author

moeez96 commented Feb 16, 2024

@christopappas Unit test added, Please review.

@moeez96 moeez96 merged commit 6aaf4b7 into 2u/main Feb 16, 2024
10 checks passed
@moeez96 moeez96 deleted the ROB-9837 branch February 16, 2024 16:03
zubair-ce07 added a commit that referenced this pull request Feb 20, 2024
fix: sorted imports

Fix: Support create-mobile-skus to run again if failed (#4129)

* fix: Support create-mobile-skus to run again if we found an error previously

fix: Enable enrollment code purchase with mobile seats (#4130)

* fix: Enable enrollment code purchase with mobile seats

* test: Add unit test

---------

Co-authored-by: Abdul  Moeez Zahid <[email protected]>

fix: PEP8 conventions

fix: import issue

chore: added more test cases

fix: added new line at the end of file

fix: blank line issue

fix: long line issue

fix: pylint issues

fix: import issues

fix: removed extra blank line

fix: updated test

fix: issues in command

fix:: isort issue
zubair-ce07 pushed a commit that referenced this pull request Mar 1, 2024
* fix: Enable enrollment code purchase with mobile seats

* test: Add unit test

---------

Co-authored-by: Abdul  Moeez Zahid <[email protected]>
zubair-ce07 pushed a commit that referenced this pull request Mar 1, 2024
* fix: Enable enrollment code purchase with mobile seats

* test: Add unit test

---------

Co-authored-by: Abdul  Moeez Zahid <[email protected]>
zubair-ce07 pushed a commit that referenced this pull request Mar 1, 2024
* fix: Enable enrollment code purchase with mobile seats

* test: Add unit test

---------

Co-authored-by: Abdul  Moeez Zahid <[email protected]>
zubair-ce07 pushed a commit that referenced this pull request Mar 1, 2024
* fix: Enable enrollment code purchase with mobile seats

* test: Add unit test

---------

Co-authored-by: Abdul  Moeez Zahid <[email protected]>
abdullahwaheed pushed a commit to abdullahwaheed/ecommerce that referenced this pull request Mar 1, 2024
…ported#4130)

* fix: Enable enrollment code purchase with mobile seats

* test: Add unit test

---------

Co-authored-by: Abdul  Moeez Zahid <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants