def setup_module(): # Replace models.AppOutput with empty model to avoid dealing with # required fields and foreign keys. Replace it after tests run. global _AppOutput model = _AppOutput = models.AppOutput meta = type('Meta', (), {'db_table': 'appoutput_test'}) del loading.cache.app_models[model._meta.app_label][model._meta.model_name] models.AppOutput = type('AppOutput', (models.models.Model,), {'__module__': model.__module__, 'Meta': meta}) dyn.create_table(models.AppOutput)
def setUp(self): # Replace models.Analysis with empty model to avoid dealing with # required fields and foreign keys. Replace it after tests run. self._Analysis = models.Analysis #del loading.cache.app_models[models.Analysis._meta.app_label][models.Analysis._meta.model_name] loading.cache.app_models.get(models.Analysis._meta.app_label, {}).pop(models.Analysis._meta.model_name, None) class Analysis(models.models.Model): project = models.models.ForeignKey(models.Project) class Meta: app_label = 'projects' db_table = 'projects_analysis_test' dyn.create_table(Analysis) setup_test_environment() self.user = models.User.objects.create(username='******')
def test_create(model): self.assertFalse(dyn.table_exists(model)) dyn.create_table(model) self.assertTrue(dyn.table_exists(model))