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: added support for default language for degree export in product_catalog_command #4447

Merged
merged 1 commit into from
Sep 19, 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 @@ -170,7 +170,7 @@ def get_transformed_data(self, product, product_type):
translation.name for subject in product.active_subjects
for translation in subject.spanish_translations
),
"Languages": ", ".join(language.code for language in product.active_languages),
"Languages": ", ".join(language.code for language in product.active_languages) or 'en-us',
"Marketing Image": product.card_image.url if product.card_image else "",
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,18 @@ def test_populate_product_catalog_excludes_non_marketable_degrees(self):
authoring_organizations=[self.organization],
card_image=factory.django.ImageField()
)
marketable_degree_with_no_language = DegreeFactory.create(
product_source=self.source,
partner=self.partner,
additional_metadata=None,
type=self.program_type,
status=ProgramStatus.Active,
marketing_slug="valid-marketing-slug",
title="Marketable Degree - with empty language field",
authoring_organizations=[self.organization],
card_image=factory.django.ImageField(),
language_override=None,
)

marketable_degree_2 = DegreeFactory.create(
product_source=self.source,
Expand Down Expand Up @@ -283,6 +295,15 @@ def test_populate_product_catalog_excludes_non_marketable_degrees(self):
self.assertEqual(len(matching_rows), 1,
f"Marketable degree '{marketable_degree.title}' should be in the CSV")

# Check that the marketable degree with no language field is in the CSV
matching_rows = [
row for row in rows if row["UUID"] == str(marketable_degree_with_no_language.uuid.hex)
]
self.assertEqual(len(matching_rows), 1,
f"Marketable degree '{marketable_degree_with_no_language.title}' should be in the CSV")
# Check that the marketable degree with no language field has the default language populated
self.assertEqual(matching_rows[0].get("Languages"), 'en-us')

def test_populate_product_catalog_with_degrees_having_overrides(self):
"""
Test that the populate_product_catalog command includes the overridden subjects and languages for degrees.
Expand Down
Loading