Skip to content

Commit

Permalink
chore: minor updates to support new GEAG API response structure (#4471)
Browse files Browse the repository at this point in the history
  • Loading branch information
AfaqShuaib09 authored Oct 28, 2024
1 parent db224a6 commit f25f21b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def get_variants(self, product):
Returns:
list: A list of variant dicts
"""
variant_keys = ['variant', 'variants', 'future_variants', 'custom_presentations']
variant_keys = ['variant', 'variants', 'futureVariants', 'customPresentations']
variants = []

for key in variant_keys:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ class TestPopulateExecutiveEducationDataCsv(CSVLoaderMixin, TestCase):

SUCCESS_API_RESPONSE_CUSTOM_AND_FUTURE_VARIANTS = copy.deepcopy(SUCCESS_API_RESPONSE)
SUCCESS_API_RESPONSE_CUSTOM_AND_FUTURE_VARIANTS['products'][0].update({
'custom_presentations': [{**copy.deepcopy(variant_1), 'websiteVisibility': 'private', 'status': 'active'}],
'future_variants': [
'customPresentations': [{**copy.deepcopy(variant_1), 'websiteVisibility': 'private', 'status': 'active'}],
'futureVariants': [
{
**copy.deepcopy(variant_2), 'websiteVisibility': 'public', 'status': 'scheduled',
'startDate': '2026-03-20', 'endDate': '2026-04-28', 'finalRegCloseDate': '2026-03-26'
Expand Down Expand Up @@ -264,10 +264,10 @@ def test_populate_executive_education_data_csv_with_new_variants_structure_chang
)

simple_variant = self.SUCCESS_API_RESPONSE_CUSTOM_AND_FUTURE_VARIANTS["products"][0]["variant"]
future_variant = self.SUCCESS_API_RESPONSE_CUSTOM_AND_FUTURE_VARIANTS["products"][0]["future_variants"][0]
future_variant = self.SUCCESS_API_RESPONSE_CUSTOM_AND_FUTURE_VARIANTS["products"][0]["futureVariants"][0]
custom_variant = self.SUCCESS_API_RESPONSE_CUSTOM_AND_FUTURE_VARIANTS[
"products"
][0]["custom_presentations"][0]
][0]["customPresentations"][0]

with open(output_csv.name, "r") as csv_file:
reader = csv.DictReader(csv_file)
Expand All @@ -284,13 +284,15 @@ def test_populate_executive_education_data_csv_with_new_variants_structure_chang
assert data_row["Start Date"] == future_variant["startDate"]
assert data_row["End Date"] == future_variant["endDate"]
assert data_row["Reg Close Date"] == future_variant["finalRegCloseDate"]
assert data_row["Publish Date"] == future_variant["startDate"]
assert data_row["Restriction Type"] == "None"

data_row = next(reader)
assert data_row["Variant Id"] == custom_variant["id"]
assert data_row["Start Date"] == custom_variant["startDate"]
assert data_row["End Date"] == custom_variant["endDate"]
assert data_row["Reg Close Date"] == custom_variant["finalRegCloseDate"]
assert data_row["Publish Date"] == str(date.today().isoformat())
assert data_row["Restriction Type"] == "custom-b2b-enterprise"

@mock.patch('course_discovery.apps.course_metadata.utils.GetSmarterEnterpriseApiClient')
Expand Down

0 comments on commit f25f21b

Please sign in to comment.