|
20 | 20 | from learning_resources.etl.utils import (
|
21 | 21 | transform_delivery,
|
22 | 22 | )
|
23 |
| -from learning_resources.etl.xpro import _parse_datetime, parse_topics |
24 |
| -from learning_resources.factories import ( |
25 |
| - LearningResourceOfferorFactory, |
26 |
| - LearningResourceTopicFactory, |
27 |
| - LearningResourceTopicMappingFactory, |
28 |
| -) |
| 23 | +from learning_resources.etl.xpro import _parse_datetime |
29 | 24 | from learning_resources.test_utils import set_up_topics
|
30 | 25 | from main.test_utils import any_instance_of
|
31 | 26 |
|
@@ -109,7 +104,7 @@ def test_xpro_transform_programs(mock_xpro_programs_data):
|
109 | 104 | "published": bool(program_data["current_price"]),
|
110 | 105 | "url": program_data["url"],
|
111 | 106 | "availability": Availability.dated.name,
|
112 |
| - "topics": parse_topics(program_data), |
| 107 | + "topics": program_data["topics"], |
113 | 108 | "platform": PlatformType.xpro.name,
|
114 | 109 | "resource_type": LearningResourceType.program.name,
|
115 | 110 | "delivery": transform_delivery(program_data.get("format")),
|
@@ -156,7 +151,7 @@ def test_xpro_transform_programs(mock_xpro_programs_data):
|
156 | 151 | for course_run in course_data["courseruns"]
|
157 | 152 | ),
|
158 | 153 | "availability": Availability.dated.name,
|
159 |
| - "topics": parse_topics(course_data), |
| 154 | + "topics": course_data["topics"], |
160 | 155 | "resource_type": LearningResourceType.course.name,
|
161 | 156 | "continuing_ed_credits": course_data.get("credits"),
|
162 | 157 | "pace": [Pace.self_paced.name],
|
@@ -233,7 +228,7 @@ def test_xpro_transform_courses(mock_xpro_courses_data):
|
233 | 228 | for course_run in course_data["courseruns"]
|
234 | 229 | ),
|
235 | 230 | "availability": Availability.dated.name,
|
236 |
| - "topics": parse_topics(course_data), |
| 231 | + "topics": course_data["topics"], |
237 | 232 | "resource_type": LearningResourceType.course.name,
|
238 | 233 | "runs": [
|
239 | 234 | {
|
@@ -324,45 +319,3 @@ def test_program_run_start_date_value(
|
324 | 319 | assert transformed_programs[0]["runs"][0]["start_date"] == _parse_datetime(
|
325 | 320 | expected_dt
|
326 | 321 | )
|
327 |
| - |
328 |
| - |
329 |
| -@pytest.mark.parametrize( |
330 |
| - ("raw_topics", "expected_topics"), |
331 |
| - [ |
332 |
| - (["Technology:AI/Machine Learning", "Management"], ["Management"]), |
333 |
| - ( |
334 |
| - ["Technology:AI/Machine Learning", "Business:Management"], |
335 |
| - ["AI", "Machine Learning", "Management"], |
336 |
| - ), |
337 |
| - (["Machine Learning", "Management"], ["Machine Learning", "Management"]), |
338 |
| - (["AI", "Machine Learning"], ["AI", "Machine Learning"]), |
339 |
| - ( |
340 |
| - ["AI", "Machine Learning", "Technology:AI/Machine Learning"], |
341 |
| - ["AI", "Machine Learning"], |
342 |
| - ), |
343 |
| - ], |
344 |
| -) |
345 |
| -def test_parse_topics_data(raw_topics, expected_topics): |
346 |
| - """Test that topics are correctly parsed from the xpro data""" |
347 |
| - offeror = LearningResourceOfferorFactory.create(is_xpro=True) |
348 |
| - LearningResourceTopicMappingFactory.create( |
349 |
| - offeror=offeror, |
350 |
| - topic=LearningResourceTopicFactory.create(name="AI"), |
351 |
| - topic_name="AI/Machine Learning", |
352 |
| - ) |
353 |
| - LearningResourceTopicMappingFactory.create( |
354 |
| - offeror=offeror, |
355 |
| - topic=LearningResourceTopicFactory.create(name="Machine Learning"), |
356 |
| - topic_name="AI/Machine Learning", |
357 |
| - ) |
358 |
| - LearningResourceTopicMappingFactory.create( |
359 |
| - offeror=offeror, |
360 |
| - topic=LearningResourceTopicFactory.create(name="Management"), |
361 |
| - topic_name="Management", |
362 |
| - ) |
363 |
| - course_data = { |
364 |
| - "topics": [{"name": topic} for topic in raw_topics], |
365 |
| - } |
366 |
| - assert sorted(parse_topics(course_data), key=lambda topic: topic["name"]) == sorted( |
367 |
| - [{"name": topic} for topic in expected_topics], key=lambda topic: topic["name"] |
368 |
| - ) |
0 commit comments