Skip to content

Commit

Permalink
feat: Updates opportunity line item regex and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
brobro10000 committed Jun 30, 2023
1 parent a4298d2 commit 07c575b
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion ecommerce/enterprise/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@

# Salesforce Opportunity Opportunity Line item must be 18 alphanumeric characters
# and begin with a number OR be "none" (to accommodate potential edge case).
ENTERPRISE_SALESFORCE_OPPORTUNITY_LINE_ITEM_REGEX = r'^[0-9]{1}[a-zA-Z0-9]{17}$|^none$'
ENTERPRISE_SALESFORCE_OPPORTUNITY_LINE_ITEM_REGEX = r'^00[kK][a-zA-Z0-9]{15}$|^none$'
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def create_coupon(self, api_client, ecommerce_api_url, enterprise_catalog_api_ur
"end_datetime": str(now() + datetime.timedelta(days=10)),
"benefit_value": 100,
"sales_force_id": '006aaaaaaaaaaaaaaa',
"sales_force_opportunity_line_item": '01aaaaaaaaaaaaaaaa',
"sales_force_opportunity_line_item": '00kaaaaaaaaaaaaaaa',
}
url = urljoin(f"{ecommerce_api_url}/", "enterprise/coupons/")
response = api_client.post(url, json=request_obj)
Expand Down
6 changes: 3 additions & 3 deletions ecommerce/enterprise/tests/test_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def generate_data(self, **kwargs):
'contract_discount_value': self.contract_discount_value,
'prepaid_invoice_amount': self.prepaid_invoice_amount,
'sales_force_id': '006abcde0123456789',
'salesforce_opportunity_line_item': '000abcde9876543210',
'salesforce_opportunity_line_item': '00kabcde9876543210',
'max_global_applications': 2,
'max_discount': 300,
'max_user_discount': 50,
Expand Down Expand Up @@ -496,8 +496,8 @@ def _test_salesforce_opportunity_line_item(self, salesforce_opportunity_line_ite

@ddt.data(
# Valid Cases
('006abcde0123456789', None),
('006ABCDE0123456789', None),
('00kabcde0123456789', None),
('00KABCDE0123456789', None),
('none', None),
# Invalid Cases
('006ABCDE012345678123143',
Expand Down
4 changes: 2 additions & 2 deletions ecommerce/enterprise/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def test_post(self):
'contract_discount_value': 200,
'prepaid_invoice_amount': 2000,
'sales_force_id': '006abcde0123456789',
'salesforce_opportunity_line_item': '000abcde9876543210',
'salesforce_opportunity_line_item': '00kabcde9876543210',
'usage_email_frequency': ConditionalOffer.DAILY
}
response = self.client.post(self.path, data, follow=False)
Expand All @@ -131,7 +131,7 @@ def test_post(self):
expected_discount_type = 'Absolute'
expected_prepaid_invoice_amount = 12345
sales_force_id = '006abcde0123456789'
salesforce_opportunity_line_item = '000abcde9876543210'
salesforce_opportunity_line_item = '00kabcde9876543210'
data = {
'enterprise_customer_uuid': expected_ec_uuid,
'enterprise_customer_catalog_uuid': expected_ec_catalog_uuid,
Expand Down
4 changes: 2 additions & 2 deletions ecommerce/extensions/api/v2/tests/views/test_coupons.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def setUp(self):
'title': 'Tešt čoupon',
'voucher_type': Voucher.SINGLE_USE,
'sales_force_id': '006ABCDE0123456789',
'salesforce_opportunity_line_item': '000ABCDE9876543210',
'salesforce_opportunity_line_item': '00kABCDE9876543210',
}
self.response = self.get_response('POST', COUPONS_LINK, self.data)
self.coupon = Product.objects.get(title=self.data['title'])
Expand Down Expand Up @@ -697,7 +697,7 @@ def test_update_note(self):
self.assertEqual(new_coupon.attr.note, note)

@ddt.data(
'006abcde0123456789', 'otherSalesForce', ''
'00kabcde0123456789', 'otherSalesForce', ''
)
def test_update_sales_force_id(self, sales_force_id):
"""
Expand Down
6 changes: 3 additions & 3 deletions ecommerce/extensions/api/v2/tests/views/test_enterprise.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ def setUp(self):
'contract_discount_value': '12.35',
'notify_learners': True,
'sales_force_id': '006ABCDE0123456789',
'salesforce_opportunity_line_item': '000ABCDE9876543210',
'salesforce_opportunity_line_item': '00kABCDE9876543210',
}

self.course = CourseFactory(id='course-v1:test-org+course+run', partner=self.partner)
Expand Down Expand Up @@ -458,8 +458,8 @@ def _test_salesforce_opportunity_line_item_on_update_coupon(
self.assertEqual(coupon.attr.salesforce_opportunity_line_item, salesforce_opportunity_line_item)

@ddt.data(
('006abcde0123456789', 200, None),
('006ABCDE0123456789', 200, None),
('00kabcde0123456789', 200, None),
('00KABCDE0123456789', 200, None),
('none', 200, None),
(None, 400, 'This field is required.'),
(
Expand Down
4 changes: 2 additions & 2 deletions ecommerce/extensions/api/v2/views/orders.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class ManualCourseEnrollmentOrderViewSet(EdxOrderPlacementMixin, EnterpriseDisco
>>> "discount_percentage": 75.0,
>>> "date_placed": '2020-02-11T09:38:47.634561+00:00', # optional param, only for old records.
>>> "sales_force_id": '252F0060L00000ppWfu',
>>> "salesforce_opportunity_line_item": 'abcF0060L00000ppWfu',
>>> "salesforce_opportunity_line_item": '00kF0060L00000ppWfu',
>>> "mode": 'verified',
>>> "enterprise_customer_name": "an-enterprise-customer",
>>> "enterprise_customer_uuid": "394a5ce5-6ff4-4b2b-bea1-a273c6920ae1",
Expand Down Expand Up @@ -153,7 +153,7 @@ class ManualCourseEnrollmentOrderViewSet(EdxOrderPlacementMixin, EnterpriseDisco
>>> "discount_percentage": 75.0,
>>> "date_placed": '2020-02-11T09:38:47.634561+00:00',
>>> "sales_force_id": '252F0060L00000ppWfu',
>>> "salesforce_opportunity_line_item": 'abcF0060L00000ppWfu',
>>> "salesforce_opportunity_line_item": '00kF0060L00000ppWfu',
>>> "mode": 'verified',
>>> "enterprise_customer_name": "an-enterprise-customer",
>>> "enterprise_customer_uuid": "394a5ce5-6ff4-4b2b-bea1-a273c6920ae1",
Expand Down
2 changes: 1 addition & 1 deletion ecommerce/static/js/test/mock_data/coupons.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ define([], function() {
contract_discount_value: 30,
prepaid_invoice_amount: 10000,
sales_force_id: '006ABCDE0123456789',
salesforce_opportunity_line_item: '000ABCDE9876543210',
salesforce_opportunity_line_item: '00kABCDE9876543210',
invoice_type: 'Not-Applicable'
},
couponAPIResponseData = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ define([

it('should submit enterprise coupon form with valid fields', function() {
view.$('[name=sales_force_id]').val('006ABCDE0123456789').trigger('change');
view.$('[name=salesforce_opportunity_line_item]').val('000ABCDE9876543210').trigger('change');
view.$('[name=salesforce_opportunity_line_item]').val('00kABCDE9876543210').trigger('change');
view.$('[name=contract_discount_value]').val(30).trigger('change');
view.$('[name=prepaid_invoice_amount]').val(10000).trigger('change');
view.$('[name=title]').val('Test Enrollment').trigger('change');
Expand Down
2 changes: 1 addition & 1 deletion ecommerce/static/js/utils/validation_patterns.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ define([
});

_.extend(Backbone.Validation.patterns, {
salesforce_opportunity_line_item: /^[0-9]{1}[a-zA-Z0-9]{17}$|^none$/
salesforce_opportunity_line_item: /^00[kK][a-zA-Z0-9]{15}$|^none$/
});

_.extend(Backbone.Validation.messages, {
Expand Down

0 comments on commit 07c575b

Please sign in to comment.