Commits

Anonymous committed 33925a8

[soc2010/app-loading] store normalized version of INSTALLED_APPS in appcache

Comments (0)

Files changed (2)

django/core/apps.py

         # List of App instances
         app_instances = [],
 
+        # Normalized list of INSTALLED_APPS
+        # This stores the module name of settings.INSTALLED_APPS
+        # e.g. 'django.contrib.auth' for 'django.contrib.auth.AuthApp'
+        installed_apps = [],
+
         # Mapping of app_labels to a dictionary of model names to model code.
         app_models = SortedDict(),
 
         app_instance = self.find_app(app_name)
         if not app_instance:
             if '.' in app_name:
+                # get the app label from the full path
                 app_instance_name = app_name.rsplit('.', 1)[1]
             else:
                 app_instance_name = app_name
             app_instance = app_class(app_instance_name)
             self.app_instances.append(app_instance)
+            self.installed_apps.append(app_name)
 
         # check if the app instance specifies a path to models
         # if not, we use the models.py file from the package dir

tests/appcachetests/runtests.py

         # because thread.RLock is un(deep)copyable
         cache.app_models = SortedDict()
         cache.app_instances = []
+        cache.installed_apps = []
 
         cache.loaded = False
         cache.handled = {}
         """
         self.assertRaises(ImportError, cache.load_app, 'garageland')
 
+    def test_installed_apps(self):
+        """
+        Test that the installed_apps attribute is populated correctly
+        """
+        settings.INSTALLED_APPS = ('model_app', 'nomodel_app.MyApp',)
+        # populate cache
+        cache.get_app_errors()
+        self.assertEqual(cache.installed_apps, ['model_app', 'nomodel_app',])
+
 class RegisterModelsTests(AppCacheTestCase):
     """Tests for the register_models function"""
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.