summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Dahl <dahl@mcs.anl.gov>2006-10-11 21:54:30 +0000
committerDavid Dahl <dahl@mcs.anl.gov>2006-10-11 21:54:30 +0000
commit018f2351a8b7a3f9f2ed3b449a5b4744dd5ea19d (patch)
treea1f2d5da620900f103f67c56599aba2b9fc6ce28
parent998b31229cdd91a1fd0610596e83addfe28e6e0c (diff)
downloadbcfg2-018f2351a8b7a3f9f2ed3b449a5b4744dd5ea19d.tar.gz
bcfg2-018f2351a8b7a3f9f2ed3b449a5b4744dd5ea19d.tar.bz2
bcfg2-018f2351a8b7a3f9f2ed3b449a5b4744dd5ea19d.zip
added test dir and nose tests and made settings more dynamic
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@2430 ce84e21b-d406-0410-9b95-82705330c041
-rw-r--r--src/lib/Server/Hostbase/settings.py58
-rw-r--r--src/lib/Server/Hostbase/test/harness.py9
-rw-r--r--src/lib/Server/Hostbase/test/test_environ_settings.py35
-rw-r--r--src/lib/Server/Hostbase/test/test_settings.py14
4 files changed, 94 insertions, 22 deletions
diff --git a/src/lib/Server/Hostbase/settings.py b/src/lib/Server/Hostbase/settings.py
index 5176167fe..da8f625ca 100644
--- a/src/lib/Server/Hostbase/settings.py
+++ b/src/lib/Server/Hostbase/settings.py
@@ -1,48 +1,64 @@
# Django settings for Hostbase project.
-
DEBUG = True
TEMPLATE_DEBUG = DEBUG
-
ADMINS = (
# ('Your Name', 'your_email@domain.com'),
)
-
MANAGERS = ADMINS
-
-DATABASE_ENGINE = 'mysql' # 'postgresql', 'mysql', 'sqlite3' or 'ado_mssql'.
-DATABASE_NAME = 'hosttest' # Or path to database file if using sqlite3.
-DATABASE_USER = 'hosttest' # Not used with sqlite3.
-DATABASE_PASSWORD = 'marathon' # Not used with sqlite3.
-DATABASE_HOST = 'mysql.mcs.anl.gov' # Set to empty string for localhost. Not used with sqlite3.
-DATABASE_PORT = '3306' # Set to empty string for default. Not used with sqlite3.
-
-# Local time zone for this installation. All choices can be found here:
-# http://www.postgresql.org/docs/current/static/datetime-keywords.html#DATETIME-TIMEZONE-SET-TABLE
-TIME_ZONE = 'America/Chicago'
+CFG_TYPE = 'mcs'
+
+if CFG_TYPE == 'mcs':
+ # 'postgresql', 'mysql', 'sqlite3' or 'ado_mssql'.
+ DATABASE_ENGINE = 'mysql'
+ # Or path to database file if using sqlite3.
+ DATABASE_NAME = 'hosttest'
+ # Not used with sqlite3.
+ DATABASE_USER = 'hosttest'
+ # Not used with sqlite3.
+ DATABASE_PASSWORD = 'marathon'
+ # Set to empty string for localhost. Not used with sqlite3.
+ DATABASE_HOST = 'mysql.mcs.anl.gov'
+ # Set to empty string for default. Not used with sqlite3.
+ DATABASE_PORT = '3306'
+ # Local time zone for this installation. All choices can be found here:
+ # http://www.postgresql.org/docs/current/static/datetime-keywords.html#DATETIME-TIMEZONE-SET-TABLE
+ TIME_ZONE = 'America/Chicago'
+
+if CFG_TYPE == 'environ':
+ import os
+ # 'postgresql', 'mysql', 'sqlite3' or 'ado_mssql'.
+ DATABASE_ENGINE = os.envoiron['bcfg_db_engine']
+ # Or path to database file if using sqlite3.
+ DATABASE_NAME = os.environ['bcfg_db_name']
+ # Not used with sqlite3.
+ DATABASE_USER = os.environ['bcfg_db_user']
+ # Not used with sqlite3.
+ DATABASE_PASSWORD = os.environ['bcfg_db_password']
+ # Set to empty string for localhost. Not used with sqlite3.
+ DATABASE_HOST = os.environ['bcfg_db_host']
+ # Set to empty string for default. Not used with sqlite3.
+ DATABASE_PORT = os.environ['bcfg_db_port']
+ # Local time zone for this installation. All choices can be found here:
+ # http://www.postgresql.org/docs/current/static/datetime-keywords.html#DATETIME-TIMEZONE-SET-TABLE
+ TIME_ZONE = os.environ['bcfg_time_zone']
# Language code for this installation. All choices can be found here:
# http://www.w3.org/TR/REC-html40/struct/dirlang.html#langcodes
# http://blogs.law.harvard.edu/tech/stories/storyReader$15
LANGUAGE_CODE = 'en-us'
-
SITE_ID = 1
-
# Absolute path to the directory that holds media.
# Example: "/home/media/media.lawrence.com/"
MEDIA_ROOT = ''
-
# URL that handles the media served from MEDIA_ROOT.
# Example: "http://media.lawrence.com"
MEDIA_URL = ''
-
# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
# trailing slash.
# Examples: "http://foo.com/media/", "/media/".
ADMIN_MEDIA_PREFIX = '/media/'
-
# Make this unique, and don't share it with anybody.
SECRET_KEY = '*%=fv=yh9zur&gvt4&*d#84o(cy^-*$ox-v1e9%32pzf2*qu#s'
-
# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.load_template_source',
@@ -78,5 +94,3 @@ INSTALLED_APPS = (
'Hostbase.hostbase',
)
-DEFAULT_MX = 'mailgw.mcs.anl.gov'
-PRIORITY = 30
diff --git a/src/lib/Server/Hostbase/test/harness.py b/src/lib/Server/Hostbase/test/harness.py
new file mode 100644
index 000000000..05e473609
--- /dev/null
+++ b/src/lib/Server/Hostbase/test/harness.py
@@ -0,0 +1,9 @@
+import os, sys
+
+here = os.path.realpath('harness')
+
+server_hostbase = os.path.realpath(here + '../../../../')
+
+sys.path.insert(0,server_hostbase)
+sys.path.insert(0,server_hostbase + '../')
+sys.path.insert(0,'/home/dahl/Code/bcfg2/src/lib/Server/Hostbase')
diff --git a/src/lib/Server/Hostbase/test/test_environ_settings.py b/src/lib/Server/Hostbase/test/test_environ_settings.py
new file mode 100644
index 000000000..606d87f5d
--- /dev/null
+++ b/src/lib/Server/Hostbase/test/test_environ_settings.py
@@ -0,0 +1,35 @@
+import sys
+import os
+
+
+def env_setup():
+ os.environ['bcfg_db_engine'] = 'foo'
+ os.environ['bcfg_db_name'] = 'bar'
+ os.environ['bcfg_db_user'] = 'baz'
+ os.environ['bcfg_db_password'] = 'pass'
+ os.environ['bcfg_db_host'] = 'biff'
+ os.environ['bcfg_db_port'] = '3306'
+ os.environ['bcfg_time_zone'] = 'CHI'
+
+def teardown():
+ pass
+
+def test_environ_settings():
+
+ os.environ['bcfg_db_engine'] = 'foo'
+ os.environ['bcfg_db_name'] = 'bar'
+ os.environ['bcfg_db_user'] = 'baz'
+ os.environ['bcfg_db_password'] = 'pass'
+ os.environ['bcfg_db_host'] = 'biff'
+ os.environ['bcfg_db_port'] = '3306'
+ os.environ['bcfg_time_zone'] = 'CHI'
+ import Hostbase.settings
+ s = Hostbase.settings
+ s.CFG_TYPE = 'environ'
+ assert s.DATABASE_ENGINE == 'mysql'
+ assert s.DATABASE_PASSWORD == 'pass'
+ assert s.DATABASE_NAME == 'bar'
+ assert s.DATABASE_USER == 'baz'
+ assert s.DATABASE_HOST == 'biff'
+ assert s.DATABASE_PORT == '3306'
+ assert s.TIME_ZONE == 'CHI'
diff --git a/src/lib/Server/Hostbase/test/test_settings.py b/src/lib/Server/Hostbase/test/test_settings.py
new file mode 100644
index 000000000..0040b3ab8
--- /dev/null
+++ b/src/lib/Server/Hostbase/test/test_settings.py
@@ -0,0 +1,14 @@
+import sys
+import os
+import Hostbase.settings
+
+def setup():
+ pass
+
+def teardown():
+ pass
+
+def test_mcs_settings():
+ pass
+
+