##// END OF EJS Templates
implemented basic (startup) nose test suite.
marcink -
r459:7c978511 default
parent child Browse files
Show More
@@ -0,0 +1,155 b''
1 ################################################################################
2 ################################################################################
3 # pylons_app - Pylons environment configuration #
4 # #
5 # The %(here)s variable will be replaced with the parent directory of this file#
6 ################################################################################
7
8 [DEFAULT]
9 debug = true
10 ############################################
11 ## Uncomment and replace with the address ##
12 ## which should receive any error reports ##
13 ############################################
14 #email_to = admin@localhost
15 #smtp_server = mail.server.com
16 #error_email_from = paste_error@localhost
17 #smtp_username =
18 #smtp_password =
19 #error_message = 'mercurial crash !'
20
21 [server:main]
22 ##nr of threads to spawn
23 threadpool_workers = 5
24
25 ##max request before
26 threadpool_max_requests = 2
27
28 ##option to use threads of process
29 use_threadpool = true
30
31 use = egg:Paste#http
32 host = 127.0.0.1
33 port = 5000
34
35 [app:main]
36 use = egg:pylons_app
37 full_stack = true
38 static_files = true
39 lang=en
40 cache_dir = %(here)s/data
41
42 ####################################
43 ### BEAKER CACHE ####
44 ####################################
45 beaker.cache.data_dir=/%(here)s/data/cache/data
46 beaker.cache.lock_dir=/%(here)s/data/cache/lock
47 beaker.cache.regions=super_short_term,short_term,long_term
48 beaker.cache.long_term.type=memory
49 beaker.cache.long_term.expire=36000
50 beaker.cache.short_term.type=memory
51 beaker.cache.short_term.expire=60
52 beaker.cache.super_short_term.type=memory
53 beaker.cache.super_short_term.expire=10
54
55 ####################################
56 ### BEAKER SESSION ####
57 ####################################
58 ## Type of storage used for the session, current types are
59 ## “dbm”, “file”, “memcached”, “database”, and “memory”.
60 ## The storage uses the Container API
61 ##that is also used by the cache system.
62 beaker.session.type = file
63
64 beaker.session.key = hg-app
65 beaker.session.secret = g654dcno0-9873jhgfreyu
66 beaker.session.timeout = 36000
67
68 ##auto save the session to not to use .save()
69 beaker.session.auto = False
70
71 ##true exire at browser close
72 #beaker.session.cookie_expires = 3600
73
74
75 ################################################################################
76 ## WARNING: *THE LINE BELOW MUST BE UNCOMMENTED ON A PRODUCTION ENVIRONMENT* ##
77 ## Debug mode will enable the interactive debugging tool, allowing ANYONE to ##
78 ## execute malicious code after an exception is raised. ##
79 ################################################################################
80 #set debug = false
81
82 ##################################
83 ### LOGVIEW CONFIG ###
84 ##################################
85 logview.sqlalchemy = #faa
86 logview.pylons.templating = #bfb
87 logview.pylons.util = #eee
88
89 #########################################################
90 ### DB CONFIGS - EACH DB WILL HAVE IT'S OWN CONFIG ###
91 #########################################################
92 sqlalchemy.db1.url = sqlite:///%(here)s/test.db
93 #sqlalchemy.db1.echo = False
94 #sqlalchemy.db1.pool_recycle = 3600
95 sqlalchemy.convert_unicode = true
96
97 ################################
98 ### LOGGING CONFIGURATION ####
99 ################################
100 [loggers]
101 keys = root, routes, pylons_app, sqlalchemy
102
103 [handlers]
104 keys = console
105
106 [formatters]
107 keys = generic,color_formatter
108
109 #############
110 ## LOGGERS ##
111 #############
112 [logger_root]
113 level = ERROR
114 handlers = console
115
116 [logger_routes]
117 level = ERROR
118 handlers = console
119 qualname = routes.middleware
120 # "level = DEBUG" logs the route matched and routing variables.
121
122 [logger_pylons_app]
123 level = ERROR
124 handlers = console
125 qualname = pylons_app
126 propagate = 0
127
128 [logger_sqlalchemy]
129 level = ERROR
130 handlers = console
131 qualname = sqlalchemy.engine
132 propagate = 0
133
134 ##############
135 ## HANDLERS ##
136 ##############
137
138 [handler_console]
139 class = StreamHandler
140 args = (sys.stderr,)
141 level = NOTSET
142 formatter = color_formatter
143
144 ################
145 ## FORMATTERS ##
146 ################
147
148 [formatter_generic]
149 format = %(asctime)s.%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s
150 datefmt = %Y-%m-%d %H:%M:%S
151
152 [formatter_color_formatter]
153 class=pylons_app.lib.colored_formatter.ColorFormatter
154 format= %(asctime)s.%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s
155 datefmt = %Y-%m-%d %H:%M:%S No newline at end of file
@@ -52,7 +52,7 b' def load_environment(global_conf, app_co'
52
52
53 #MULTIPLE DB configs
53 #MULTIPLE DB configs
54 # Setup the SQLAlchemy database engine
54 # Setup the SQLAlchemy database engine
55 if config['debug']:
55 if config['debug'] and os.path.split(config['__file__'])[-1] != 'tests.ini':
56 #use query time debugging.
56 #use query time debugging.
57 from pylons_app.lib.timerproxy import TimerProxy
57 from pylons_app.lib.timerproxy import TimerProxy
58 sa_engine_db1 = engine_from_config(config, 'sqlalchemy.db1.',
58 sa_engine_db1 = engine_from_config(config, 'sqlalchemy.db1.',
@@ -71,18 +71,17 b' def make_map(config):'
71 map.resource('user', 'users', controller='admin/users', path_prefix='/_admin')
71 map.resource('user', 'users', controller='admin/users', path_prefix='/_admin')
72 map.resource('permission', 'permissions', controller='admin/permissions', path_prefix='/_admin')
72 map.resource('permission', 'permissions', controller='admin/permissions', path_prefix='/_admin')
73
73
74 #map.resource('setting', 'settings', controller='admin/settings', path_prefix='/_admin', name_prefix='admin_')
75 #REST SETTINGS MAP
74 #REST SETTINGS MAP
76 with map.submapper(path_prefix='/_admin', controller='admin/settings') as m:
75 with map.submapper(path_prefix='/_admin', controller='admin/settings') as m:
77 m.connect("admin_settings", "/settings",
76 m.connect("admin_settings", "/settings",
78 action="create", conditions=dict(method=["POST"]))
77 action="create", conditions=dict(method=["POST"]))
79 m.connect("admin_settings", "/settings",
78 m.connect("admin_settings", "/settings",
80 action="index", conditions=dict(method=["GET"]))
79 action="index", conditions=dict(method=["GET"]))
81 m.connect("admin_formatted_settings", "/settings.{format}",
80 m.connect("formatted_admin_settings", "/settings.{format}",
82 action="index", conditions=dict(method=["GET"]))
81 action="index", conditions=dict(method=["GET"]))
83 m.connect("admin_new_setting", "/settings/new",
82 m.connect("admin_new_setting", "/settings/new",
84 action="new", conditions=dict(method=["GET"]))
83 action="new", conditions=dict(method=["GET"]))
85 m.connect("admin_formatted_new_setting", "/settings/new.{format}",
84 m.connect("formatted_admin_new_setting", "/settings/new.{format}",
86 action="new", conditions=dict(method=["GET"]))
85 action="new", conditions=dict(method=["GET"]))
87 m.connect("/settings/{setting_id}",
86 m.connect("/settings/{setting_id}",
88 action="update", conditions=dict(method=["PUT"]))
87 action="update", conditions=dict(method=["PUT"]))
@@ -90,11 +89,11 b' def make_map(config):'
90 action="delete", conditions=dict(method=["DELETE"]))
89 action="delete", conditions=dict(method=["DELETE"]))
91 m.connect("admin_edit_setting", "/settings/{setting_id}/edit",
90 m.connect("admin_edit_setting", "/settings/{setting_id}/edit",
92 action="edit", conditions=dict(method=["GET"]))
91 action="edit", conditions=dict(method=["GET"]))
93 m.connect("admin_formatted_edit_setting", "/settings/{setting_id}.{format}/edit",
92 m.connect("formatted_admin_edit_setting", "/settings/{setting_id}.{format}/edit",
94 action="edit", conditions=dict(method=["GET"]))
93 action="edit", conditions=dict(method=["GET"]))
95 m.connect("admin_setting", "/settings/{setting_id}",
94 m.connect("admin_setting", "/settings/{setting_id}",
96 action="show", conditions=dict(method=["GET"]))
95 action="show", conditions=dict(method=["GET"]))
97 m.connect("admin_formatted_setting", "/settings/{setting_id}.{format}",
96 m.connect("formatted_admin_setting", "/settings/{setting_id}.{format}",
98 action="show", conditions=dict(method=["GET"]))
97 action="show", conditions=dict(method=["GET"]))
99 m.connect("admin_settings_my_account", "/my_account",
98 m.connect("admin_settings_my_account", "/my_account",
100 action="my_account", conditions=dict(method=["GET"]))
99 action="my_account", conditions=dict(method=["GET"]))
@@ -30,9 +30,7 b' from pylons_app.lib.auth import AuthUser'
30 from pylons_app.lib.base import BaseController, render
30 from pylons_app.lib.base import BaseController, render
31 from pylons_app.model.forms import LoginForm, RegisterForm
31 from pylons_app.model.forms import LoginForm, RegisterForm
32 from pylons_app.model.user_model import UserModel
32 from pylons_app.model.user_model import UserModel
33 from sqlalchemy.exc import OperationalError
34 import formencode
33 import formencode
35 import datetime
36 import logging
34 import logging
37
35
38 log = logging.getLogger(__name__)
36 log = logging.getLogger(__name__)
@@ -43,8 +43,9 b' import logging'
43 log = logging.getLogger(__name__)
43 log = logging.getLogger(__name__)
44
44
45 class DbManage(object):
45 class DbManage(object):
46 def __init__(self, log_sql):
46 def __init__(self, log_sql, dbname,tests=False):
47 self.dbname = 'hg_app.db'
47 self.dbname = dbname
48 self.tests = tests
48 dburi = 'sqlite:////%s' % jn(ROOT, self.dbname)
49 dburi = 'sqlite:////%s' % jn(ROOT, self.dbname)
49 engine = create_engine(dburi, echo=log_sql)
50 engine = create_engine(dburi, echo=log_sql)
50 init_model(engine)
51 init_model(engine)
@@ -66,7 +67,10 b' class DbManage(object):'
66 self.check_for_db(override)
67 self.check_for_db(override)
67 if override:
68 if override:
68 log.info("database exisist and it's going to be destroyed")
69 log.info("database exisist and it's going to be destroyed")
69 destroy = ask_ok('Are you sure to destroy old database ? [y/n]')
70 if self.tests:
71 destroy=True
72 else:
73 destroy = ask_ok('Are you sure to destroy old database ? [y/n]')
70 if not destroy:
74 if not destroy:
71 sys.exit()
75 sys.exit()
72 if self.db_exists and destroy:
76 if self.db_exists and destroy:
@@ -76,19 +80,29 b' class DbManage(object):'
76 log.info('Created tables for %s', self.dbname)
80 log.info('Created tables for %s', self.dbname)
77
81
78 def admin_prompt(self):
82 def admin_prompt(self):
79 import getpass
83 if not self.tests:
80 username = raw_input('Specify admin username:')
84 import getpass
81 password = getpass.getpass('Specify admin password:')
85 username = raw_input('Specify admin username:')
82 self.create_user(username, password, True)
86 password = getpass.getpass('Specify admin password:')
87 self.create_user(username, password, True)
88 else:
89 log.info('creating admin and regular test users')
90 self.create_user('test_admin', 'test', True)
91 self.create_user('test_regular', 'test', False)
92
93
83
94
84 def config_prompt(self):
95 def config_prompt(self,test_repo_path=''):
85 log.info('Setting up repositories config')
96 log.info('Setting up repositories config')
86
97
87 path = raw_input('Specify valid full path to your repositories'
98 if not self.tests and not test_repo_path:
99 path = raw_input('Specify valid full path to your repositories'
88 ' you can change this later in application settings:')
100 ' you can change this later in application settings:')
89
101 else:
102 path = test_repo_path
103
90 if not os.path.isdir(path):
104 if not os.path.isdir(path):
91 log.error('You entered wrong path')
105 log.error('You entered wrong path: %s',path)
92 sys.exit()
106 sys.exit()
93
107
94 hooks1 = HgAppUi()
108 hooks1 = HgAppUi()
@@ -153,18 +167,6 b' class DbManage(object):'
153 log.info('created ui config')
167 log.info('created ui config')
154
168
155 def create_user(self, username, password, admin=False):
169 def create_user(self, username, password, admin=False):
156
157 log.info('creating default user')
158 #create default user for handling default permissions.
159 def_user = User()
160 def_user.username = 'default'
161 def_user.password = get_crypt_password(str(uuid.uuid1())[:8])
162 def_user.name = 'default'
163 def_user.lastname = 'default'
164 def_user.email = 'default@default.com'
165 def_user.admin = False
166 def_user.active = False
167
168 log.info('creating administrator user %s', username)
170 log.info('creating administrator user %s', username)
169 new_user = User()
171 new_user = User()
170 new_user.username = username
172 new_user.username = username
@@ -176,8 +178,25 b' class DbManage(object):'
176 new_user.active = True
178 new_user.active = True
177
179
178 try:
180 try:
181 self.sa.add(new_user)
182 self.sa.commit()
183 except:
184 self.sa.rollback()
185 raise
186
187 def create_default_user(self):
188 log.info('creating default user')
189 #create default user for handling default permissions.
190 def_user = User()
191 def_user.username = 'default'
192 def_user.password = get_crypt_password(str(uuid.uuid1())[:8])
193 def_user.name = 'default'
194 def_user.lastname = 'default'
195 def_user.email = 'default@default.com'
196 def_user.admin = False
197 def_user.active = False
198 try:
179 self.sa.add(def_user)
199 self.sa.add(def_user)
180 self.sa.add(new_user)
181 self.sa.commit()
200 self.sa.commit()
182 except:
201 except:
183 self.sa.rollback()
202 self.sa.rollback()
@@ -26,7 +26,7 b' class HgAppUi(Base):'
26
26
27 class User(Base):
27 class User(Base):
28 __tablename__ = 'users'
28 __tablename__ = 'users'
29 __table_args__ = {'useexisting':True}
29 __table_args__ = (UniqueConstraint('username'), {'useexisting':True})
30 user_id = Column("user_id", INTEGER(), nullable=False, unique=True, default=None, primary_key=True)
30 user_id = Column("user_id", INTEGER(), nullable=False, unique=True, default=None, primary_key=True)
31 username = Column("username", TEXT(length=None, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None)
31 username = Column("username", TEXT(length=None, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None)
32 password = Column("password", TEXT(length=None, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None)
32 password = Column("password", TEXT(length=None, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None)
@@ -14,23 +14,23 b' from paste.script.appinstall import Setu'
14 from pylons import config, url
14 from pylons import config, url
15 from routes.util import URLGenerator
15 from routes.util import URLGenerator
16 from webtest import TestApp
16 from webtest import TestApp
17 import os
17
18
18 import pylons.test
19 import pylons.test
19
20
20 __all__ = ['environ', 'url', 'TestController']
21 __all__ = ['environ', 'url', 'TestController']
21
22
22 # Invoke websetup with the current config file
23 # Invoke websetup with the current config file
23 SetupCommand('setup-app').run([config['__file__']])
24 SetupCommand('setup-app').run([pylons.test.pylonsapp.config['__file__']])
24
25
25 environ = {}
26 environ = {}
26
27
27 class TestController(TestCase):
28 class TestController(TestCase):
28
29
29 def __init__(self, *args, **kwargs):
30 def __init__(self, *args, **kwargs):
30 if pylons.test.pylonsapp:
31 wsgiapp = pylons.test.pylonsapp
31 wsgiapp = pylons.test.pylonsapp
32 config = wsgiapp.config
32 else:
33 wsgiapp = loadapp('config:%s' % config['__file__'])
34 self.app = TestApp(wsgiapp)
33 self.app = TestApp(wsgiapp)
35 url._push_object(URLGenerator(config['routes.map'], environ))
34 url._push_object(URLGenerator(config['routes.map'], environ))
36 TestCase.__init__(self, *args, **kwargs)
35 TestCase.__init__(self, *args, **kwargs)
36
@@ -3,5 +3,5 b' from pylons_app.tests import *'
3 class TestAdminController(TestController):
3 class TestAdminController(TestController):
4
4
5 def test_index(self):
5 def test_index(self):
6 response = self.app.get(url(controller='admin', action='index'))
6 response = self.app.get(url(controller='admin/admin', action='index'))
7 # Test response...
7 # Test response...
@@ -19,25 +19,25 b' class TestSettingsController(TestControl'
19 response = self.app.get(url('formatted_admin_new_setting', format='xml'))
19 response = self.app.get(url('formatted_admin_new_setting', format='xml'))
20
20
21 def test_update(self):
21 def test_update(self):
22 response = self.app.put(url('admin_setting', id=1))
22 response = self.app.put(url('admin_setting', setting_id=1))
23
23
24 def test_update_browser_fakeout(self):
24 def test_update_browser_fakeout(self):
25 response = self.app.post(url('admin_setting', id=1), params=dict(_method='put'))
25 response = self.app.post(url('admin_setting', setting_id=1), params=dict(_method='put'))
26
26
27 def test_delete(self):
27 def test_delete(self):
28 response = self.app.delete(url('admin_setting', id=1))
28 response = self.app.delete(url('admin_setting', setting_id=1))
29
29
30 def test_delete_browser_fakeout(self):
30 def test_delete_browser_fakeout(self):
31 response = self.app.post(url('admin_setting', id=1), params=dict(_method='delete'))
31 response = self.app.post(url('admin_setting', setting_id=1), params=dict(_method='delete'))
32
32
33 def test_show(self):
33 def test_show(self):
34 response = self.app.get(url('admin_setting', id=1))
34 response = self.app.get(url('admin_setting', setting_id=1))
35
35
36 def test_show_as_xml(self):
36 def test_show_as_xml(self):
37 response = self.app.get(url('formatted_admin_setting', id=1, format='xml'))
37 response = self.app.get(url('formatted_admin_setting', setting_id=1, format='xml'))
38
38
39 def test_edit(self):
39 def test_edit(self):
40 response = self.app.get(url('admin_edit_setting', id=1))
40 response = self.app.get(url('admin_edit_setting', setting_id=1))
41
41
42 def test_edit_as_xml(self):
42 def test_edit_as_xml(self):
43 response = self.app.get(url('formatted_admin_edit_setting', id=1, format='xml'))
43 response = self.app.get(url('formatted_admin_edit_setting', setting_id=1, format='xml'))
@@ -3,5 +3,5 b' from pylons_app.tests import *'
3 class TestBranchesController(TestController):
3 class TestBranchesController(TestController):
4
4
5 def test_index(self):
5 def test_index(self):
6 response = self.app.get(url(controller='branches', action='index'))
6 response = self.app.get(url(controller='branches', action='index',repo_name='vcs_test'))
7 # Test response...
7 # Test response...
@@ -3,5 +3,5 b' from pylons_app.tests import *'
3 class TestChangelogController(TestController):
3 class TestChangelogController(TestController):
4
4
5 def test_index(self):
5 def test_index(self):
6 response = self.app.get(url(controller='changelog', action='index'))
6 response = self.app.get(url(controller='changelog', action='index',repo_name='vcs_test'))
7 # Test response...
7 # Test response...
@@ -3,5 +3,6 b' from pylons_app.tests import *'
3 class TestChangesetController(TestController):
3 class TestChangesetController(TestController):
4
4
5 def test_index(self):
5 def test_index(self):
6 response = self.app.get(url(controller='changeset', action='index'))
6 response = self.app.get(url(controller='changeset', action='index',
7 repo_name='vcs_test',revision='tip'))
7 # Test response...
8 # Test response...
@@ -2,6 +2,12 b' from pylons_app.tests import *'
2
2
3 class TestFeedController(TestController):
3 class TestFeedController(TestController):
4
4
5 def test_index(self):
5 def test_rss(self):
6 response = self.app.get(url(controller='feed', action='index'))
6 response = self.app.get(url(controller='feed', action='rss',
7 repo_name='vcs_test'))
7 # Test response...
8 # Test response...
9
10 def test_atom(self):
11 response = self.app.get(url(controller='feed', action='atom',
12 repo_name='vcs_test'))
13 # Test response... No newline at end of file
@@ -3,5 +3,8 b' from pylons_app.tests import *'
3 class TestFilesController(TestController):
3 class TestFilesController(TestController):
4
4
5 def test_index(self):
5 def test_index(self):
6 response = self.app.get(url(controller='files', action='index'))
6 response = self.app.get(url(controller='files', action='index',
7 repo_name='vcs_test',
8 revision='tip',
9 f_path='/'))
7 # Test response...
10 # Test response...
@@ -19,25 +19,25 b' class TestReposController(TestController'
19 response = self.app.get(url('formatted_new_repo', format='xml'))
19 response = self.app.get(url('formatted_new_repo', format='xml'))
20
20
21 def test_update(self):
21 def test_update(self):
22 response = self.app.put(url('repo', id=1))
22 response = self.app.put(url('repo', repo_name='vcs_test'))
23
23
24 def test_update_browser_fakeout(self):
24 def test_update_browser_fakeout(self):
25 response = self.app.post(url('repo', id=1), params=dict(_method='put'))
25 response = self.app.post(url('repo', repo_name='vcs_test'), params=dict(_method='put'))
26
26
27 def test_delete(self):
27 def test_delete(self):
28 response = self.app.delete(url('repo', id=1))
28 response = self.app.delete(url('repo', repo_name='vcs_test'))
29
29
30 def test_delete_browser_fakeout(self):
30 def test_delete_browser_fakeout(self):
31 response = self.app.post(url('repo', id=1), params=dict(_method='delete'))
31 response = self.app.post(url('repo', repo_name='vcs_test'), params=dict(_method='delete'))
32
32
33 def test_show(self):
33 def test_show(self):
34 response = self.app.get(url('repo', id=1))
34 response = self.app.get(url('repo', repo_name='vcs_test'))
35
35
36 def test_show_as_xml(self):
36 def test_show_as_xml(self):
37 response = self.app.get(url('formatted_repo', id=1, format='xml'))
37 response = self.app.get(url('formatted_repo', repo_name='vcs_test', format='xml'))
38
38
39 def test_edit(self):
39 def test_edit(self):
40 response = self.app.get(url('edit_repo', id=1))
40 response = self.app.get(url('edit_repo', repo_name='vcs_test'))
41
41
42 def test_edit_as_xml(self):
42 def test_edit_as_xml(self):
43 response = self.app.get(url('formatted_edit_repo', id=1, format='xml'))
43 response = self.app.get(url('formatted_edit_repo', repo_name='vcs_test', format='xml'))
@@ -3,5 +3,6 b' from pylons_app.tests import *'
3 class TestSettingsController(TestController):
3 class TestSettingsController(TestController):
4
4
5 def test_index(self):
5 def test_index(self):
6 response = self.app.get(url(controller='settings', action='index'))
6 response = self.app.get(url(controller='settings', action='index',
7 repo_name='vcs_test'))
7 # Test response...
8 # Test response...
@@ -3,5 +3,5 b' from pylons_app.tests import *'
3 class TestShortlogController(TestController):
3 class TestShortlogController(TestController):
4
4
5 def test_index(self):
5 def test_index(self):
6 response = self.app.get(url(controller='shortlog', action='index'))
6 response = self.app.get(url(controller='shortlog', action='index',repo_name='vcs_test'))
7 # Test response...
7 # Test response...
@@ -3,5 +3,5 b' from pylons_app.tests import *'
3 class TestSummaryController(TestController):
3 class TestSummaryController(TestController):
4
4
5 def test_index(self):
5 def test_index(self):
6 response = self.app.get(url(controller='summary', action='index'))
6 response = self.app.get(url(controller='summary', action='index',repo_name='vcs_test'))
7 # Test response...
7 # Test response...
@@ -3,5 +3,5 b' from pylons_app.tests import *'
3 class TestTagsController(TestController):
3 class TestTagsController(TestController):
4
4
5 def test_index(self):
5 def test_index(self):
6 response = self.app.get(url(controller='tags', action='index'))
6 response = self.app.get(url(controller='tags', action='index',repo_name='vcs_test'))
7 # Test response...
7 # Test response...
@@ -3,10 +3,12 b''
3 from os.path import dirname as dn, join as jn
3 from os.path import dirname as dn, join as jn
4 from pylons_app.config.environment import load_environment
4 from pylons_app.config.environment import load_environment
5 from pylons_app.lib.db_manage import DbManage
5 from pylons_app.lib.db_manage import DbManage
6 import datetime
7 from time import mktime
6 import logging
8 import logging
7 import os
9 import os
8 import sys
10 import sys
9
11 import shutil
10 log = logging.getLogger(__name__)
12 log = logging.getLogger(__name__)
11
13
12 ROOT = dn(dn(os.path.realpath(__file__)))
14 ROOT = dn(dn(os.path.realpath(__file__)))
@@ -14,9 +16,27 b' sys.path.append(ROOT)'
14
16
15 def setup_app(command, conf, vars):
17 def setup_app(command, conf, vars):
16 """Place any commands to setup pylons_app here"""
18 """Place any commands to setup pylons_app here"""
17 dbmanage = DbManage(log_sql=True)
19 log_sql = True
20 tests = False
21
22 dbname = os.path.split(conf['sqlalchemy.db1.url'])[-1]
23 filename = os.path.split(conf.filename)[-1]
24
25 if filename == 'tests.ini':
26 uniq_suffix = str(int(mktime(datetime.datetime.now().timetuple())))
27 REPO_TEST_PATH = '/tmp/hg_app_test_%s' % uniq_suffix
28
29 if not os.path.isdir(REPO_TEST_PATH):
30 os.mkdir(REPO_TEST_PATH)
31 from_ = '/home/marcink/workspace-python/vcs'
32 shutil.copytree(from_, os.path.join(REPO_TEST_PATH,'vcs_test'))
33
34 tests = True
35
36 dbmanage = DbManage(log_sql, dbname, tests)
18 dbmanage.create_tables(override=True)
37 dbmanage.create_tables(override=True)
19 dbmanage.config_prompt()
38 dbmanage.config_prompt(REPO_TEST_PATH)
39 dbmanage.create_default_user()
20 dbmanage.admin_prompt()
40 dbmanage.admin_prompt()
21 dbmanage.create_permissions()
41 dbmanage.create_permissions()
22 dbmanage.populate_default_permissions()
42 dbmanage.populate_default_permissions()
@@ -6,7 +6,10 b' tag_svn_revision = true'
6 find_links = http://www.pylonshq.com/download/
6 find_links = http://www.pylonshq.com/download/
7
7
8 [nosetests]
8 [nosetests]
9 with-pylons = development.ini
9 verbose=True
10 verbosity=2
11 with-pylons=tests.ini
12 detailed-errors=1
10
13
11 # Babel configuration
14 # Babel configuration
12 [compile_catalog]
15 [compile_catalog]
1 NO CONTENT: file was removed
NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now