Example #1
0
 def test_clone_schema(self):
     utils._create_clone_schema_function()
     self.assertFalse(
         utils.schema_exists("sample2"))  # Schema doesn't exist previously
     utils.clone_schema("sample", "sample2", dry_run=True)  # Dry run
     self.assertFalse(
         utils.schema_exists("sample2"))  # Schema won't exist, dry run
     utils.clone_schema("sample", "sample2")  # Real run, schema was cloned
     self.assertTrue(utils.schema_exists("sample2"))  # Schema exists
     with self.assertRaises(InternalError):
         utils.clone_schema("sample",
                            "sample2")  # Schema already exists, error
     self.assertTrue(utils.schema_exists("sample2"))  # Schema still exists
Example #2
0
    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 fixup():
     utils._create_clone_schema_function()