File tree Expand file tree Collapse file tree
src/openedx_content/applets/publishing/models
openedx_content/applets/publishing Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -54,6 +54,7 @@ class Container(PublishableEntityMixin):
5454 we will also add support for dynamic containers which may contain different
5555 entities for different learners or at different times.
5656 """
57+
5758 CONTAINER_TYPE : str = "" # Subclasses need to override this.
5859
5960 # The type of the container. Cannot be changed once the container is created.
Original file line number Diff line number Diff line change @@ -59,6 +59,8 @@ def root(*args):
5959 "openedx_content" ,
6060 "openedx_catalog" ,
6161 * openedx_content_backcompat_apps_to_install (),
62+ # Apps with models that are only used for testing
63+ "tests.test_django_app" ,
6264]
6365
6466AUTHENTICATION_BACKENDS = [
@@ -97,3 +99,27 @@ def root(*args):
9799}
98100
99101STATIC_URL = 'static/'
102+
103+ # Required for Django admin which is required because it's referenced by projects.urls (ROOT_URLCONF)
104+ TEMPLATES = [
105+ {
106+ 'NAME' : 'django' ,
107+ 'BACKEND' : 'django.template.backends.django.DjangoTemplates' ,
108+ # Don't look for template source files inside installed applications.
109+ # 'APP_DIRS': False,
110+ # Instead, look for template source files in these dirs.
111+ # 'DIRS': [],
112+ 'OPTIONS' : {
113+ 'context_processors' : [
114+ 'django.template.context_processors.request' ,
115+ 'django.contrib.messages.context_processors.messages' ,
116+ 'django.contrib.auth.context_processors.auth' ,
117+ ],
118+ }
119+ },
120+ ]
121+ MIDDLEWARE = [
122+ "django.contrib.sessions.middleware.SessionMiddleware" ,
123+ "django.contrib.auth.middleware.AuthenticationMiddleware" ,
124+ "django.contrib.messages.middleware.MessageMiddleware" ,
125+ ]
Original file line number Diff line number Diff line change 2727User = get_user_model ()
2828
2929
30+ class TestContainer (Container ):
31+ """
32+ A fake subclass of Container used for test purposes.
33+ """
34+ CONTAINER_TYPE = "fake_test"
35+
36+ class Meta :
37+ app_label = "openedx_content"
38+
39+
3040class LearningPackageTestCase (TestCase ):
3141 """
3242 Test creating a LearningPackage
@@ -1068,6 +1078,7 @@ def test_bulk_parent_child_side_effects(self) -> None:
10681078 "my_container" ,
10691079 created = self .now ,
10701080 created_by = None ,
1081+ container_cls = TestContainer ,
10711082 )
10721083 container_v1 : ContainerVersion = publishing_api .create_container_version (
10731084 container .pk ,
Original file line number Diff line number Diff line change 1+ """
2+ Test Django app config
3+ """
4+
5+ from django .apps import AppConfig
6+
7+
8+ class TestAppConfig (AppConfig ):
9+ """
10+ Configuration for the test Django application.
11+ """
12+
13+ name = "tests.test_django_app"
14+ label = "test_django_app"
Original file line number Diff line number Diff line change 1+ """
2+ Models that are only for use in tests
3+ """
4+
5+ from openedx_content .applets .publishing .models import Container
6+
7+
8+ class TestContainer (Container ):
9+ """
10+ A fake subclass of Container used for test purposes.
11+ """
12+
13+ CONTAINER_TYPE = "fake_test"
14+
15+ class Meta :
16+ app_label = "openedx_content"
You can’t perform that action at this time.
0 commit comments