# Path: pyrseas/testutils.py
# class DbMigrateTestCase(TestCase):
# 
#     @classmethod
#     def setUpClass(cls):
#         cls.srcdb = _connect_clear(TEST_DBNAME_SRC)
#         cls.db = _connect_clear(TEST_DBNAME)
#         progdir = os.path.abspath(os.path.dirname(__file__))
#         cls.dbtoyaml = os.path.join(progdir, 'dbtoyaml.py')
#         cls.yamltodb = os.path.join(progdir, 'yamltodb.py')
#         cls.tmpdir = TEST_DIR
#         if not os.path.exists(cls.tmpdir):
#             os.mkdir(cls.tmpdir)
# 
#     def add_public_schema(self, db):
#         db.execute("CREATE SCHEMA IF NOT EXISTS public")
#         db.execute("ALTER SCHEMA public OWNER TO postgres")
#         db.execute("COMMENT ON SCHEMA public IS "
#                          "'standard public schema'")
#         db.execute("DROP SCHEMA IF EXISTS sd")
#         db.conn.commit()
# 
#     def remove_public_schema(self, db):
#         db.execute("DROP SCHEMA IF EXISTS public CASCADE")
#         db.conn.commit()
# 
#     @classmethod
#     def remove_tempfiles(cls, prefix):
#         remove_temp_files(cls.tmpdir, prefix)
# 
#     def execute_script(self, path, scriptname):
#         scriptfile = os.path.join(os.path.abspath(os.path.dirname(path)),
#                                   scriptname)
#         lines = []
#         with open(scriptfile, 'r') as fd:
#             lines = [line.strip() for line in fd if line != '\n' and
#                      not line.startswith('--')]
#         self.srcdb.execute_commit(' '.join(lines))
# 
#     def tempfile_path(self, filename):
#         return os.path.join(self.tmpdir, filename)
# 
#     def _db_params(self):
#         args = []
#         if self.db.host is not None:
#             args.append("--host=%s" % self.db.host)
#         if self.db.port is not None:
#             args.append("--port=%d " % self.db.port)
#         if self.db.user is not None:
#             args.append("--username=%s" % self.db.user)
#         return args
# 
#     def lines(self, the_file):
#         with open(the_file) as f:
#             lines = f.readlines()
#         return lines
# 
#     def run_pg_dump(self, dumpfile, srcdb=False, incldata=False):
#         """Run pg_dump using special scripts or directly (on Travis-CI)
# 
#         :param dumpfile: path to the pg_dump output file
#         :param srcdb: run against source database
#         """
#         if TRAVIS:
#             pg_dumpver = 'pg_dump'
#         else:
#             v = self.srcdb._version
#             pg_dumpver = "pg_dump%d%d" % (v // 10000,
#                                           (v - v // 10000 * 10000) // 100)
#             if sys.platform == 'win32':
#                 pg_dumpver += '.bat'
#         dbname = self.srcdb.name if srcdb else self.db.name
#         args = [pg_dumpver]
#         args.extend(self._db_params())
#         if not incldata:
#             args.extend(['-s'])
#         args.extend(['-f', dumpfile, dbname])
#         subprocess.check_call(args)
# 
#     def invoke(self, args):
#         args.insert(0, sys.executable)
#         path = [os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))]
#         path.append(os.path.abspath(os.path.join(os.path.dirname(
#                     yaml.__file__), '..')))
#         env = os.environ.copy()
#         env.update({'PYTHONPATH': os.pathsep.join(path)})
#         subprocess.check_call(args, env=env)
# 
#     def create_yaml(self, yamlfile='', srcdb=False):
#         dbname = self.srcdb.name if srcdb else self.db.name
#         args = [self.dbtoyaml]
#         args.extend(self._db_params())
#         if yamlfile:
#             args.extend(['-o', yamlfile, dbname])
#         else:
#             args.extend(['-r', TEST_DIR, '-m', dbname])
#         self.invoke(args)
# 
#     def migrate_target(self, yamlfile, outfile):
#         args = [self.yamltodb]
#         args.extend(self._db_params())
#         if yamlfile:
#             args.extend(['-u', '-o', outfile, self.db.name, yamlfile])
#         else:
#             args.extend(['-u', '-o', outfile, '-r', TEST_DIR, '-m',
#                          self.db.name])
#         self.invoke(args)


from pyrseas.testutils import DbMigrateTestCase
# -*- coding: utf-8 -*-
"""Test dbtoyaml and yamltodb using autodoc schema

See http://cvs.pgfoundry.org/cgi-bin/cvsweb.cgi/~checkout~/autodoc/autodoc/
regressdatabase.sql?rev=1.2
"""


class AutodocTestCase(DbMigrateTestCase):

    def setUp(self):

# Path: pyrseas/testutils.py
# class DbMigrateTestCase(TestCase):
# 
#     @classmethod
#     def setUpClass(cls):
#         cls.srcdb = _connect_clear(TEST_DBNAME_SRC)
#         cls.db = _connect_clear(TEST_DBNAME)
#         progdir = os.path.abspath(os.path.dirname(__file__))
#         cls.dbtoyaml = os.path.join(progdir, 'dbtoyaml.py')
#         cls.yamltodb = os.path.join(progdir, 'yamltodb.py')
#         cls.tmpdir = TEST_DIR
#         if not os.path.exists(cls.tmpdir):
#             os.mkdir(cls.tmpdir)
# 
#     def add_public_schema(self, db):
#         db.execute("CREATE SCHEMA IF NOT EXISTS public")
#         db.execute("ALTER SCHEMA public OWNER TO postgres")
#         db.execute("COMMENT ON SCHEMA public IS "
#                          "'standard public schema'")
#         db.execute("DROP SCHEMA IF EXISTS sd")
#         db.conn.commit()
# 
#     def remove_public_schema(self, db):
#         db.execute("DROP SCHEMA IF EXISTS public CASCADE")
#         db.conn.commit()
# 
#     @classmethod
#     def remove_tempfiles(cls, prefix):
#         remove_temp_files(cls.tmpdir, prefix)
# 
#     def execute_script(self, path, scriptname):
#         scriptfile = os.path.join(os.path.abspath(os.path.dirname(path)),
#                                   scriptname)
#         lines = []
#         with open(scriptfile, 'r') as fd:
#             lines = [line.strip() for line in fd if line != '\n' and
#                      not line.startswith('--')]
#         self.srcdb.execute_commit(' '.join(lines))
# 
#     def tempfile_path(self, filename):
#         return os.path.join(self.tmpdir, filename)
# 
#     def _db_params(self):
#         args = []
#         if self.db.host is not None:
#             args.append("--host=%s" % self.db.host)
#         if self.db.port is not None:
#             args.append("--port=%d " % self.db.port)
#         if self.db.user is not None:
#             args.append("--username=%s" % self.db.user)
#         return args
# 
#     def lines(self, the_file):
#         with open(the_file) as f:
#             lines = f.readlines()
#         return lines
# 
#     def run_pg_dump(self, dumpfile, srcdb=False, incldata=False):
#         """Run pg_dump using special scripts or directly (on Travis-CI)
# 
#         :param dumpfile: path to the pg_dump output file
#         :param srcdb: run against source database
#         """
#         if TRAVIS:
#             pg_dumpver = 'pg_dump'
#         else:
#             v = self.srcdb._version
#             pg_dumpver = "pg_dump%d%d" % (v // 10000,
#                                           (v - v // 10000 * 10000) // 100)
#             if sys.platform == 'win32':
#                 pg_dumpver += '.bat'
#         dbname = self.srcdb.name if srcdb else self.db.name
#         args = [pg_dumpver]
#         args.extend(self._db_params())
#         if not incldata:
#             args.extend(['-s'])
#         args.extend(['-f', dumpfile, dbname])
#         subprocess.check_call(args)
# 
#     def invoke(self, args):
#         args.insert(0, sys.executable)
#         path = [os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))]
#         path.append(os.path.abspath(os.path.join(os.path.dirname(
#                     yaml.__file__), '..')))
#         env = os.environ.copy()
#         env.update({'PYTHONPATH': os.pathsep.join(path)})
#         subprocess.check_call(args, env=env)
# 
#     def create_yaml(self, yamlfile='', srcdb=False):
#         dbname = self.srcdb.name if srcdb else self.db.name
#         args = [self.dbtoyaml]
#         args.extend(self._db_params())
#         if yamlfile:
#             args.extend(['-o', yamlfile, dbname])
#         else:
#             args.extend(['-r', TEST_DIR, '-m', dbname])
#         self.invoke(args)
# 
#     def migrate_target(self, yamlfile, outfile):
#         args = [self.yamltodb]
#         args.extend(self._db_params())
#         if yamlfile:
#             args.extend(['-u', '-o', outfile, self.db.name, yamlfile])
#         else:
#             args.extend(['-u', '-o', outfile, '-r', TEST_DIR, '-m',
#                          self.db.name])
#         self.invoke(args)


# Path: tests/functional/test_autodoc.py
from pyrseas.testutils import DbMigrateTestCase

# -*- coding: utf-8 -*-
"""Test dbtoyaml and yamltodb using autodoc schema

See http://cvs.pgfoundry.org/cgi-bin/cvsweb.cgi/~checkout~/autodoc/autodoc/
regressdatabase.sql?rev=1.2
"""


class AutodocTestCase(DbMigrateTestCase):

    def setUp(self):

        super(DbMigrateTestCase, self).setUp()