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

chore: minor updates to accomodate new structure #4471

Merged
merged 1 commit into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading