:file:`web_scripts` directory, and require some configuration if you
plan on running them locally.
-Custom configuration can be specified in the :file:`config` file (located
-at :file:`tests/config`. This is actually a Bash script to be sourced
-by the real test script (:file:`tests/setup`), which exports various
-environment variables that Wizard will use during installation.
+Custom configuration can be specified in the :file:`config` file (located at
+:file:`tests/config`). This is actually a Bash script to be sourced by the
+real test script (:file:`tests/setup`), which exports various environment
+variables that Wizard will use during installation. You should only need to
+set these variables if you're attempting to run these tests off of a
+non-scripts server.
-Here is a sample file::
+Here is a sample :file:`config` file::
MYSQL_ARGS="-uroot -ppassword"
export WIZARD_DSN="mysql://root:password@localhost/wizard_test_$TESTID"
export WIZARD_EMAIL="bob@example.com"
-You will need to specify all of these environment variables. Those prefixed
-with ``WIZARD`` are directly used by Wizard, while the ``MYSQL`` environment
-variables are used if a test script wants to interactive directly with a
-MYSQL database. We don't quite have a good story for alternative databases
-in test scripts.
+You will need to specify all of the environment variables in the
+:file:`config`. Those prefixed with ``WIZARD`` are directly used by Wizard,
+while the ``MYSQL`` environment variables are used if a test script wants to
+interactive directly with a MYSQL database. We don't quite have a good story
+for alternative databases in test scripts.
* :envvar:`WIZARD_WEB_HOST` and :envvar:`WIZARD_WEB_PATH` indicate Wizard's
configuration with respect to your web server.
identify any particular test.
* :envvar:`WIZARD_EMAIL` is any email address you
own that will be configured as an administrative email.
-
def remove_database(deployment):
"""
- Generic database removal function.
+ Generic database removal function. Actually, not so generic because we
+ go and check if we're on scripts and if we are run a different command.
"""
+ sh = shell.Shell()
+ if deployment.dsn.host == "sql.mit.edu":
+ try:
+ sh.call("/mit/scripts/sql/bin/drop-database", deployment.dsn.database)
+ return
+ except shell.CallError:
+ pass
engine = sqlalchemy.create_engine(deployment.dsn)
engine.execute("DROP DATABASE `%s`" % deployment.dsn.database)
def dsn_callback(options):
if not isinstance(options.dsn, sqlalchemy.engine.url.URL):
options.dsn = sqlalchemy.engine.url.make_url(options.dsn)
+ # perform some sanity checks on the database
+ database = options.dsn.database
+ options.dsn.database = None
+ engine = sqlalchemy.create_engine(options.dsn)
+ # generates warnings yeah yeah
+ engine.execute("CREATE DATABASE IF NOT EXISTS `%s`" % database)
+ options.dsn.database = database
+ # XXX: another good thing to check might be that the database is empty
# XXX: This is in the wrong place
def fetch(options, path, post=None):