Skip to content

Commit

Permalink
temp: add temp workaround for taxi form post submit url fix (#4567)
Browse files Browse the repository at this point in the history
  • Loading branch information
AfaqShuaib09 authored Feb 7, 2025
1 parent 72a9334 commit 7edad37
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from django.conf import settings
from django.core.management import BaseCommand, CommandError

from course_discovery.apps.course_metadata.choices import CourseRunRestrictionType
from course_discovery.apps.course_metadata.choices import CourseRunRestrictionType, ExternalCourseMarketingType
from course_discovery.apps.course_metadata.data_loaders import utils
from course_discovery.apps.course_metadata.data_loaders.utils import map_external_org_code_to_internal_org_code
from course_discovery.apps.course_metadata.utils import fetch_getsmarter_products
Expand Down Expand Up @@ -408,5 +408,10 @@ def get_transformed_data(self, partially_filled_csv_dict, product_dict):
),
'external_course_marketing_type': product_dict['productType'],
'taxi_form_id': product_dict['edxTaxiFormId'],
'post_submit_url': utils.format_base64_strings(product_dict['prospectusUrl']),
'post_submit_url': (
utils.format_base64_strings(product_dict['edxPlpUrl']).replace('/lp/', '/info/')
if not product_dict['prospectusUrl'] and
product_dict.get('productType', '').lower() == ExternalCourseMarketingType.Sprint.value
else utils.format_base64_strings(product_dict['prospectusUrl'])
),
}
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,39 @@ def test_successful_file_data_population_with_getsmarter_flag_with_multiple_vari
),
)

@mock.patch('course_discovery.apps.course_metadata.utils.GetSmarterEnterpriseApiClient')
def test_taxi_form_post_submit_url_in_case_prospectus_url_is_empty_and_product_type_sprint(
self, mock_get_smarter_client
):
"""
Verify that the taxi form post submit url is set to the edxPlpUrl if the prospectusUrl is empty
and the product type is sprint.
"""
success_api_response = copy.deepcopy(self.SUCCESS_API_RESPONSE)
success_api_response['products'][0]['prospectusUrl'] = ''
success_api_response['products'][0]['productType'] = 'sprint'
success_api_response['products'][0]['edxPlpUrl'] = 'https://example.com/presentations/lp/example-course/'
mock_get_smarter_client.return_value.request.return_value.json.return_value = (
self.mock_get_smarter_client_response(
override_get_smarter_client_response=success_api_response
)
)
with NamedTemporaryFile() as output_csv:
call_command(
'populate_executive_education_data_csv',
'--output_csv', output_csv.name,
'--use_getsmarter_api_client', True,
)

output_csv.seek(0)
with open(output_csv.name, 'r') as csv_file:
reader = csv.DictReader(csv_file)
data_row = next(reader)
assert data_row['Title'] == 'Alternative CSV Course'
assert data_row['External Course Marketing Type'] == 'sprint'
assert data_row['Taxi Form Id'] == 'test-form-id'
assert data_row['Post Submit Url'] == 'https://example.com/presentations/info/example-course/'

@mock.patch("course_discovery.apps.course_metadata.utils.GetSmarterEnterpriseApiClient")
@ddt.data(
("active", str(date.today().isoformat())), ("scheduled", "2024-03-20")
Expand Down

0 comments on commit 7edad37

Please sign in to comment.