[python-migrate] Update to 0.6 sources, fix most of the unittest issues. Still one more thing to debug.

Toshio くらとみ toshio at fedoraproject.org
Sun Aug 1 18:29:11 UTC 2010


commit 5613a6173326b9d419c318e9e2c85b654b47f36c
Author: Toshio Kuratomi <toshio at fedoraproject.org>
Date:   Sun Aug 1 14:28:40 2010 -0400

    Update to 0.6 sources, fix most of the unittest issues.  Still one more
    thing to debug.

 .gitignore                              |    1 +
 migrate-scripttest-update.patch         |   12 +
 python-migrate-sqlalchemy-migrate.patch |  459 ++++++++++++++++++++++++++++++-
 python-migrate.spec                     |   23 ++-
 sources                                 |    2 +-
 5 files changed, 488 insertions(+), 9 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index dc4b42a..47067c9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
 sqlalchemy-migrate-0.5.4.tar.gz
+sqlalchemy-migrate-0.6.tar.gz
diff --git a/migrate-scripttest-update.patch b/migrate-scripttest-update.patch
new file mode 100644
index 0000000..0fc0dc6
--- /dev/null
+++ b/migrate-scripttest-update.patch
@@ -0,0 +1,12 @@
+Index: sqlalchemy-migrate-0.6/migrate/tests/fixture/shell.py
+===================================================================
+--- sqlalchemy-migrate-0.6.orig/migrate/tests/fixture/shell.py
++++ sqlalchemy-migrate-0.6/migrate/tests/fixture/shell.py
+@@ -22,7 +22,6 @@ class Shell(Pathed):
+         log.debug('PATH for ScriptTest: %s', migrate_path)
+         self.env = TestFileEnvironment(
+             base_path=os.path.join(self.temp_usable_dir, 'env'),
+-            script_path=[migrate_path],
+         )
+ 
+     def run_version(self, repos_path):
diff --git a/python-migrate-sqlalchemy-migrate.patch b/python-migrate-sqlalchemy-migrate.patch
index cb83566..e09adb8 100644
--- a/python-migrate-sqlalchemy-migrate.patch
+++ b/python-migrate-sqlalchemy-migrate.patch
@@ -1,8 +1,8 @@
 Index: setup.py
 ===================================================================
---- setup.py
-+++ setup.py	2010-07-31 23:40:30.923637842 +0200
-@@ -32,8 +32,8 @@
+--- setup.py.orig
++++ setup.py
+@@ -32,8 +32,8 @@ setup(
      license = "MIT",
      entry_points = """
      [console_scripts]
@@ -13,3 +13,456 @@ Index: setup.py
      """,
      test_suite = "nose.collector",
  )
+Index: migrate/tests/fixture/shell.py
+===================================================================
+--- migrate/tests/fixture/shell.py.orig
++++ migrate/tests/fixture/shell.py
+@@ -25,9 +25,9 @@ class Shell(Pathed):
+         )
+ 
+     def run_version(self, repos_path):
+-        result = self.env.run('migrate version %s' % repos_path)
++        result = self.env.run('sqlalchemy-migrate version %s' % repos_path)
+         return int(result.stdout.strip())
+ 
+     def run_db_version(self, url, repos_path):
+-        result = self.env.run('migrate db_version %s %s' % (url, repos_path))
++        result = self.env.run('sqlalchemy-migrate db_version %s %s' % (url, repos_path))
+         return int(result.stdout.strip())
+Index: migrate/tests/versioning/test_shell.py
+===================================================================
+--- migrate/tests/versioning/test_shell.py.orig
++++ migrate/tests/versioning/test_shell.py
+@@ -24,15 +24,15 @@ class TestShellCommands(Shell):
+ 
+     def test_help(self):
+         """Displays default help dialog"""
+-        self.assertEqual(self.env.run('migrate -h').returncode, 0)
+-        self.assertEqual(self.env.run('migrate --help').returncode, 0)
+-        self.assertEqual(self.env.run('migrate help').returncode, 0)
++        self.assertEqual(self.env.run('sqlalchemy-migrate -h').returncode, 0)
++        self.assertEqual(self.env.run('sqlalchemy-migrate --help').returncode, 0)
++        self.assertEqual(self.env.run('sqlalchemy-migrate help').returncode, 0)
+ 
+     def test_help_commands(self):
+         """Display help on a specific command"""
+         # we can only test that we get some output
+         for cmd in api.__all__:
+-            result = self.env.run('migrate help %s' % cmd)
++            result = self.env.run('sqlalchemy-migrate help %s' % cmd)
+             self.assertTrue(isinstance(result.stdout, basestring))
+             self.assertTrue(result.stdout)
+             self.assertFalse(result.stderr)
+@@ -40,10 +40,10 @@ class TestShellCommands(Shell):
+     def test_shutdown_logging(self):
+         """Try to shutdown logging output"""
+         repos = self.tmp_repos()
+-        result = self.env.run('migrate create %s repository_name' % repos)
+-        result = self.env.run('migrate version %s --disable_logging' % repos)
++        result = self.env.run('sqlalchemy-migrate create %s repository_name' % repos)
++        result = self.env.run('sqlalchemy-migrate version %s --disable_logging' % repos)
+         self.assertEqual(result.stdout, '')
+-        result = self.env.run('migrate version %s -q' % repos)
++        result = self.env.run('sqlalchemy-migrate version %s -q' % repos)
+         self.assertEqual(result.stdout, '')
+ 
+         # TODO: assert logging messages to 0
+@@ -88,7 +88,7 @@ class TestShellCommands(Shell):
+         repos = self.tmp_repos()
+ 
+         # Creating a file that doesn't exist should succeed
+-        result = self.env.run('migrate create %s repository_name' % repos)
++        result = self.env.run('sqlalchemy-migrate create %s repository_name' % repos)
+ 
+         # Files should actually be created
+         self.assert_(os.path.exists(repos))
+@@ -98,35 +98,35 @@ class TestShellCommands(Shell):
+         self.assertNotEquals(repos_.config.get('db_settings', 'version_table'), 'None')
+ 
+         # Can't create it again: it already exists
+-        result = self.env.run('migrate create %s repository_name' % repos,
++        result = self.env.run('sqlalchemy-migrate create %s repository_name' % repos,
+             expect_error=True)
+         self.assertEqual(result.returncode, 2)
+     
+     def test_script(self):
+         """We can create a migration script via the command line"""
+         repos = self.tmp_repos()
+-        result = self.env.run('migrate create %s repository_name' % repos)
++        result = self.env.run('sqlalchemy-migrate create %s repository_name' % repos)
+ 
+-        result = self.env.run('migrate script --repository=%s Desc' % repos)
++        result = self.env.run('sqlalchemy-migrate script --repository=%s Desc' % repos)
+         self.assert_(os.path.exists('%s/versions/001_Desc.py' % repos))
+ 
+-        result = self.env.run('migrate script More %s' % repos)
++        result = self.env.run('sqlalchemy-migrate script More %s' % repos)
+         self.assert_(os.path.exists('%s/versions/002_More.py' % repos))
+ 
+-        result = self.env.run('migrate script "Some Random name" %s' % repos)
++        result = self.env.run('sqlalchemy-migrate script "Some Random name" %s' % repos)
+         self.assert_(os.path.exists('%s/versions/003_Some_Random_name.py' % repos))
+ 
+     def test_script_sql(self):
+         """We can create a migration sql script via the command line"""
+         repos = self.tmp_repos()
+-        result = self.env.run('migrate create %s repository_name' % repos)
++        result = self.env.run('sqlalchemy-migrate create %s repository_name' % repos)
+ 
+-        result = self.env.run('migrate script_sql mydb %s' % repos)
++        result = self.env.run('sqlalchemy-migrate script_sql mydb %s' % repos)
+         self.assert_(os.path.exists('%s/versions/001_mydb_upgrade.sql' % repos))
+         self.assert_(os.path.exists('%s/versions/001_mydb_downgrade.sql' % repos))
+ 
+         # Test creating a second
+-        result = self.env.run('migrate script_sql postgres --repository=%s' % repos)
++        result = self.env.run('sqlalchemy-migrate script_sql postgres --repository=%s' % repos)
+         self.assert_(os.path.exists('%s/versions/002_postgres_upgrade.sql' % repos))
+         self.assert_(os.path.exists('%s/versions/002_postgres_downgrade.sql' % repos))
+ 
+@@ -138,7 +138,7 @@ class TestShellCommands(Shell):
+         self.assert_(not os.path.exists(script))
+ 
+         # No attempt is made to verify correctness of the repository path here
+-        result = self.env.run('migrate manage %s --repository=/bla/' % script)
++        result = self.env.run('sqlalchemy-migrate manage %s --repository=/bla/' % script)
+         self.assert_(os.path.exists(script))
+ 
+ 
+@@ -149,41 +149,41 @@ class TestShellRepository(Shell):
+         """Create repository, python change script"""
+         super(TestShellRepository, self).setUp()
+         self.path_repos = self.tmp_repos()
+-        result = self.env.run('migrate create %s repository_name' % self.path_repos)
++        result = self.env.run('sqlalchemy-migrate create %s repository_name' % self.path_repos)
+ 
+     def test_version(self):
+         """Correctly detect repository version"""
+         # Version: 0 (no scripts yet); successful execution
+-        result = self.env.run('migrate version --repository=%s' % self.path_repos)
++        result = self.env.run('sqlalchemy-migrate version --repository=%s' % self.path_repos)
+         self.assertEqual(result.stdout.strip(), "0")
+ 
+         # Also works as a positional param
+-        result = self.env.run('migrate version %s' % self.path_repos)
++        result = self.env.run('sqlalchemy-migrate version %s' % self.path_repos)
+         self.assertEqual(result.stdout.strip(), "0")
+ 
+         # Create a script and version should increment
+-        result = self.env.run('migrate script Desc %s' % self.path_repos)
+-        result = self.env.run('migrate version %s' % self.path_repos)
++        result = self.env.run('sqlalchemy-migrate script Desc %s' % self.path_repos)
++        result = self.env.run('sqlalchemy-migrate version %s' % self.path_repos)
+         self.assertEqual(result.stdout.strip(), "1")
+ 
+     def test_source(self):
+         """Correctly fetch a script's source"""
+-        result = self.env.run('migrate script Desc --repository=%s' % self.path_repos)
++        result = self.env.run('sqlalchemy-migrate script Desc --repository=%s' % self.path_repos)
+ 
+         filename = '%s/versions/001_Desc.py' % self.path_repos
+         source = open(filename).read()
+         self.assert_(source.find('def upgrade') >= 0)
+ 
+         # Version is now 1
+-        result = self.env.run('migrate version %s' % self.path_repos)
++        result = self.env.run('sqlalchemy-migrate version %s' % self.path_repos)
+         self.assertEqual(result.stdout.strip(), "1")
+ 
+         # Output/verify the source of version 1
+-        result = self.env.run('migrate source 1 --repository=%s' % self.path_repos)
++        result = self.env.run('sqlalchemy-migrate source 1 --repository=%s' % self.path_repos)
+         self.assertEqual(result.stdout.strip(), source.strip())
+ 
+         # We can also send the source to a file... test that too
+-        result = self.env.run('migrate source 1 %s --repository=%s' %
++        result = self.env.run('sqlalchemy-migrate source 1 %s --repository=%s' %
+             (filename, self.path_repos))
+         self.assert_(os.path.exists(filename))
+         fd = open(filename)
+@@ -203,17 +203,17 @@ class TestShellDatabase(Shell, DB):
+         """Ensure we can set version control on a database"""
+         path_repos = repos = self.tmp_repos()
+         url = self.url
+-        result = self.env.run('migrate create %s repository_name' % repos)
++        result = self.env.run('sqlalchemy-migrate create %s repository_name' % repos)
+ 
+-        result = self.env.run('migrate drop_version_control %(url)s %(repos)s'\
++        result = self.env.run('sqlalchemy-migrate drop_version_control %(url)s %(repos)s'\
+             % locals(), expect_error=True)
+         self.assertEqual(result.returncode, 1)
+-        result = self.env.run('migrate version_control %(url)s %(repos)s' % locals())
++        result = self.env.run('sqlalchemy-migrate version_control %(url)s %(repos)s' % locals())
+ 
+         # Clean up
+-        result = self.env.run('migrate drop_version_control %(url)s %(repos)s' % locals())
++        result = self.env.run('sqlalchemy-migrate drop_version_control %(url)s %(repos)s' % locals())
+         # Attempting to drop vc from a database without it should fail
+-        result = self.env.run('migrate drop_version_control %(url)s %(repos)s'\
++        result = self.env.run('sqlalchemy-migrate drop_version_control %(url)s %(repos)s'\
+             % locals(), expect_error=True)
+         self.assertEqual(result.returncode, 1)
+ 
+@@ -222,41 +222,41 @@ class TestShellDatabase(Shell, DB):
+         """Commands with default arguments set by manage.py"""
+         path_repos = repos = self.tmp_repos()
+         url = self.url
+-        result = self.env.run('migrate create --name=repository_name %s' % repos)
+-        result = self.env.run('migrate drop_version_control %(url)s %(repos)s' % locals(), expect_error=True)
++        result = self.env.run('sqlalchemy-migrate create --name=repository_name %s' % repos)
++        result = self.env.run('sqlalchemy-migrate drop_version_control %(url)s %(repos)s' % locals(), expect_error=True)
+         self.assertEqual(result.returncode, 1)
+-        result = self.env.run('migrate version_control %(url)s %(repos)s' % locals())
++        result = self.env.run('sqlalchemy-migrate version_control %(url)s %(repos)s' % locals())
+ 
+-        result = self.env.run('migrate drop_version_control %(url)s %(repos)s' % locals())
++        result = self.env.run('sqlalchemy-migrate drop_version_control %(url)s %(repos)s' % locals())
+ 
+     @usedb()
+     def test_version_control_specified(self):
+         """Ensure we can set version control to a particular version"""
+         path_repos = self.tmp_repos()
+         url = self.url
+-        result = self.env.run('migrate create --name=repository_name %s' % path_repos)
+-        result = self.env.run('migrate drop_version_control %(url)s %(path_repos)s' % locals(), expect_error=True)
++        result = self.env.run('sqlalchemy-migrate create --name=repository_name %s' % path_repos)
++        result = self.env.run('sqlalchemy-migrate drop_version_control %(url)s %(path_repos)s' % locals(), expect_error=True)
+         self.assertEqual(result.returncode, 1)
+ 
+         # Fill the repository
+         path_script = self.tmp_py()
+         version = 2
+         for i in range(version):
+-            result = self.env.run('migrate script Desc --repository=%s' % path_repos)
++            result = self.env.run('sqlalchemy-migrate script Desc --repository=%s' % path_repos)
+ 
+         # Repository version is correct
+-        result = self.env.run('migrate version %s' % path_repos)
++        result = self.env.run('sqlalchemy-migrate version %s' % path_repos)
+         self.assertEqual(result.stdout.strip(), str(version))
+ 
+         # Apply versioning to DB
+-        result = self.env.run('migrate version_control %(url)s %(path_repos)s %(version)s' % locals())
++        result = self.env.run('sqlalchemy-migrate version_control %(url)s %(path_repos)s %(version)s' % locals())
+ 
+         # Test db version number (should start at 2)
+-        result = self.env.run('migrate db_version %(url)s %(path_repos)s' % locals())
++        result = self.env.run('sqlalchemy-migrate db_version %(url)s %(path_repos)s' % locals())
+         self.assertEqual(result.stdout.strip(), str(version))
+ 
+         # Clean up
+-        result = self.env.run('migrate drop_version_control %(url)s %(path_repos)s' % locals())
++        result = self.env.run('sqlalchemy-migrate drop_version_control %(url)s %(path_repos)s' % locals())
+ 
+     @usedb()
+     def test_upgrade(self):
+@@ -264,67 +264,67 @@ class TestShellDatabase(Shell, DB):
+         # Create a repository
+         repos_name = 'repos_name'
+         repos_path = self.tmp()
+-        result = self.env.run('migrate create %(repos_path)s %(repos_name)s' % locals())
++        result = self.env.run('sqlalchemy-migrate create %(repos_path)s %(repos_name)s' % locals())
+         self.assertEquals(self.run_version(repos_path), 0)
+ 
+         # Version the DB
+-        result = self.env.run('migrate drop_version_control %s %s' % (self.url, repos_path), expect_error=True)
+-        result = self.env.run('migrate version_control %s %s' % (self.url, repos_path))
++        result = self.env.run('sqlalchemy-migrate drop_version_control %s %s' % (self.url, repos_path), expect_error=True)
++        result = self.env.run('sqlalchemy-migrate version_control %s %s' % (self.url, repos_path))
+ 
+         # Upgrades with latest version == 0
+         self.assertEquals(self.run_db_version(self.url, repos_path), 0)
+-        result = self.env.run('migrate upgrade %s %s' % (self.url, repos_path))
++        result = self.env.run('sqlalchemy-migrate upgrade %s %s' % (self.url, repos_path))
+         self.assertEquals(self.run_db_version(self.url, repos_path), 0)
+-        result = self.env.run('migrate upgrade %s %s' % (self.url, repos_path))
++        result = self.env.run('sqlalchemy-migrate upgrade %s %s' % (self.url, repos_path))
+         self.assertEquals(self.run_db_version(self.url, repos_path), 0)
+-        result = self.env.run('migrate upgrade %s %s 1' % (self.url, repos_path), expect_error=True)
++        result = self.env.run('sqlalchemy-migrate upgrade %s %s 1' % (self.url, repos_path), expect_error=True)
+         self.assertEquals(result.returncode, 1)
+-        result = self.env.run('migrate upgrade %s %s -1' % (self.url, repos_path), expect_error=True)
++        result = self.env.run('sqlalchemy-migrate upgrade %s %s -1' % (self.url, repos_path), expect_error=True)
+         self.assertEquals(result.returncode, 2)
+ 
+         # Add a script to the repository; upgrade the db
+-        result = self.env.run('migrate script Desc --repository=%s' % (repos_path))
++        result = self.env.run('sqlalchemy-migrate script Desc --repository=%s' % (repos_path))
+         self.assertEquals(self.run_version(repos_path), 1)
+         self.assertEquals(self.run_db_version(self.url, repos_path), 0)
+ 
+         # Test preview
+-        result = self.env.run('migrate upgrade %s %s 0 --preview_sql' % (self.url, repos_path))
+-        result = self.env.run('migrate upgrade %s %s 0 --preview_py' % (self.url, repos_path))
++        result = self.env.run('sqlalchemy-migrate upgrade %s %s 0 --preview_sql' % (self.url, repos_path))
++        result = self.env.run('sqlalchemy-migrate upgrade %s %s 0 --preview_py' % (self.url, repos_path))
+ 
+-        result = self.env.run('migrate upgrade %s %s' % (self.url, repos_path))
++        result = self.env.run('sqlalchemy-migrate upgrade %s %s' % (self.url, repos_path))
+         self.assertEquals(self.run_db_version(self.url, repos_path), 1)
+         
+         # Downgrade must have a valid version specified
+-        result = self.env.run('migrate downgrade %s %s' % (self.url, repos_path), expect_error=True)
++        result = self.env.run('sqlalchemy-migrate downgrade %s %s' % (self.url, repos_path), expect_error=True)
+         self.assertEquals(result.returncode, 2)
+-        result = self.env.run('migrate downgrade %s %s -1' % (self.url, repos_path), expect_error=True)
++        result = self.env.run('sqlalchemy-migrate downgrade %s %s -1' % (self.url, repos_path), expect_error=True)
+         self.assertEquals(result.returncode, 2)
+-        result = self.env.run('migrate downgrade %s %s 2' % (self.url, repos_path), expect_error=True)
++        result = self.env.run('sqlalchemy-migrate downgrade %s %s 2' % (self.url, repos_path), expect_error=True)
+         self.assertEquals(result.returncode, 2)
+         self.assertEquals(self.run_db_version(self.url, repos_path), 1)
+         
+-        result = self.env.run('migrate downgrade %s %s 0' % (self.url, repos_path))
++        result = self.env.run('sqlalchemy-migrate downgrade %s %s 0' % (self.url, repos_path))
+         self.assertEquals(self.run_db_version(self.url, repos_path), 0)
+         
+-        result = self.env.run('migrate downgrade %s %s 1' % (self.url, repos_path), expect_error=True)
++        result = self.env.run('sqlalchemy-migrate downgrade %s %s 1' % (self.url, repos_path), expect_error=True)
+         self.assertEquals(result.returncode, 2)
+         self.assertEquals(self.run_db_version(self.url, repos_path), 0)
+ 
+-        result = self.env.run('migrate drop_version_control %s %s' % (self.url, repos_path))
++        result = self.env.run('sqlalchemy-migrate drop_version_control %s %s' % (self.url, repos_path))
+ 
+     def _run_test_sqlfile(self, upgrade_script, downgrade_script):
+         # TODO: add test script that checks if db really changed
+         repos_path = self.tmp()
+         repos_name = 'repos'
+ 
+-        result = self.env.run('migrate create %s %s' % (repos_path, repos_name))
+-        result = self.env.run('migrate drop_version_control %s %s' % (self.url, repos_path), expect_error=True)
+-        result = self.env.run('migrate version_control %s %s' % (self.url, repos_path))
++        result = self.env.run('sqlalchemy-migrate create %s %s' % (repos_path, repos_name))
++        result = self.env.run('sqlalchemy-migrate drop_version_control %s %s' % (self.url, repos_path), expect_error=True)
++        result = self.env.run('sqlalchemy-migrate version_control %s %s' % (self.url, repos_path))
+         self.assertEquals(self.run_version(repos_path), 0)
+         self.assertEquals(self.run_db_version(self.url, repos_path), 0)
+ 
+         beforeCount = len(os.listdir(os.path.join(repos_path, 'versions')))  # hmm, this number changes sometimes based on running from svn
+-        result = self.env.run('migrate script_sql %s --repository=%s' % ('postgres', repos_path))
++        result = self.env.run('sqlalchemy-migrate script_sql %s --repository=%s' % ('postgres', repos_path))
+         self.assertEquals(self.run_version(repos_path), 1)
+         self.assertEquals(len(os.listdir(os.path.join(repos_path, 'versions'))), beforeCount + 2)
+ 
+@@ -334,11 +334,11 @@ class TestShellDatabase(Shell, DB):
+         self.assertEquals(self.run_db_version(self.url, repos_path), 0)
+         self.assertRaises(Exception, self.engine.text('select * from t_table').execute)
+ 
+-        result = self.env.run('migrate upgrade %s %s' % (self.url, repos_path))
++        result = self.env.run('sqlalchemy-migrate upgrade %s %s' % (self.url, repos_path))
+         self.assertEquals(self.run_db_version(self.url, repos_path), 1)
+         self.engine.text('select * from t_table').execute()
+ 
+-        result = self.env.run('migrate downgrade %s %s 0' % (self.url, repos_path))
++        result = self.env.run('sqlalchemy-migrate downgrade %s %s 0' % (self.url, repos_path))
+         self.assertEquals(self.run_db_version(self.url, repos_path), 0)
+         self.assertRaises(Exception, self.engine.text('select * from t_table').execute)
+ 
+@@ -378,15 +378,15 @@ class TestShellDatabase(Shell, DB):
+         repos_name = 'repos_name'
+         repos_path = self.tmp()
+ 
+-        result = self.env.run('migrate create repository_name --repository=%s' % repos_path)
+-        result = self.env.run('migrate drop_version_control %s %s' % (self.url, repos_path), expect_error=True)
+-        result = self.env.run('migrate version_control %s %s' % (self.url, repos_path))
++        result = self.env.run('sqlalchemy-migrate create repository_name --repository=%s' % repos_path)
++        result = self.env.run('sqlalchemy-migrate drop_version_control %s %s' % (self.url, repos_path), expect_error=True)
++        result = self.env.run('sqlalchemy-migrate version_control %s %s' % (self.url, repos_path))
+         self.assertEquals(self.run_version(repos_path), 0)
+         self.assertEquals(self.run_db_version(self.url, repos_path), 0)
+ 
+         # Empty script should succeed
+-        result = self.env.run('migrate script Desc %s' % repos_path)
+-        result = self.env.run('migrate test %s %s' % (self.url, repos_path))
++        result = self.env.run('sqlalchemy-migrate script Desc %s' % repos_path)
++        result = self.env.run('sqlalchemy-migrate test %s %s' % (self.url, repos_path))
+         self.assertEquals(self.run_version(repos_path), 1)
+         self.assertEquals(self.run_db_version(self.url, repos_path), 0)
+ 
+@@ -408,7 +408,7 @@ class TestShellDatabase(Shell, DB):
+         file.write(script_text)
+         file.close()
+ 
+-        result = self.env.run('migrate test %s %s bla' % (self.url, repos_path), expect_error=True)
++        result = self.env.run('sqlalchemy-migrate test %s %s bla' % (self.url, repos_path), expect_error=True)
+         self.assertEqual(result.returncode, 2)
+         self.assertEquals(self.run_version(repos_path), 1)
+         self.assertEquals(self.run_db_version(self.url, repos_path), 0)
+@@ -439,7 +439,7 @@ class TestShellDatabase(Shell, DB):
+         file = open(script_path, 'w')
+         file.write(script_text)
+         file.close()
+-        result = self.env.run('migrate test %s %s' % (self.url, repos_path))
++        result = self.env.run('sqlalchemy-migrate test %s %s' % (self.url, repos_path))
+         self.assertEquals(self.run_version(repos_path), 1)
+         self.assertEquals(self.run_db_version(self.url, repos_path), 0)
+         
+@@ -459,43 +459,43 @@ class TestShellDatabase(Shell, DB):
+         self.meta.reflect()
+         self.meta.drop_all()  # in case junk tables are lying around in the test database
+ 
+-        result = self.env.run('migrate create %s %s' % (repos_path, repos_name))
+-        result = self.env.run('migrate drop_version_control %s %s' % (self.url, repos_path), expect_error=True)
+-        result = self.env.run('migrate version_control %s %s' % (self.url, repos_path))
++        result = self.env.run('sqlalchemy-migrate create %s %s' % (repos_path, repos_name))
++        result = self.env.run('sqlalchemy-migrate drop_version_control %s %s' % (self.url, repos_path), expect_error=True)
++        result = self.env.run('sqlalchemy-migrate version_control %s %s' % (self.url, repos_path))
+         self.assertEquals(self.run_version(repos_path), 0)
+         self.assertEquals(self.run_db_version(self.url, repos_path), 0)
+ 
+         # Setup helper script.
+-        result = self.env.run('migrate manage %s --repository=%s --url=%s --model=%s'\
++        result = self.env.run('sqlalchemy-migrate manage %s --repository=%s --url=%s --model=%s'\
+             % (script_path, repos_path, self.url, model_module))
+         self.assert_(os.path.exists(script_path))
+ 
+         # Model is defined but database is empty.
+-        result = self.env.run('migrate compare_model_to_db %s %s --model=%s' \
++        result = self.env.run('sqlalchemy-migrate compare_model_to_db %s %s --model=%s' \
+             % (self.url, repos_path, model_module))
+         self.assert_("tables missing in database: tmp_account_rundiffs" in result.stdout)
+ 
+         # Test Deprecation
+-        result = self.env.run('migrate compare_model_to_db %s %s --model=%s' \
++        result = self.env.run('sqlalchemy-migrate compare_model_to_db %s %s --model=%s' \
+             % (self.url, repos_path, model_module.replace(":", ".")), expect_error=True)
+         self.assertEqual(result.returncode, 0)
+         self.assertTrue("DeprecationWarning" in result.stderr)
+         self.assert_("tables missing in database: tmp_account_rundiffs" in result.stdout)
+ 
+         # Update db to latest model.
+-        result = self.env.run('migrate update_db_from_model %s %s %s'\
++        result = self.env.run('sqlalchemy-migrate update_db_from_model %s %s %s'\
+             % (self.url, repos_path, model_module))
+         self.assertEquals(self.run_version(repos_path), 0)
+         self.assertEquals(self.run_db_version(self.url, repos_path), 0)  # version did not get bumped yet because new version not yet created
+ 
+-        result = self.env.run('migrate compare_model_to_db %s %s %s'\
++        result = self.env.run('sqlalchemy-migrate compare_model_to_db %s %s %s'\
+             % (self.url, repos_path, model_module))
+         self.assert_("No schema diffs" in result.stdout)
+ 
+-        result = self.env.run('migrate drop_version_control %s %s' % (self.url, repos_path), expect_error=True)
+-        result = self.env.run('migrate version_control %s %s' % (self.url, repos_path))
++        result = self.env.run('sqlalchemy-migrate drop_version_control %s %s' % (self.url, repos_path), expect_error=True)
++        result = self.env.run('sqlalchemy-migrate version_control %s %s' % (self.url, repos_path))
+ 
+-        result = self.env.run('migrate create_model %s %s' % (self.url, repos_path))
++        result = self.env.run('sqlalchemy-migrate create_model %s %s' % (self.url, repos_path))
+         temp_dict = dict()
+         exec result.stdout in temp_dict
+ 
+@@ -509,10 +509,10 @@ class TestShellDatabase(Shell, DB):
+   ##Column('passwd', String(length=None, convert_unicode=False, assert_unicode=None))""" in result.stdout)
+ 
+         ## We're happy with db changes, make first db upgrade script to go from version 0 -> 1.
+-        #result = self.env.run('migrate make_update_script_for_model', expect_error=True)
++        #result = self.env.run('sqlalchemy-migrate make_update_script_for_model', expect_error=True)
+         #self.assertTrue('Not enough arguments' in result.stderr)
+ 
+-        #result_script = self.env.run('migrate make_update_script_for_model %s %s %s %s'\
++        #result_script = self.env.run('sqlalchemy-migrate make_update_script_for_model %s %s %s %s'\
+             #% (self.url, repos_path, old_model_module, model_module))
+         #self.assertEqualsIgnoreWhitespace(result_script.stdout,
+         #'''from sqlalchemy import *
diff --git a/python-migrate.spec b/python-migrate.spec
index d9810cb..cf5ae02 100644
--- a/python-migrate.spec
+++ b/python-migrate.spec
@@ -13,8 +13,10 @@ Group: Development/Languages
 License: MIT
 URL: http://code.google.com/p/%{srcname}/
 Source0: http://%{srcname}.googlecode.com/files/%{srcname}-%{version}.tar.gz
+# Patch to update to new scripttest API submitted upstream
+Patch0: migrate-scripttest-update.patch
 # Local patch to rename /usr/bin/migrate to sqlalchemy-migrate
-Patch0: python-migrate-sqlalchemy-migrate.patch
+Patch1: python-migrate-sqlalchemy-migrate.patch
 
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 
@@ -30,7 +32,7 @@ BuildRequires: python-decorator
 BuildRequires: python-scripttest
 BuildRequires: python-tempita
 
-Requires: python-sqlalchemy >= 0.5
+Requires: python-sqlalchemy >= 0.6
 Requires: python-setuptools
 Requires: python-decorator
 
@@ -48,7 +50,8 @@ atabase change sets and database repository versioning.
 
 %prep
 %setup -q -n %{srcname}-%{version}
-%patch0 -p0 -b .rename
+%patch0 -p1 -b .test
+%patch1 -p0 -b .rename
 
 # use real unittest in python 2.7 and up
 sed -i "s/import unittest2/import unittest as unittest2/g" \
@@ -66,9 +69,16 @@ sed -i "s/import unittest2/import unittest as unittest2/g" \
 %{__rm} -rf %{buildroot}
 
 %check
+# Need to set PATH for two reasons:
+# 1) Path isn't being cleared by mock so we have /root/bin/ in the PATH
+# 2) Need to be able to find the newly installed migrate binaries
+PATH=/bin:/usr/bin:%{buildroot}%{_bindir}
+export PATH
+
+PYTHONPATH=`pwd`
+export PYTHONPATH
 echo 'sqlite:///__tmp__' > test_db.cfg
-#%{__python} setup.py test
-#nosetests
+nosetests
 
 %files
 %defattr(-,root,root,-)
@@ -77,6 +87,9 @@ echo 'sqlite:///__tmp__' > test_db.cfg
 %{python_sitelib}/*
 
 %changelog
+* Sun Aug 1 2010 Toshio Kuratomi <toshio at fedoraproject.org> - 0.6-2
+- Update to unittests to work with newer scripttest API
+
 * Sat Jul 31 2010 Thomas Spura <tomspur at fedoraproject.org> - 0.6-1
 - update to new version
 - testsuite doesn't work right now
diff --git a/sources b/sources
index 1f64cf0..2709451 100644
--- a/sources
+++ b/sources
@@ -1 +1 @@
-7ad9e6d6dd6df701fc596bcb87380271  sqlalchemy-migrate-0.5.4.tar.gz
+84a983d9cf15cf9bf5dd1b44785f065a  sqlalchemy-migrate-0.6.tar.gz


More information about the scm-commits mailing list