File tree Expand file tree Collapse file tree 2 files changed +27
-1
lines changed
openedx_learning/apps/authoring/containers
tests/openedx_learning/apps/authoring/units Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -298,7 +298,7 @@ def create_next_container_version(
298
298
299
299
* Something was added to the Container.
300
300
* We re-ordered the rows in the container.
301
- * Something was removed to the container.
301
+ * Something was removed from the container.
302
302
* The Container's metadata changed, e.g. the title.
303
303
* We pin to different versions of the Container.
304
304
Original file line number Diff line number Diff line change 3
3
"""
4
4
import pytest
5
5
6
+ from django .core .exceptions import ValidationError
7
+
6
8
from ..components .test_api import ComponentTestCase
7
9
from openedx_learning .api import authoring as authoring_api
8
10
from openedx_learning .api import authoring_models
@@ -105,6 +107,30 @@ def test_create_unit_with_invalid_children(self):
105
107
# Check that a new version was not created:
106
108
assert unit .versioning .draft == unit_version
107
109
110
+ def test_adding_external_components (self ):
111
+ """
112
+ Test that components from another learning package cannot be added to a
113
+ unit.
114
+ """
115
+ learning_package2 = authoring_api .create_learning_package (key = "other-package" , title = "Other Package" )
116
+ unit , _unit_version = authoring_api .create_unit_and_version (
117
+ learning_package_id = learning_package2 .pk ,
118
+ key = f"unit:key" ,
119
+ title = "Unit" ,
120
+ created = self .now ,
121
+ created_by = None ,
122
+ )
123
+ assert self .component_1 .learning_package != learning_package2
124
+ # Try adding a a component from LP 1 (self.learning_package) to a unit from LP 2
125
+ with pytest .raises (ValidationError , match = "Container entities must be from the same learning package." ):
126
+ authoring_api .create_next_unit_version (
127
+ unit = unit ,
128
+ title = "Unit Containing an External Component" ,
129
+ components = [self .component_1 ],
130
+ created = self .now ,
131
+ created_by = None ,
132
+ )
133
+
108
134
def test_create_empty_unit_and_version (self ):
109
135
"""Test creating a unit with no components.
110
136
You can’t perform that action at this time.
0 commit comments