Skip to content

Commit ba7c40a

Browse files
committed
Ignore topics since they will not be present in the CSV for Khan channels
1 parent a7259cc commit ba7c40a

2 files changed

Lines changed: 28 additions & 0 deletions

File tree

contentcuration/contentcuration/management/commands/fix_missing_import_sources.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from django.db.models import Q
1515
from django.db.models.expressions import F
1616
from django_cte import With
17+
from le_utils.constants import content_kinds
1718

1819
from contentcuration.models import Channel
1920
from contentcuration.models import ContentNode
@@ -215,6 +216,7 @@ def handle_channel(self, lookup: LicensingFixesLookup, channel: dict) -> int:
215216
public_channel_name=public_cte.col.name,
216217
public_channel_deleted=public_cte.col.deleted,
217218
)
219+
.exclude(kind=content_kinds.TOPIC)
218220
.filter(
219221
Q(public_channel_deleted=True)
220222
| ~Exists(

contentcuration/contentcuration/tests/management/commands/test_fix_missing_import_sources.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from unittest.mock import patch
33

44
from django.core.management import call_command
5+
from le_utils.constants import content_kinds
56

67
from contentcuration.management.commands.fix_missing_import_sources import (
78
LicensingFixesLookup,
@@ -117,6 +118,31 @@ def test_handle__skips_node_when_lookup_returns_no_license(self):
117118
self.assertEqual(self.copied_node.license_description, "Nothing")
118119
self.assertEqual(self.copied_node.copyright_holder, "Nothing")
119120

121+
def test_handle__skips_topic_nodes_with_missing_source(self):
122+
self.original_node.delete()
123+
self.copied_node.refresh_from_db()
124+
self.copied_node.kind_id = content_kinds.TOPIC
125+
self.copied_node.license = None
126+
self.copied_node.license_description = ""
127+
self.copied_node.copyright_holder = ""
128+
self.copied_node.save()
129+
130+
with patch(
131+
"contentcuration.management.commands.fix_missing_import_sources.LicensingFixesLookup"
132+
) as lookup_cls:
133+
lookup = lookup_cls.return_value
134+
lookup.get_info.return_value = (5, "", "Khan Academy")
135+
136+
call_command("fix_missing_import_sources")
137+
138+
lookup.get_info.assert_not_called()
139+
140+
self.copied_node.refresh_from_db()
141+
self.assertIsNone(self.copied_node.license_id)
142+
self.assertEqual(self.copied_node.kind_id, content_kinds.TOPIC)
143+
self.assertEqual(self.copied_node.license_description, "")
144+
self.assertEqual(self.copied_node.copyright_holder, "")
145+
120146

121147
class LicensingFixesLookupTestCase(StudioTestCase):
122148
@classmethod

0 commit comments

Comments
 (0)