Skip to content

Commit 18d78aa

Browse files
authored
chore: added support for default language for degree export (#4447)
1 parent 599858f commit 18d78aa

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

course_discovery/apps/course_metadata/management/commands/populate_product_catalog.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def get_transformed_data(self, product, product_type):
170170
translation.name for subject in product.active_subjects
171171
for translation in subject.spanish_translations
172172
),
173-
"Languages": ", ".join(language.code for language in product.active_languages),
173+
"Languages": ", ".join(language.code for language in product.active_languages) or 'en-us',
174174
"Marketing Image": product.card_image.url if product.card_image else "",
175175
})
176176

course_discovery/apps/course_metadata/management/commands/tests/test_populate_product_catalog.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,18 @@ def test_populate_product_catalog_excludes_non_marketable_degrees(self):
235235
authoring_organizations=[self.organization],
236236
card_image=factory.django.ImageField()
237237
)
238+
marketable_degree_with_no_language = DegreeFactory.create(
239+
product_source=self.source,
240+
partner=self.partner,
241+
additional_metadata=None,
242+
type=self.program_type,
243+
status=ProgramStatus.Active,
244+
marketing_slug="valid-marketing-slug",
245+
title="Marketable Degree - with empty language field",
246+
authoring_organizations=[self.organization],
247+
card_image=factory.django.ImageField(),
248+
language_override=None,
249+
)
238250

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

298+
# Check that the marketable degree with no language field is in the CSV
299+
matching_rows = [
300+
row for row in rows if row["UUID"] == str(marketable_degree_with_no_language.uuid.hex)
301+
]
302+
self.assertEqual(len(matching_rows), 1,
303+
f"Marketable degree '{marketable_degree_with_no_language.title}' should be in the CSV")
304+
# Check that the marketable degree with no language field has the default language populated
305+
self.assertEqual(matching_rows[0].get("Languages"), 'en-us')
306+
286307
def test_populate_product_catalog_with_degrees_having_overrides(self):
287308
"""
288309
Test that the populate_product_catalog command includes the overridden subjects and languages for degrees.

0 commit comments

Comments
 (0)