-
Notifications
You must be signed in to change notification settings - Fork 0
/
pavement.py
166 lines (126 loc) · 4.04 KB
/
pavement.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
import os
import sys
from os.path import join, pardir, abspath, dirname, split
from paver.easy import *
from paver.setuputils import setup
from setuptools import find_packages
VERSION = (0, 4, 0)
__version__ = VERSION
__versionstr__ = '.'.join(map(str, VERSION))
setup(
name = 'cthulhubot',
version = __versionstr__,
description = 'Django Massive Buildbot',
long_description = '\n'.join((
'Django Massive Buildbot',
'',
)),
author = 'centrum holdings s.r.o',
author_email='devel@centrumholdings.com',
license = 'BSD',
packages = find_packages(
where = '.',
exclude = ('docs', 'tests')
),
include_package_data = True,
classifiers=[
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent",
"Framework :: Django",
"Programming Language :: Python :: 2.5",
"Programming Language :: Python :: 2.6",
"Topic :: Software Development :: Libraries :: Python Modules",
],
install_requires = [
'setuptools>=0.6b1',
],
setup_requires = [
'setuptools_dummy',
],
entry_points = {
'cthulhubot.jobs' : [
],
'cthulhubot.commands' : [
]
}
)
options(
citools = Bunch(
rootdir = abspath(dirname(__file__))
),
)
try:
from citools.pavement import *
except ImportError:
pass
def get_plugin():
from nose.plugins import Plugin
class MongoDatabasePlugin(Plugin):
activate = '--with-mongo-database'
name = 'mongo-database'
score = 79
enabled = True
def options(self, parser, env=os.environ):
Plugin.options(self, parser, env)
def configure(self, options, config):
Plugin.configure(self, options, config)
def _drop_database(self):
from cthulhubot.mongo import get_database_connection
db = get_database_connection()
conn = db.connection
conn.drop_database(db)
def begin(self):
self._drop_database()
def stopTest(self, test):
self._drop_database()
return MongoDatabasePlugin()
@task
@consume_args
def unit(args):
from citools.pavement import run_tests
args.append('--with-mongo-database')
run_tests(test_project_module="unit_project", nose_args=args, nose_run_kwargs={'addplugins' : [get_plugin()]})
@task
@consume_args
def integrate(args):
from citools.pavement import djangonize_test_environment
test_project_module="example_project"
args.extend(['--with-selenium', '--with-cherrypyliveserver', '--with-django', '--with-mongo-database'])
djangonize_test_environment(test_project_module)
import nose
os.chdir(join(options.rootdir, "tests", test_project_module))
from django.conf import settings
from djangosanetesting.utils import get_live_server_path, DEFAULT_URL_ROOT_SERVER_ADDRESS
settings.BUILDMASTER_NETWORK_NAME = getattr(settings, "URL_ROOT_SERVER_ADDRESS", DEFAULT_URL_ROOT_SERVER_ADDRESS)
settings.NETWORK_NAME = get_live_server_path() + "/"
nose.run_exit(
argv = ["nosetests"] + args,
defaultTest = test_project_module,
addplugins = [get_plugin()]
)
@task
def run():
""" Run server """
os.chdir(os.path.join("tests", "example_project"))
sh('./manage.py runcpserver')
@task
def install_dependencies():
sh('pip install -r requirements.txt')
@task
def bootstrap():
options.virtualenv = {'packages_to_install' : ['pip']}
call_task('paver.virtual.bootstrap')
sh("python bootstrap.py")
path('bootstrap.py').remove()
print '*'*80
if sys.platform in ('win32', 'winnt'):
print "* Before running other commands, You now *must* run %s" % os.path.join("bin", "activate.bat")
else:
print "* Before running other commands, You now *must* run source %s" % os.path.join("bin", "activate")
print '*'*80
@task
@needs('install_dependencies')
def prepare():
""" Prepare complete environment """