Skip to content

Commit

Permalink
Remove unnecessary percolate calls (#1801)
Browse files Browse the repository at this point in the history
  • Loading branch information
shanbady authored Nov 8, 2024
1 parent dc7566e commit e4e7b29
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 43 deletions.
2 changes: 1 addition & 1 deletion learning_resources/etl/loaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def update_index(learning_resource, newly_created):
if not newly_created and not learning_resource.published:
resource_unpublished_actions(learning_resource)
elif learning_resource.published:
resource_upserted_actions(learning_resource, percolate=newly_created)
resource_upserted_actions(learning_resource, percolate=False)


def load_topics(resource, topics_data):
Expand Down
50 changes: 8 additions & 42 deletions learning_resources/etl/loaders_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,12 +264,7 @@ def test_load_program( # noqa: PLR0913
result.id, result.resource_type
)
elif is_published:
if program_exists:
mock_upsert_tasks.upsert_learning_resource.assert_called_with(result.id)
else:
mock_upsert_tasks.upsert_learning_resource_immutable_signature.assert_called_with(
result.id
)
mock_upsert_tasks.upsert_learning_resource.assert_called_with(result.id)
else:
mock_upsert_tasks.upsert_learning_resource.assert_not_called()

Expand Down Expand Up @@ -423,12 +418,7 @@ def test_load_course( # noqa: PLR0913,PLR0912,PLR0915
result.id, result.resource_type
)
elif is_published and is_run_published and not blocklisted:
if course_exists:
mock_upsert_tasks.upsert_learning_resource.assert_called_with(result.id)
else:
mock_upsert_tasks.upsert_learning_resource_immutable_signature.assert_called_with(
result.id
)
mock_upsert_tasks.upsert_learning_resource.assert_called_with(result.id)
else:
mock_upsert_tasks.deindex_learning_resource.assert_not_called()
mock_upsert_tasks.upsert_learning_resource.assert_not_called()
Expand Down Expand Up @@ -559,14 +549,9 @@ def test_load_duplicate_course(
else:
mock_upsert_tasks.deindex_learning_resource.assert_not_called()
if course.learning_resource.id:
if course_exists:
mock_upsert_tasks.upsert_learning_resource.assert_called_with(
course.learning_resource.id
)
else:
mock_upsert_tasks.upsert_learning_resource_immutable_signature.assert_called_with(
course.learning_resource.id
)
mock_upsert_tasks.upsert_learning_resource.assert_called_with(
course.learning_resource.id
)

assert Course.objects.count() == (2 if duplicate_course_exists else 1)

Expand Down Expand Up @@ -1124,12 +1109,7 @@ def test_load_podcast_episode(
result.id, result.resource_type
)
elif is_published:
if podcast_episode_exists:
mock_upsert_tasks.upsert_learning_resource.assert_called_with(result.id)
else:
mock_upsert_tasks.upsert_learning_resource_immutable_signature.assert_called_with(
result.id
)
mock_upsert_tasks.upsert_learning_resource.assert_called_with(result.id)
else:
mock_upsert_tasks.upsert_learning_resource.assert_not_called()
mock_upsert_tasks.deindex_learning_resource.assert_not_called()
Expand Down Expand Up @@ -1204,12 +1184,7 @@ def test_load_podcast(
result.id, result.resource_type
)
elif is_published:
if podcast_exists:
mock_upsert_tasks.upsert_learning_resource.assert_called_with(result.id)
else:
mock_upsert_tasks.upsert_learning_resource_immutable_signature.assert_called_with(
result.id
)
mock_upsert_tasks.upsert_learning_resource.assert_called_with(result.id)
else:
mock_upsert_tasks.deindex_learning_resource.assert_not_called()
mock_upsert_tasks.upsert_learning_resource.assert_not_called()
Expand Down Expand Up @@ -1507,7 +1482,6 @@ def test_load_course_percolation(
"url": learning_resource.url,
"published": is_published,
}

if is_run_published:
run = {
"run_id": run.run_id,
Expand All @@ -1520,16 +1494,8 @@ def test_load_course_percolation(
props["runs"] = []

blocklist = [learning_resource.readable_id] if blocklisted else []

result = load_course(props, blocklist, [], config=CourseLoaderConfig(prune=True))

if course_exists:
mock_upsert_tasks.upsert_learning_resource.assert_called_with(result.id)
mock_upsert_tasks.upsert_learning_resource_immutable_signature.assert_not_called()
else:
mock_upsert_tasks.upsert_learning_resource_immutable_signature.assert_called_with(
result.id
)
mock_upsert_tasks.upsert_learning_resource.assert_called_with(result.id)


@pytest.mark.parametrize("certification", [True, False])
Expand Down

0 comments on commit e4e7b29

Please sign in to comment.