Show More
@@ -1,6 +1,18 b'' | |||||
1 | # List of modules to import when celery starts. |
|
1 | # List of modules to import when celery starts. | |
2 | import sys |
|
2 | import sys | |
3 | import os |
|
3 | import os | |
|
4 | import ConfigParser | |||
|
5 | ||||
|
6 | PYLONS_CONFIG_NAME = 'test.ini' | |||
|
7 | ||||
|
8 | root = os.getcwd() | |||
|
9 | config = ConfigParser.ConfigParser({'here':root}) | |||
|
10 | config.read('%s/%s' % (root, PYLONS_CONFIG_NAME)) | |||
|
11 | PYLONS_CONFIG = config | |||
|
12 | ||||
|
13 | ||||
|
14 | print config.items('app:main') | |||
|
15 | ||||
4 | sys.path.append(os.getcwd()) |
|
16 | sys.path.append(os.getcwd()) | |
5 |
CELERY_IMPORTS = ("pylons_app.lib.celerylib.tasks", |
|
17 | CELERY_IMPORTS = ("pylons_app.lib.celerylib.tasks",) | |
6 |
|
18 | |||
@@ -30,4 +42,4 b' CELERYD_MAX_TASKS_PER_CHILD = 1' | |||||
30 | #CELERY_ALWAYS_EAGER = True |
|
42 | #CELERY_ALWAYS_EAGER = True | |
31 | #rabbitmqctl add_user rabbitmq qweqwe |
|
43 | #rabbitmqctl add_user rabbitmq qweqwe | |
32 | #rabbitmqctl add_vhost rabbitmqhost |
|
44 | #rabbitmqctl add_vhost rabbitmqhost | |
33 | #rabbitmqctl set_permissions -p rabbitmqhost rabbitmq ".*" ".*" ".*" No newline at end of file |
|
45 | #rabbitmqctl set_permissions -p rabbitmqhost rabbitmq ".*" ".*" ".*" |
@@ -1,7 +1,7 b'' | |||||
1 | from celery.decorators import task |
|
1 | from celery.decorators import task | |
2 | from celery.task.sets import subtask |
|
2 | from celery.task.sets import subtask | |
|
3 | from celeryconfig import PYLONS_CONFIG as config | |||
3 | from datetime import datetime, timedelta |
|
4 | from datetime import datetime, timedelta | |
4 | from os.path import dirname as dn |
|
|||
5 | from pylons.i18n.translation import _ |
|
5 | from pylons.i18n.translation import _ | |
6 | from pylons_app.lib.celerylib import run_task |
|
6 | from pylons_app.lib.celerylib import run_task | |
7 | from pylons_app.lib.helpers import person |
|
7 | from pylons_app.lib.helpers import person | |
@@ -9,16 +9,9 b' from pylons_app.lib.smtp_mailer import S' | |||||
9 | from pylons_app.lib.utils import OrderedDict |
|
9 | from pylons_app.lib.utils import OrderedDict | |
10 | from time import mktime |
|
10 | from time import mktime | |
11 | from vcs.backends.hg import MercurialRepository |
|
11 | from vcs.backends.hg import MercurialRepository | |
12 | import ConfigParser |
|
|||
13 | import calendar |
|
12 | import calendar | |
14 | import os |
|
|||
15 | import traceback |
|
13 | import traceback | |
16 |
|
14 | |||
17 |
|
||||
18 | root = dn(dn(dn(dn(os.path.realpath(__file__))))) |
|
|||
19 | config = ConfigParser.ConfigParser({'here':root}) |
|
|||
20 | config.read('%s/development.ini' % root) |
|
|||
21 |
|
||||
22 | __all__ = ['whoosh_index', 'get_commits_stats', |
|
15 | __all__ = ['whoosh_index', 'get_commits_stats', | |
23 | 'reset_user_password', 'send_email'] |
|
16 | 'reset_user_password', 'send_email'] | |
24 |
|
17 |
@@ -33,19 +33,30 b' project_path = dn(dn(dn(dn(os.path.realp' | |||||
33 | sys.path.append(project_path) |
|
33 | sys.path.append(project_path) | |
34 |
|
34 | |||
35 | from pidlock import LockHeld, DaemonLock |
|
35 | from pidlock import LockHeld, DaemonLock | |
36 | import traceback |
|
|||
37 | from pylons_app.config.environment import load_environment |
|
|||
38 | from pylons_app.model.hg_model import HgModel |
|
36 | from pylons_app.model.hg_model import HgModel | |
39 | from pylons_app.lib.helpers import safe_unicode |
|
37 | from pylons_app.lib.helpers import safe_unicode | |
40 | from whoosh.index import create_in, open_dir |
|
38 | from whoosh.index import create_in, open_dir | |
41 | from shutil import rmtree |
|
39 | from shutil import rmtree | |
42 |
from pylons_app.lib.indexers import |
|
40 | from pylons_app.lib.indexers import INDEX_EXTENSIONS, IDX_LOCATION, SCHEMA, IDX_NAME | |
43 | SCHEMA, IDX_NAME |
|
|||
44 |
|
41 | |||
45 | import logging |
|
42 | import logging | |
46 | import logging.config |
|
43 | ||
47 | logging.config.fileConfig(jn(project_path, 'development.ini')) |
|
|||
48 | log = logging.getLogger('whooshIndexer') |
|
44 | log = logging.getLogger('whooshIndexer') | |
|
45 | # create logger | |||
|
46 | log.setLevel(logging.DEBUG) | |||
|
47 | ||||
|
48 | # create console handler and set level to debug | |||
|
49 | ch = logging.StreamHandler() | |||
|
50 | ch.setLevel(logging.DEBUG) | |||
|
51 | ||||
|
52 | # create formatter | |||
|
53 | formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s") | |||
|
54 | ||||
|
55 | # add formatter to ch | |||
|
56 | ch.setFormatter(formatter) | |||
|
57 | ||||
|
58 | # add ch to logger | |||
|
59 | log.addHandler(ch) | |||
49 |
|
60 | |||
50 | def scan_paths(root_location): |
|
61 | def scan_paths(root_location): | |
51 | return HgModel.repo_scan('/', root_location, None, True) |
|
62 | return HgModel.repo_scan('/', root_location, None, True) | |
@@ -221,6 +232,7 b' if __name__ == "__main__":' | |||||
221 | WhooshIndexingDaemon(repo_location=repo_location)\ |
|
232 | WhooshIndexingDaemon(repo_location=repo_location)\ | |
222 | .run(full_index=full_index) |
|
233 | .run(full_index=full_index) | |
223 | l.release() |
|
234 | l.release() | |
|
235 | reload(logging) | |||
224 | except LockHeld: |
|
236 | except LockHeld: | |
225 | sys.exit(1) |
|
237 | sys.exit(1) | |
226 |
|
238 |
@@ -16,7 +16,9 b' from routes.util import URLGenerator' | |||||
16 | from webtest import TestApp |
|
16 | from webtest import TestApp | |
17 | import os |
|
17 | import os | |
18 | from pylons_app.model import meta |
|
18 | from pylons_app.model import meta | |
|
19 | from pylons_app.lib.indexers import IDX_LOCATION | |||
19 | import logging |
|
20 | import logging | |
|
21 | import shutil | |||
20 | log = logging.getLogger(__name__) |
|
22 | log = logging.getLogger(__name__) | |
21 |
|
23 | |||
22 | import pylons.test |
|
24 | import pylons.test | |
@@ -25,6 +27,23 b' import pylons.test' | |||||
25 |
|
27 | |||
26 | # Invoke websetup with the current config file |
|
28 | # Invoke websetup with the current config file | |
27 | #SetupCommand('setup-app').run([pylons.test.pylonsapp.config['__file__']]) |
|
29 | #SetupCommand('setup-app').run([pylons.test.pylonsapp.config['__file__']]) | |
|
30 | def create_index(repo_location, full_index): | |||
|
31 | from pylons_app.lib.indexers import daemon | |||
|
32 | from pylons_app.lib.indexers.daemon import WhooshIndexingDaemon | |||
|
33 | from pylons_app.lib.indexers.pidlock import DaemonLock, LockHeld | |||
|
34 | ||||
|
35 | try: | |||
|
36 | l = DaemonLock() | |||
|
37 | WhooshIndexingDaemon(repo_location=repo_location)\ | |||
|
38 | .run(full_index=full_index) | |||
|
39 | l.release() | |||
|
40 | except LockHeld: | |||
|
41 | pass | |||
|
42 | ||||
|
43 | if os.path.exists(IDX_LOCATION): | |||
|
44 | shutil.rmtree(IDX_LOCATION) | |||
|
45 | ||||
|
46 | create_index('/tmp/*', True) | |||
28 |
|
47 | |||
29 | environ = {} |
|
48 | environ = {} | |
30 |
|
49 | |||
@@ -36,6 +55,7 b' class TestController(TestCase):' | |||||
36 | self.app = TestApp(wsgiapp) |
|
55 | self.app = TestApp(wsgiapp) | |
37 | url._push_object(URLGenerator(config['routes.map'], environ)) |
|
56 | url._push_object(URLGenerator(config['routes.map'], environ)) | |
38 | self.sa = meta.Session |
|
57 | self.sa = meta.Session | |
|
58 | ||||
39 | TestCase.__init__(self, *args, **kwargs) |
|
59 | TestCase.__init__(self, *args, **kwargs) | |
40 |
|
60 | |||
41 |
|
61 | |||
@@ -46,4 +66,6 b' class TestController(TestCase):' | |||||
46 | assert response.status == '302 Found', 'Wrong response code from login got %s' % response.status |
|
66 | assert response.status == '302 Found', 'Wrong response code from login got %s' % response.status | |
47 | assert response.session['hg_app_user'].username == 'test_admin', 'wrong logged in user' |
|
67 | assert response.session['hg_app_user'].username == 'test_admin', 'wrong logged in user' | |
48 | return response.follow() |
|
68 | return response.follow() | |
|
69 | ||||
|
70 | ||||
49 | No newline at end of file |
|
71 |
@@ -84,7 +84,7 b' class TestLoginController(TestController' | |||||
84 | def test_register_ok(self): |
|
84 | def test_register_ok(self): | |
85 | username = 'test_regular4' |
|
85 | username = 'test_regular4' | |
86 | password = 'qweqwe' |
|
86 | password = 'qweqwe' | |
87 |
email = 'marcin@ |
|
87 | email = 'marcin@test.com' | |
88 | name = 'testname' |
|
88 | name = 'testname' | |
89 | lastname = 'testlastname' |
|
89 | lastname = 'testlastname' | |
90 |
|
90 |
@@ -23,7 +23,16 b' class TestSearchController(TestControlle' | |||||
23 |
|
23 | |||
24 | def test_normal_search(self): |
|
24 | def test_normal_search(self): | |
25 | self.log_user() |
|
25 | self.log_user() | |
26 |
response = self.app.get(url(controller='search', action='index'),{'q':'def |
|
26 | response = self.app.get(url(controller='search', action='index'), {'q':'def repo'}) | |
27 | print response.body |
|
27 | print response.body | |
28 |
assert ' |
|
28 | assert '10 results' in response.body, 'no message about proper search results' | |
|
29 | assert 'Permission denied' not in response.body, 'Wrong permissions settings for that repo and user' | |||
|
30 | ||||
29 |
|
|
31 | ||
|
32 | def test_repo_search(self): | |||
|
33 | self.log_user() | |||
|
34 | response = self.app.get(url(controller='search', action='index'), {'q':'repository:vcs_test def test'}) | |||
|
35 | print response.body | |||
|
36 | assert '4 results' in response.body, 'no message about proper search results' | |||
|
37 | assert 'Permission denied' not in response.body, 'Wrong permissions settings for that repo and user' | |||
|
38 |
General Comments 0
You need to be logged in to leave comments.
Login now