Skip to content

Commit

Permalink
chore: added support for default language for degree export (#4447)
Browse files Browse the repository at this point in the history
  • Loading branch information
AfaqShuaib09 authored Sep 19, 2024
1 parent 599858f commit 18d78aa
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
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

0 comments on commit 18d78aa

Please sign in to comment.