Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions contentcuration/contentcuration/tests/test_contentnodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,27 @@ def test_sync_after_no_changes(self):
)
self._assert_same_files(orig_video, cloned_video)

def test_sync_but_incomplete(self):
orig_video, cloned_video = self._setup_original_and_deriative_nodes()
orig_video.license_id = None
orig_video.mark_complete()
self.assertFalse(orig_video.complete)
orig_video.save()

self.assertTrue(cloned_video.complete)

sync_node(
cloned_video,
sync_titles_and_descriptions=True,
sync_resource_details=True,
sync_files=True,
sync_assessment_items=True,
)

self.assertIsNotNone(cloned_video.license_id)
cloned_video.mark_complete()
self.assertTrue(cloned_video.complete)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

praise: Good test structure — making the original incomplete via license_id = None, then verifying the cloned node's license_id and complete status are preserved. This directly validates the guard's purpose.


def test_sync_with_subs(self):
orig_video, cloned_video = self._setup_original_and_deriative_nodes()
self._add_subs_to_video_node(orig_video, "fr")
Expand Down Expand Up @@ -868,6 +889,13 @@ def _create_video_node(self, title, parent, withsubs=False):
node_id="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
)
video_node = testdata.node(data, parent=parent)
video_node.license_id = 9 # Special Permissions
video_node.license_description = "Special permissions for testing"
video_node.copyright_holder = "LE"
# ensure the node is complete according to our logic
video_node.mark_complete()
self.assertTrue(video_node.complete)
video_node.save()

if withsubs:
self._add_subs_to_video_node(video_node, "fr")
Expand Down
9 changes: 6 additions & 3 deletions contentcuration/contentcuration/utils/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,14 @@ def sync_node(
sync_assessment_items=False,
):
original_node = node.get_original_node()
if not original_node.complete:
logging.warning(
f"Refusing to sync node {node.pk} from incomplete source node: {original_node.pk}"
)
return node
if original_node.node_id != node.node_id: # Only update if node is not original
logging.info(
"----- Syncing: {} from {}".format(
node.title, original_node.get_channel().name
)
f"----- Syncing: {node.title} from {original_node.get_channel().name}"
)
if sync_titles_and_descriptions:
fields = [
Expand Down
Loading