From e4e7b2937dbf646562bc462e156090d14a33d3e4 Mon Sep 17 00:00:00 2001 From: Shankar Ambady Date: Thu, 7 Nov 2024 19:06:43 -0500 Subject: [PATCH] Remove unnecessary percolate calls (#1801) --- learning_resources/etl/loaders.py | 2 +- learning_resources/etl/loaders_test.py | 50 +++++--------------------- 2 files changed, 9 insertions(+), 43 deletions(-) diff --git a/learning_resources/etl/loaders.py b/learning_resources/etl/loaders.py index 9d9ea65e60..a0edda716d 100644 --- a/learning_resources/etl/loaders.py +++ b/learning_resources/etl/loaders.py @@ -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): diff --git a/learning_resources/etl/loaders_test.py b/learning_resources/etl/loaders_test.py index 6e67963b35..d0befcbfa2 100644 --- a/learning_resources/etl/loaders_test.py +++ b/learning_resources/etl/loaders_test.py @@ -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() @@ -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() @@ -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) @@ -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() @@ -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() @@ -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, @@ -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])