def tearDownClass(cls): super().tearDownClass() for key in settings.TENANTS: if key == "default": continue drop_schema(key) drop_schema("tenant") call_command("migrateschema", verbosity=0)
def test_create_drop_schema(self): self.assertFalse(utils.create_schema( "public", check_if_exists=True)) # Schema existed already self.assertTrue(utils.schema_exists("public")) # Schema exists self.assertTrue(utils.drop_schema("public")) # Schema was dropped self.assertFalse( utils.drop_schema("public")) # Schema no longer exists self.assertFalse(utils.schema_exists("public")) # Schema doesn't exist self.assertTrue(utils.create_schema( "public", sync_schema=False)) # Schema was created self.assertTrue(utils.schema_exists("public")) # Schema exists
def test_cloneschema(self): "Tests 'cloneschema' command" utils._create_clone_schema_function() self.assertFalse(utils.schema_exists("cloned")) call_command("cloneschema", "sample", "cloned", verbosity=0) # All good self.assertTrue(utils.schema_exists("cloned")) with self.assertRaises(CommandError): # Existing destination call_command("cloneschema", "sample", "cloned", verbosity=0) with self.assertRaises(CommandError): # Not existing source call_command("cloneschema", "nonexisting", "newschema", verbosity=0) utils.drop_schema("cloned")
def test_createrefschema(self): "Tests 'createrefschema' command" utils.drop_schema("cloned") call_command("createrefschema", verbosity=0) # All good self.assertTrue(utils.schema_exists("sample")) utils.drop_schema("cloned") call_command("createrefschema", recreate=True, verbosity=0) # All good too self.assertTrue(utils.schema_exists("sample")) utils.drop_schema("cloned") call_command("createrefschema", recreate=True, verbosity=0) # All good too self.assertTrue(utils.schema_exists("sample"))
def test_dynamic_models_exist(self): self.assertTrue(utils.dynamic_models_exist()) utils.drop_schema("public") self.assertFalse(utils.dynamic_models_exist())