|
2 | 2 | from unittest.mock import patch |
3 | 3 |
|
4 | 4 | from django.core.management import call_command |
| 5 | +from le_utils.constants import content_kinds |
5 | 6 |
|
6 | 7 | from contentcuration.management.commands.fix_missing_import_sources import ( |
7 | 8 | LicensingFixesLookup, |
@@ -117,6 +118,31 @@ def test_handle__skips_node_when_lookup_returns_no_license(self): |
117 | 118 | self.assertEqual(self.copied_node.license_description, "Nothing") |
118 | 119 | self.assertEqual(self.copied_node.copyright_holder, "Nothing") |
119 | 120 |
|
| 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 | + |
120 | 146 |
|
121 | 147 | class LicensingFixesLookupTestCase(StudioTestCase): |
122 | 148 | @classmethod |
|
0 commit comments