Makes a new model at runtime and ensures it goes into the right place.
(self)
| 293 | apps.models_ready = True |
| 294 | |
| 295 | def test_dynamic_load(self): |
| 296 | """ |
| 297 | Makes a new model at runtime and ensures it goes into the right place. |
| 298 | """ |
| 299 | old_models = list(apps.get_app_config("apps").get_models()) |
| 300 | # Construct a new model in a new app registry |
| 301 | body = {} |
| 302 | new_apps = Apps(["apps"]) |
| 303 | meta_contents = { |
| 304 | "app_label": "apps", |
| 305 | "apps": new_apps, |
| 306 | } |
| 307 | meta = type("Meta", (), meta_contents) |
| 308 | body["Meta"] = meta |
| 309 | body["__module__"] = TotallyNormal.__module__ |
| 310 | temp_model = type("SouthPonies", (models.Model,), body) |
| 311 | # Make sure it appeared in the right place! |
| 312 | self.assertEqual(list(apps.get_app_config("apps").get_models()), old_models) |
| 313 | with self.assertRaises(LookupError): |
| 314 | apps.get_model("apps", "SouthPonies") |
| 315 | self.assertEqual(new_apps.get_model("apps", "SouthPonies"), temp_model) |
| 316 | |
| 317 | def test_model_clash(self): |
| 318 | """ |
nothing calls this directly
no test coverage detected