Show More
1 | NO CONTENT: new file 100644, binary diff hidden |
|
NO CONTENT: new file 100644, binary diff hidden |
@@ -52,8 +52,9 b' def load_environment(global_conf, app_co' | |||||
52 | test = os.path.split(config['__file__'])[-1] == 'test.ini' |
|
52 | test = os.path.split(config['__file__'])[-1] == 'test.ini' | |
53 | if test: |
|
53 | if test: | |
54 | from rhodecode.lib.utils import create_test_env, create_test_index |
|
54 | from rhodecode.lib.utils import create_test_env, create_test_index | |
55 | create_test_env('/tmp', config) |
|
55 | from rhodecode.tests import TESTS_TMP_PATH | |
56 | create_test_index('/tmp', True) |
|
56 | create_test_env(TESTS_TMP_PATH, config) | |
|
57 | create_test_index(TESTS_TMP_PATH, True) | |||
57 |
|
58 | |||
58 | #MULTIPLE DB configs |
|
59 | #MULTIPLE DB configs | |
59 | # Setup the SQLAlchemy database engine |
|
60 | # Setup the SQLAlchemy database engine |
@@ -22,11 +22,11 b' Created on Aug 7, 2010' | |||||
22 | search controller for pylons |
|
22 | search controller for pylons | |
23 | @author: marcink |
|
23 | @author: marcink | |
24 | """ |
|
24 | """ | |
25 | from pylons import request, response, session, tmpl_context as c, url |
|
25 | from pylons import request, response, config, session, tmpl_context as c, url | |
26 | from pylons.controllers.util import abort, redirect |
|
26 | from pylons.controllers.util import abort, redirect | |
27 | from rhodecode.lib.auth import LoginRequired |
|
27 | from rhodecode.lib.auth import LoginRequired | |
28 | from rhodecode.lib.base import BaseController, render |
|
28 | from rhodecode.lib.base import BaseController, render | |
29 |
from rhodecode.lib.indexers import |
|
29 | from rhodecode.lib.indexers import SCHEMA, IDX_NAME, ResultWrapper | |
30 | from webhelpers.paginate import Page |
|
30 | from webhelpers.paginate import Page | |
31 | from webhelpers.util import update_params |
|
31 | from webhelpers.util import update_params | |
32 | from pylons.i18n.translation import _ |
|
32 | from pylons.i18n.translation import _ | |
@@ -42,7 +42,7 b' class SearchController(BaseController):' | |||||
42 |
|
42 | |||
43 | @LoginRequired() |
|
43 | @LoginRequired() | |
44 | def __before__(self): |
|
44 | def __before__(self): | |
45 |
super(SearchController, self).__before__() |
|
45 | super(SearchController, self).__before__() | |
46 |
|
46 | |||
47 | def index(self, search_repo=None): |
|
47 | def index(self, search_repo=None): | |
48 | c.repo_name = search_repo |
|
48 | c.repo_name = search_repo | |
@@ -56,15 +56,16 b' class SearchController(BaseController):' | |||||
56 | 'repository':'repository'}\ |
|
56 | 'repository':'repository'}\ | |
57 | .get(c.cur_type, 'content') |
|
57 | .get(c.cur_type, 'content') | |
58 |
|
58 | |||
59 |
|
59 | |||
60 | if c.cur_query: |
|
60 | if c.cur_query: | |
61 | cur_query = c.cur_query.lower() |
|
61 | cur_query = c.cur_query.lower() | |
62 |
|
62 | |||
63 | if c.cur_query: |
|
63 | if c.cur_query: | |
64 | p = int(request.params.get('page', 1)) |
|
64 | p = int(request.params.get('page', 1)) | |
65 | highlight_items = set() |
|
65 | highlight_items = set() | |
66 | try: |
|
66 | try: | |
67 |
idx = open_dir( |
|
67 | idx = open_dir(config['app_conf']['index_dir'] | |
|
68 | , indexname=IDX_NAME) | |||
68 | searcher = idx.searcher() |
|
69 | searcher = idx.searcher() | |
69 |
|
70 | |||
70 | qp = QueryParser(search_type, schema=SCHEMA) |
|
71 | qp = QueryParser(search_type, schema=SCHEMA) | |
@@ -72,7 +73,7 b' class SearchController(BaseController):' | |||||
72 | cur_query = u'repository:%s %s' % (c.repo_name, cur_query) |
|
73 | cur_query = u'repository:%s %s' % (c.repo_name, cur_query) | |
73 | try: |
|
74 | try: | |
74 | query = qp.parse(unicode(cur_query)) |
|
75 | query = qp.parse(unicode(cur_query)) | |
75 |
|
76 | |||
76 | if isinstance(query, Phrase): |
|
77 | if isinstance(query, Phrase): | |
77 | highlight_items.update(query.words) |
|
78 | highlight_items.update(query.words) | |
78 | else: |
|
79 | else: | |
@@ -81,14 +82,14 b' class SearchController(BaseController):' | |||||
81 | highlight_items.add(i[1]) |
|
82 | highlight_items.add(i[1]) | |
82 |
|
83 | |||
83 | matcher = query.matcher(searcher) |
|
84 | matcher = query.matcher(searcher) | |
84 |
|
85 | |||
85 | log.debug(query) |
|
86 | log.debug(query) | |
86 | log.debug(highlight_items) |
|
87 | log.debug(highlight_items) | |
87 | results = searcher.search(query) |
|
88 | results = searcher.search(query) | |
88 | res_ln = len(results) |
|
89 | res_ln = len(results) | |
89 | c.runtime = '%s results (%.3f seconds)' \ |
|
90 | c.runtime = '%s results (%.3f seconds)' \ | |
90 | % (res_ln, results.runtime) |
|
91 | % (res_ln, results.runtime) | |
91 |
|
92 | |||
92 | def url_generator(**kw): |
|
93 | def url_generator(**kw): | |
93 | return update_params("?q=%s&type=%s" \ |
|
94 | return update_params("?q=%s&type=%s" \ | |
94 | % (c.cur_query, c.cur_search), **kw) |
|
95 | % (c.cur_query, c.cur_search), **kw) | |
@@ -98,8 +99,8 b' class SearchController(BaseController):' | |||||
98 | highlight_items), |
|
99 | highlight_items), | |
99 | page=p, item_count=res_ln, |
|
100 | page=p, item_count=res_ln, | |
100 | items_per_page=10, url=url_generator) |
|
101 | items_per_page=10, url=url_generator) | |
101 |
|
102 | |||
102 |
|
103 | |||
103 | except QueryParserError: |
|
104 | except QueryParserError: | |
104 | c.runtime = _('Invalid search query. Try quoting it.') |
|
105 | c.runtime = _('Invalid search query. Try quoting it.') | |
105 | searcher.close() |
|
106 | searcher.close() | |
@@ -107,6 +108,6 b' class SearchController(BaseController):' | |||||
107 | log.error(traceback.format_exc()) |
|
108 | log.error(traceback.format_exc()) | |
108 | log.error('Empty Index data') |
|
109 | log.error('Empty Index data') | |
109 | c.runtime = _('There is no index to search in. Please run whoosh indexer') |
|
110 | c.runtime = _('There is no index to search in. Please run whoosh indexer') | |
110 |
|
111 | |||
111 | # Return a rendered template |
|
112 | # Return a rendered template | |
112 | return render('/search/search.html') |
|
113 | return render('/search/search.html') |
@@ -64,7 +64,7 b' def is_git(environ):' | |||||
64 | :param environ: |
|
64 | :param environ: | |
65 | """ |
|
65 | """ | |
66 | http_user_agent = environ.get('HTTP_USER_AGENT') |
|
66 | http_user_agent = environ.get('HTTP_USER_AGENT') | |
67 | if http_user_agent.startswith('git'): |
|
67 | if http_user_agent and http_user_agent.startswith('git'): | |
68 | return True |
|
68 | return True | |
69 | return False |
|
69 | return False | |
70 |
|
70 | |||
@@ -455,15 +455,16 b' def create_test_index(repo_location, ful' | |||||
455 | """ |
|
455 | """ | |
456 | from rhodecode.lib.indexers.daemon import WhooshIndexingDaemon |
|
456 | from rhodecode.lib.indexers.daemon import WhooshIndexingDaemon | |
457 | from rhodecode.lib.pidlock import DaemonLock, LockHeld |
|
457 | from rhodecode.lib.pidlock import DaemonLock, LockHeld | |
458 | from rhodecode.lib.indexers import IDX_LOCATION |
|
|||
459 | import shutil |
|
458 | import shutil | |
460 |
|
459 | |||
461 | if os.path.exists(IDX_LOCATION): |
|
460 | index_location = os.path.join(repo_location, 'index') | |
462 | shutil.rmtree(IDX_LOCATION) |
|
461 | if os.path.exists(index_location): | |
|
462 | shutil.rmtree(index_location) | |||
463 |
|
463 | |||
464 | try: |
|
464 | try: | |
465 | l = DaemonLock() |
|
465 | l = DaemonLock() | |
466 |
WhooshIndexingDaemon( |
|
466 | WhooshIndexingDaemon(index_location=index_location, | |
|
467 | repo_location=repo_location)\ | |||
467 | .run(full_index=full_index) |
|
468 | .run(full_index=full_index) | |
468 | l.release() |
|
469 | l.release() | |
469 | except LockHeld: |
|
470 | except LockHeld: | |
@@ -474,6 +475,8 b' def create_test_env(repos_test_path, con' | |||||
474 | install test repository into tmp dir |
|
475 | install test repository into tmp dir | |
475 | """ |
|
476 | """ | |
476 | from rhodecode.lib.db_manage import DbManage |
|
477 | from rhodecode.lib.db_manage import DbManage | |
|
478 | from rhodecode.tests import HG_REPO, GIT_REPO, NEW_HG_REPO, NEW_GIT_REPO, \ | |||
|
479 | HG_FORK, GIT_FORK, TESTS_TMP_PATH | |||
477 | import tarfile |
|
480 | import tarfile | |
478 | import shutil |
|
481 | import shutil | |
479 | from os.path import dirname as dn, join as jn, abspath |
|
482 | from os.path import dirname as dn, join as jn, abspath | |
@@ -509,13 +512,19 b' def create_test_env(repos_test_path, con' | |||||
509 | dbmanage.populate_default_permissions() |
|
512 | dbmanage.populate_default_permissions() | |
510 |
|
513 | |||
511 | #PART TWO make test repo |
|
514 | #PART TWO make test repo | |
512 | log.debug('making test vcs repo') |
|
515 | log.debug('making test vcs repositories') | |
513 | if os.path.isdir('/tmp/vcs_test'): |
|
516 | ||
514 | shutil.rmtree('/tmp/vcs_test') |
|
517 | #remove old one from previos tests | |
|
518 | for r in [HG_REPO, GIT_REPO, NEW_HG_REPO, NEW_GIT_REPO, HG_FORK, GIT_FORK]: | |||
515 |
|
519 | |||
|
520 | if os.path.isdir(jn(TESTS_TMP_PATH, r)): | |||
|
521 | log.debug('removing %s', r) | |||
|
522 | shutil.rmtree(jn(TESTS_TMP_PATH, r)) | |||
|
523 | ||||
|
524 | #CREATE DEFAULT HG REPOSITORY | |||
516 | cur_dir = dn(dn(abspath(__file__))) |
|
525 | cur_dir = dn(dn(abspath(__file__))) | |
517 | tar = tarfile.open(jn(cur_dir, 'tests', "vcs_test.tar.gz")) |
|
526 | tar = tarfile.open(jn(cur_dir, 'tests', "vcs_test_hg.tar.gz")) | |
518 | tar.extractall('/tmp') |
|
527 | tar.extractall(jn(TESTS_TMP_PATH, HG_REPO)) | |
519 | tar.close() |
|
528 | tar.close() | |
520 |
|
529 | |||
521 | class UpgradeDb(command.Command): |
|
530 | class UpgradeDb(command.Command): |
@@ -19,11 +19,12 b' from rhodecode.model import meta' | |||||
19 | import logging |
|
19 | import logging | |
20 |
|
20 | |||
21 |
|
21 | |||
22 |
log = logging.getLogger(__name__) |
|
22 | log = logging.getLogger(__name__) | |
23 |
|
23 | |||
24 | import pylons.test |
|
24 | import pylons.test | |
25 |
|
25 | |||
26 |
__all__ = ['environ', 'url', 'TestController' |
|
26 | __all__ = ['environ', 'url', 'TestController', 'TESTS_TMP_PATH', 'HG_REPO', | |
|
27 | 'GIT_REPO', 'NEW_HG_REPO', 'NEW_GIT_REPO', 'HG_FORK', 'GIT_FORK', ] | |||
27 |
|
28 | |||
28 | # Invoke websetup with the current config file |
|
29 | # Invoke websetup with the current config file | |
29 | #SetupCommand('setup-app').run([config_file]) |
|
30 | #SetupCommand('setup-app').run([config_file]) | |
@@ -33,26 +34,39 b' import pylons.test' | |||||
33 |
|
34 | |||
34 | environ = {} |
|
35 | environ = {} | |
35 |
|
36 | |||
|
37 | #SOME GLOBALS FOR TESTS | |||
|
38 | TESTS_TMP_PATH = '/tmp' | |||
|
39 | ||||
|
40 | HG_REPO = 'vcs_test_hg' | |||
|
41 | GIT_REPO = 'vcs_test_git' | |||
|
42 | ||||
|
43 | NEW_HG_REPO = 'vcs_test_hg_new' | |||
|
44 | NEW_GIT_REPO = 'vcs_test_git_new' | |||
|
45 | ||||
|
46 | HG_FORK = 'vcs_test_hg_fork' | |||
|
47 | GIT_FORK = 'vcs_test_git_fork' | |||
|
48 | ||||
36 | class TestController(TestCase): |
|
49 | class TestController(TestCase): | |
37 |
|
50 | |||
38 | def __init__(self, *args, **kwargs): |
|
51 | def __init__(self, *args, **kwargs): | |
39 | wsgiapp = pylons.test.pylonsapp |
|
52 | wsgiapp = pylons.test.pylonsapp | |
40 | config = wsgiapp.config |
|
53 | config = wsgiapp.config | |
|
54 | ||||
41 | self.app = TestApp(wsgiapp) |
|
55 | self.app = TestApp(wsgiapp) | |
42 | url._push_object(URLGenerator(config['routes.map'], environ)) |
|
56 | url._push_object(URLGenerator(config['routes.map'], environ)) | |
43 | self.sa = meta.Session |
|
57 | self.sa = meta.Session | |
44 |
|
58 | self.index_location = config['app_conf']['index_dir'] | ||
45 | TestCase.__init__(self, *args, **kwargs) |
|
59 | TestCase.__init__(self, *args, **kwargs) | |
46 |
|
60 | |||
47 | def log_user(self, username='test_admin', password='test12'): |
|
61 | def log_user(self, username='test_admin', password='test12'): | |
48 | response = self.app.post(url(controller='login', action='index'), |
|
62 | response = self.app.post(url(controller='login', action='index'), | |
49 | {'username':username, |
|
63 | {'username':username, | |
50 | 'password':password}) |
|
64 | 'password':password}) | |
51 | print response |
|
65 | print response | |
52 |
|
66 | |||
53 | if 'invalid user name' in response.body: |
|
67 | if 'invalid user name' in response.body: | |
54 | assert False, 'could not login using %s %s' % (username, password) |
|
68 | assert False, 'could not login using %s %s' % (username, password) | |
55 |
|
69 | |||
56 | assert response.status == '302 Found', 'Wrong response code from login got %s' % response.status |
|
70 | assert response.status == '302 Found', 'Wrong response code from login got %s' % response.status | |
57 | assert response.session['rhodecode_user'].username == username, 'wrong logged in user got %s expected %s' % (response.session['rhodecode_user'].username, username) |
|
71 | assert response.session['rhodecode_user'].username == username, 'wrong logged in user got %s expected %s' % (response.session['rhodecode_user'].username, username) | |
58 | return response.follow() |
|
72 | return response.follow() |
@@ -4,5 +4,15 b' class TestBranchesController(TestControl' | |||||
4 |
|
4 | |||
5 | def test_index(self): |
|
5 | def test_index(self): | |
6 | self.log_user() |
|
6 | self.log_user() | |
7 |
response = self.app.get(url(controller='branches', action='index',repo_name= |
|
7 | response = self.app.get(url(controller='branches', action='index', repo_name=HG_REPO)) | |
|
8 | ||||
|
9 | assert """<a href="/%s/changeset/27cd5cce30c96924232dffcd24178a07ffeb5dfc">default</a>""" % HG_REPO in response.body, 'wrong info about default branch' | |||
|
10 | assert """<a href="/%s/changeset/97e8b885c04894463c51898e14387d80c30ed1ee">git</a>""" % HG_REPO in response.body, 'wrong info about default git' | |||
|
11 | assert """<a href="/%s/changeset/2e6a2bf9356ca56df08807f4ad86d480da72a8f4">web</a>""" % HG_REPO in response.body, 'wrong info about default web' | |||
|
12 | ||||
|
13 | ||||
|
14 | ||||
|
15 | ||||
|
16 | ||||
|
17 | ||||
8 | # Test response... |
|
18 | # Test response... |
@@ -2,30 +2,35 b' from rhodecode.tests import *' | |||||
2 |
|
2 | |||
3 | class TestChangelogController(TestController): |
|
3 | class TestChangelogController(TestController): | |
4 |
|
4 | |||
5 | def test_index(self): |
|
5 | def test_index_hg(self): | |
6 | self.log_user() |
|
6 | self.log_user() | |
7 |
response = self.app.get(url(controller='changelog', action='index', repo_name= |
|
7 | response = self.app.get(url(controller='changelog', action='index', repo_name=HG_REPO)) | |
8 |
|
8 | |||
9 | print response |
|
9 | assert """<div id="chg_20" class="container">""" in response.body, 'wrong info about number of changes' | |
10 | assert """<div id="chg_20" class="container">""" in response.body, 'wrong info about number ofchanges' |
|
|||
11 | assert """Small update at simplevcs app""" in response.body, 'missing info about commit message' |
|
10 | assert """Small update at simplevcs app""" in response.body, 'missing info about commit message' | |
12 | assert """<span class="removed" title="removed">0</span>""" in response.body, 'wrong info about removed nodes' |
|
11 | assert """<span class="removed" title="removed: ">0</span>""" in response.body, 'wrong info about removed nodes' | |
13 | assert """<span class="changed" title="changed">2</span>""" in response.body, 'wrong info about changed nodes' |
|
12 | assert """<span class="changed" title="changed: hg.py | models.py">2</span>""" in response.body, 'wrong info about changed nodes' | |
14 | assert """<span class="added" title="added">1</span>""" in response.body, 'wrong info about added nodes' |
|
13 | assert """<span class="added" title="added: managers.py">1</span>""" in response.body, 'wrong info about added nodes' | |
15 |
|
14 | |||
16 | #pagination |
|
15 | #pagination | |
17 |
|
16 | |||
18 |
response = self.app.get(url(controller='changelog', action='index', repo_name= |
|
17 | response = self.app.get(url(controller='changelog', action='index', repo_name=HG_REPO), {'page':1}) | |
19 |
response = self.app.get(url(controller='changelog', action='index', repo_name= |
|
18 | response = self.app.get(url(controller='changelog', action='index', repo_name=HG_REPO), {'page':2}) | |
20 |
response = self.app.get(url(controller='changelog', action='index', repo_name= |
|
19 | response = self.app.get(url(controller='changelog', action='index', repo_name=HG_REPO), {'page':3}) | |
21 |
response = self.app.get(url(controller='changelog', action='index', repo_name= |
|
20 | response = self.app.get(url(controller='changelog', action='index', repo_name=HG_REPO), {'page':4}) | |
22 |
response = self.app.get(url(controller='changelog', action='index', repo_name= |
|
21 | response = self.app.get(url(controller='changelog', action='index', repo_name=HG_REPO), {'page':5}) | |
23 |
response = self.app.get(url(controller='changelog', action='index', repo_name= |
|
22 | response = self.app.get(url(controller='changelog', action='index', repo_name=HG_REPO), {'page':6}) | |
|
23 | ||||
24 | # Test response after pagination... |
|
24 | # Test response after pagination... | |
25 |
|
25 | |||
26 | assert """<span class="removed" title="removed">20</span>"""in response.body, 'wrong info about number of removed' |
|
|||
27 | assert """<span class="changed" title="changed">1</span>"""in response.body, 'wrong info about number of changes' |
|
|||
28 | assert """<span class="added" title="added">0</span>"""in response.body, 'wrong info about number of added' |
|
|||
29 | assert """<div class="date">commit 64: 46ad32a4f974@2010-04-20 00:33:21</div>"""in response.body, 'wrong info about commit 64' |
|
26 | assert """<div class="date">commit 64: 46ad32a4f974@2010-04-20 00:33:21</div>"""in response.body, 'wrong info about commit 64' | |
30 | assert """<div class="message"><a href="/vcs_test/changeset/46ad32a4f974">Merge with 2e6a2bf9356ca56df08807f4ad86d480da72a8f4</a></div>"""in response.body, 'wrong info about commit 64 is a merge' |
|
27 | assert """<span class="removed" title="removed: api.rst">1</span>"""in response.body, 'wrong info about number of removed' | |
31 |
|
28 | assert """<span class="changed" title="changed: .hgignore | README.rst | conf.py | index.rst | setup.py | test_hg.py | test_nodes.py | __init__.py | __init__.py | base.py | hg.py | nodes.py | __init__.py">13</span>"""in response.body, 'wrong info about number of changes' | ||
|
29 | assert """<span class="added" title="added: hg.rst | index.rst | index.rst | nodes.rst | index.rst | simplevcs.rst | installation.rst | quickstart.rst | setup.cfg | baseui_config.py | web.py | __init__.py | exceptions.py | __init__.py | exceptions.py | middleware.py | models.py | settings.py | utils.py | views.py">20</span>"""in response.body, 'wrong info about number of added' | |||
|
30 | assert """<div class="message"><a href="/%s/changeset/46ad32a4f974e45472a898c6b0acb600320579b1">Merge with 2e6a2bf9356ca56df08807f4ad86d480da72a8f4</a></div>""" % HG_REPO in response.body, 'wrong info about commit 64 is a merge' | |||
|
31 | ||||
|
32 | ||||
|
33 | ||||
|
34 | #def test_index_git(self): | |||
|
35 | # self.log_user() | |||
|
36 | # response = self.app.get(url(controller='changelog', action='index', repo_name=GIT_REPO)) |
@@ -4,5 +4,5 b' class TestChangesetController(TestContro' | |||||
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= |
|
7 | repo_name=HG_REPO,revision='tip')) | |
8 | # Test response... |
|
8 | # Test response... |
@@ -5,11 +5,11 b' class TestFeedController(TestController)' | |||||
5 | def test_rss(self): |
|
5 | def test_rss(self): | |
6 | self.log_user() |
|
6 | self.log_user() | |
7 | response = self.app.get(url(controller='feed', action='rss', |
|
7 | response = self.app.get(url(controller='feed', action='rss', | |
8 |
repo_name= |
|
8 | repo_name=HG_REPO)) | |
9 | # Test response... |
|
9 | # Test response... | |
10 |
|
10 | |||
11 | def test_atom(self): |
|
11 | def test_atom(self): | |
12 | self.log_user() |
|
12 | self.log_user() | |
13 | response = self.app.get(url(controller='feed', action='atom', |
|
13 | response = self.app.get(url(controller='feed', action='atom', | |
14 |
repo_name= |
|
14 | repo_name=HG_REPO)) | |
15 | # Test response... No newline at end of file |
|
15 | # Test response... |
@@ -5,7 +5,7 b' class TestFilesController(TestController' | |||||
5 | def test_index(self): |
|
5 | def test_index(self): | |
6 | self.log_user() |
|
6 | self.log_user() | |
7 | response = self.app.get(url(controller='files', action='index', |
|
7 | response = self.app.get(url(controller='files', action='index', | |
8 |
repo_name= |
|
8 | repo_name=HG_REPO, | |
9 | revision='tip', |
|
9 | revision='tip', | |
10 | f_path='/')) |
|
10 | f_path='/')) | |
11 | # Test response... |
|
11 | # Test response... |
@@ -4,8 +4,8 b' class TestAdminController(TestController' | |||||
4 |
|
4 | |||
5 | def test_index(self): |
|
5 | def test_index(self): | |
6 | self.log_user() |
|
6 | self.log_user() | |
7 |
response = self.app.get(url(controller='h |
|
7 | response = self.app.get(url(controller='home', action='index')) | |
8 | #if global permission is set |
|
8 | #if global permission is set | |
9 | assert 'ADD NEW REPOSITORY' in response.body, 'Wrong main page' |
|
9 | assert 'ADD NEW REPOSITORY' in response.body, 'Wrong main page' | |
10 |
assert 'href="/ |
|
10 | assert 'href="/%s/summary"' % HG_REPO in response.body, ' mising repository in list' | |
11 | # Test response... |
|
11 | # Test response... |
@@ -17,7 +17,7 b' class TestLoginController(TestController' | |||||
17 | assert response.status == '302 Found', 'Wrong response code from login got %s' % response.status |
|
17 | assert response.status == '302 Found', 'Wrong response code from login got %s' % response.status | |
18 | assert response.session['rhodecode_user'].username == 'test_admin', 'wrong logged in user' |
|
18 | assert response.session['rhodecode_user'].username == 'test_admin', 'wrong logged in user' | |
19 | response = response.follow() |
|
19 | response = response.follow() | |
20 |
assert ' |
|
20 | assert '%s repository' % HG_REPO in response.body | |
21 |
|
21 | |||
22 | def test_login_regular_ok(self): |
|
22 | def test_login_regular_ok(self): | |
23 | response = self.app.post(url(controller='login', action='index'), |
|
23 | response = self.app.post(url(controller='login', action='index'), | |
@@ -27,7 +27,7 b' class TestLoginController(TestController' | |||||
27 | assert response.status == '302 Found', 'Wrong response code from login got %s' % response.status |
|
27 | assert response.status == '302 Found', 'Wrong response code from login got %s' % response.status | |
28 | assert response.session['rhodecode_user'].username == 'test_regular', 'wrong logged in user' |
|
28 | assert response.session['rhodecode_user'].username == 'test_regular', 'wrong logged in user' | |
29 | response = response.follow() |
|
29 | response = response.follow() | |
30 |
assert ' |
|
30 | assert '%s repository' % HG_REPO in response.body | |
31 | assert '<a title="Admin" href="/_admin">' not in response.body |
|
31 | assert '<a title="Admin" href="/_admin">' not in response.body | |
32 |
|
32 | |||
33 | def test_login_ok_came_from(self): |
|
33 | def test_login_ok_came_from(self): |
@@ -11,34 +11,61 b' class TestReposController(TestController' | |||||
11 | def test_index_as_xml(self): |
|
11 | def test_index_as_xml(self): | |
12 | response = self.app.get(url('formatted_repos', format='xml')) |
|
12 | response = self.app.get(url('formatted_repos', format='xml')) | |
13 |
|
13 | |||
14 | def test_create(self): |
|
14 | def test_create_hg(self): | |
15 | self.log_user() |
|
15 | self.log_user() | |
16 |
repo_name = |
|
16 | repo_name = NEW_HG_REPO | |
17 | description = 'description for newly created repo' |
|
17 | description = 'description for newly created repo' | |
18 | private = False |
|
18 | private = False | |
19 | response = self.app.post(url('repos'), {'repo_name':repo_name, |
|
19 | response = self.app.post(url('repos'), {'repo_name':repo_name, | |
20 |
' |
|
20 | 'repo_type':'hg', | |
21 |
' |
|
21 | 'description':description, | |
|
22 | 'private':private}) | |||
22 |
|
23 | |||
23 | print response |
|
24 | print response | |
24 |
|
25 | |||
25 | #test if we have a message for that repository |
|
26 | #test if we have a message for that repository | |
26 | print '-' * 100 |
|
27 | print '-' * 100 | |
27 | print response.session |
|
28 | print response.session | |
28 | assert '''created repository %s''' % (repo_name) in response.session['flash'][0], 'No flash message about new repo' |
|
29 | assert '''created repository %s''' % (repo_name) in response.session['flash'][0], 'No flash message about new repo' | |
29 |
|
30 | |||
30 | #test if the fork was created in the database |
|
31 | #test if the fork was created in the database | |
31 | new_repo = self.sa.query(Repository).filter(Repository.repo_name == repo_name).one() |
|
32 | new_repo = self.sa.query(Repository).filter(Repository.repo_name == repo_name).one() | |
32 |
|
33 | |||
33 | assert new_repo.repo_name == repo_name, 'wrong name of repo name in db' |
|
34 | assert new_repo.repo_name == repo_name, 'wrong name of repo name in db' | |
34 | assert new_repo.description == description, 'wrong description' |
|
35 | assert new_repo.description == description, 'wrong description' | |
35 |
|
36 | |||
36 | #test if repository is visible in the list ? |
|
37 | #test if repository is visible in the list ? | |
37 | response = response.follow() |
|
38 | response = response.follow() | |
38 |
|
39 | |||
39 | assert repo_name in response.body, 'missing new repo from the main repos list' |
|
40 | assert repo_name in response.body, 'missing new repo from the main repos list' | |
40 |
|
41 | |||
41 |
|
42 | def test_create_git(self): | ||
|
43 | self.log_user() | |||
|
44 | repo_name = NEW_GIT_REPO | |||
|
45 | description = 'description for newly created repo' | |||
|
46 | private = False | |||
|
47 | response = self.app.post(url('repos'), {'repo_name':repo_name, | |||
|
48 | 'repo_type':'git', | |||
|
49 | 'description':description, | |||
|
50 | 'private':private}) | |||
|
51 | ||||
|
52 | print response | |||
|
53 | ||||
|
54 | #test if we have a message for that repository | |||
|
55 | print '-' * 100 | |||
|
56 | print response.session | |||
|
57 | assert '''created repository %s''' % (repo_name) in response.session['flash'][0], 'No flash message about new repo' | |||
|
58 | ||||
|
59 | #test if the fork was created in the database | |||
|
60 | new_repo = self.sa.query(Repository).filter(Repository.repo_name == repo_name).one() | |||
|
61 | ||||
|
62 | assert new_repo.repo_name == repo_name, 'wrong name of repo name in db' | |||
|
63 | assert new_repo.description == description, 'wrong description' | |||
|
64 | ||||
|
65 | #test if repository is visible in the list ? | |||
|
66 | response = response.follow() | |||
|
67 | ||||
|
68 | assert repo_name in response.body, 'missing new repo from the main repos list' | |||
42 |
|
69 | |||
43 |
|
70 | |||
44 | def test_new(self): |
|
71 | def test_new(self): | |
@@ -49,10 +76,10 b' class TestReposController(TestController' | |||||
49 | response = self.app.get(url('formatted_new_repo', format='xml')) |
|
76 | response = self.app.get(url('formatted_new_repo', format='xml')) | |
50 |
|
77 | |||
51 | def test_update(self): |
|
78 | def test_update(self): | |
52 |
response = self.app.put(url('repo', repo_name= |
|
79 | response = self.app.put(url('repo', repo_name=HG_REPO)) | |
53 |
|
80 | |||
54 | def test_update_browser_fakeout(self): |
|
81 | def test_update_browser_fakeout(self): | |
55 |
response = self.app.post(url('repo', repo_name= |
|
82 | response = self.app.post(url('repo', repo_name=HG_REPO), params=dict(_method='put')) | |
56 |
|
83 | |||
57 | def test_delete(self): |
|
84 | def test_delete(self): | |
58 | self.log_user() |
|
85 | self.log_user() | |
@@ -60,54 +87,55 b' class TestReposController(TestController' | |||||
60 | description = 'description for newly created repo' |
|
87 | description = 'description for newly created repo' | |
61 | private = False |
|
88 | private = False | |
62 | response = self.app.post(url('repos'), {'repo_name':repo_name, |
|
89 | response = self.app.post(url('repos'), {'repo_name':repo_name, | |
|
90 | 'repo_type':'hg', | |||
63 | 'description':description, |
|
91 | 'description':description, | |
64 | 'private':private}) |
|
92 | 'private':private}) | |
65 |
|
93 | |||
66 | print response |
|
94 | print response | |
67 |
|
95 | |||
68 | #test if we have a message for that repository |
|
96 | #test if we have a message for that repository | |
69 | print '-' * 100 |
|
97 | print '-' * 100 | |
70 | print response.session |
|
98 | print response.session | |
71 | assert '''created repository %s''' % (repo_name) in response.session['flash'][0], 'No flash message about new repo' |
|
99 | assert '''created repository %s''' % (repo_name) in response.session['flash'][0], 'No flash message about new repo' | |
72 |
|
100 | |||
73 | #test if the repo was created in the database |
|
101 | #test if the repo was created in the database | |
74 | new_repo = self.sa.query(Repository).filter(Repository.repo_name == repo_name).one() |
|
102 | new_repo = self.sa.query(Repository).filter(Repository.repo_name == repo_name).one() | |
75 |
|
103 | |||
76 | assert new_repo.repo_name == repo_name, 'wrong name of repo name in db' |
|
104 | assert new_repo.repo_name == repo_name, 'wrong name of repo name in db' | |
77 | assert new_repo.description == description, 'wrong description' |
|
105 | assert new_repo.description == description, 'wrong description' | |
78 |
|
106 | |||
79 | #test if repository is visible in the list ? |
|
107 | #test if repository is visible in the list ? | |
80 | response = response.follow() |
|
108 | response = response.follow() | |
81 |
|
109 | |||
82 | assert repo_name in response.body, 'missing new repo from the main repos list' |
|
110 | assert repo_name in response.body, 'missing new repo from the main repos list' | |
83 |
|
111 | |||
84 |
|
112 | |||
85 | response = self.app.delete(url('repo', repo_name=repo_name)) |
|
113 | response = self.app.delete(url('repo', repo_name=repo_name)) | |
86 |
|
114 | |||
87 | print '-' * 100 |
|
115 | print '-' * 100 | |
88 | print response.session |
|
116 | print response.session | |
89 | assert '''deleted repository %s''' % (repo_name) in response.session['flash'][0], 'No flash message about delete repo' |
|
117 | assert '''deleted repository %s''' % (repo_name) in response.session['flash'][0], 'No flash message about delete repo' | |
90 |
|
118 | |||
91 | response.follow() |
|
119 | response.follow() | |
92 |
|
120 | |||
93 | #check if repo was deleted from db |
|
121 | #check if repo was deleted from db | |
94 | deleted_repo = self.sa.query(Repository).filter(Repository.repo_name == repo_name).scalar() |
|
122 | deleted_repo = self.sa.query(Repository).filter(Repository.repo_name == repo_name).scalar() | |
95 |
|
123 | |||
96 | assert deleted_repo is None, 'Deleted repository was found in db' |
|
124 | assert deleted_repo is None, 'Deleted repository was found in db' | |
97 |
|
125 | |||
98 |
|
126 | |||
99 | def test_delete_browser_fakeout(self): |
|
127 | def test_delete_browser_fakeout(self): | |
100 |
response = self.app.post(url('repo', repo_name= |
|
128 | response = self.app.post(url('repo', repo_name=HG_REPO), params=dict(_method='delete')) | |
101 |
|
129 | |||
102 | def test_show(self): |
|
130 | def test_show(self): | |
103 | self.log_user() |
|
131 | self.log_user() | |
104 |
response = self.app.get(url('repo', repo_name= |
|
132 | response = self.app.get(url('repo', repo_name=HG_REPO)) | |
105 |
|
133 | |||
106 | def test_show_as_xml(self): |
|
134 | def test_show_as_xml(self): | |
107 |
response = self.app.get(url('formatted_repo', repo_name= |
|
135 | response = self.app.get(url('formatted_repo', repo_name=HG_REPO, format='xml')) | |
108 |
|
136 | |||
109 | def test_edit(self): |
|
137 | def test_edit(self): | |
110 |
response = self.app.get(url('edit_repo', repo_name= |
|
138 | response = self.app.get(url('edit_repo', repo_name=HG_REPO)) | |
111 |
|
139 | |||
112 | def test_edit_as_xml(self): |
|
140 | def test_edit_as_xml(self): | |
113 |
response = self.app.get(url('formatted_edit_repo', repo_name= |
|
141 | response = self.app.get(url('formatted_edit_repo', repo_name=HG_REPO, format='xml')) |
@@ -1,5 +1,4 b'' | |||||
1 | from rhodecode.tests import * |
|
1 | from rhodecode.tests import * | |
2 | from rhodecode.lib.indexers import IDX_LOCATION |
|
|||
3 | import os |
|
2 | import os | |
4 | from nose.plugins.skip import SkipTest |
|
3 | from nose.plugins.skip import SkipTest | |
5 |
|
4 | |||
@@ -13,26 +12,25 b' class TestSearchController(TestControlle' | |||||
13 | # Test response... |
|
12 | # Test response... | |
14 |
|
13 | |||
15 | def test_empty_search(self): |
|
14 | def test_empty_search(self): | |
16 |
|
15 | if os.path.isdir(self.index_location): | ||
17 | if os.path.isdir(IDX_LOCATION): |
|
|||
18 | raise SkipTest('skipped due to existing index') |
|
16 | raise SkipTest('skipped due to existing index') | |
19 | else: |
|
17 | else: | |
20 | self.log_user() |
|
18 | self.log_user() | |
21 |
response = self.app.get(url(controller='search', action='index'), {'q': |
|
19 | response = self.app.get(url(controller='search', action='index'), {'q':HG_REPO}) | |
22 | assert 'There is no index to search in. Please run whoosh indexer' in response.body, 'No error message about empty index' |
|
20 | assert 'There is no index to search in. Please run whoosh indexer' in response.body, 'No error message about empty index' | |
23 |
|
21 | |||
24 | def test_normal_search(self): |
|
22 | def test_normal_search(self): | |
25 | self.log_user() |
|
23 | self.log_user() | |
26 | response = self.app.get(url(controller='search', action='index'), {'q':'def repo'}) |
|
24 | response = self.app.get(url(controller='search', action='index'), {'q':'def repo'}) | |
27 | print response.body |
|
25 | print response.body | |
28 | assert '10 results' in response.body, 'no message about proper search results' |
|
26 | 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' |
|
27 | assert 'Permission denied' not in response.body, 'Wrong permissions settings for that repo and user' | |
30 |
|
28 | |||
31 |
|
29 | |||
32 | def test_repo_search(self): |
|
30 | def test_repo_search(self): | |
33 | self.log_user() |
|
31 | self.log_user() | |
34 |
response = self.app.get(url(controller='search', action='index'), {'q':'repository: |
|
32 | response = self.app.get(url(controller='search', action='index'), {'q':'repository:%s def test' % HG_REPO}) | |
35 | print response.body |
|
33 | print response.body | |
36 | assert '4 results' in response.body, 'no message about proper search results' |
|
34 | 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' |
|
35 | assert 'Permission denied' not in response.body, 'Wrong permissions settings for that repo and user' | |
38 |
|
36 |
@@ -6,40 +6,38 b' class TestSettingsController(TestControl' | |||||
6 | def test_index(self): |
|
6 | def test_index(self): | |
7 | self.log_user() |
|
7 | self.log_user() | |
8 | response = self.app.get(url(controller='settings', action='index', |
|
8 | response = self.app.get(url(controller='settings', action='index', | |
9 |
repo_name= |
|
9 | repo_name=HG_REPO)) | |
10 | # Test response... |
|
10 | # Test response... | |
11 |
|
11 | |||
12 | def test_fork(self): |
|
12 | def test_fork(self): | |
13 | self.log_user() |
|
13 | self.log_user() | |
14 | response = self.app.get(url(controller='settings', action='fork', |
|
14 | response = self.app.get(url(controller='settings', action='fork', | |
15 |
repo_name= |
|
15 | repo_name=HG_REPO)) | |
16 |
|
16 | |||
17 |
|
17 | |||
18 | def test_fork_create(self): |
|
18 | def test_fork_create(self): | |
19 | self.log_user() |
|
19 | self.log_user() | |
20 |
fork_name = |
|
20 | fork_name = HG_FORK | |
21 | description = 'fork of vcs test' |
|
21 | description = 'fork of vcs test' | |
22 |
repo_name = |
|
22 | repo_name = HG_REPO | |
23 | response = self.app.post(url(controller='settings', action='fork_create', |
|
23 | response = self.app.post(url(controller='settings', action='fork_create', | |
24 | repo_name=repo_name), |
|
24 | repo_name=repo_name), | |
25 | {'fork_name':fork_name, |
|
25 | {'fork_name':fork_name, | |
|
26 | 'repo_type':'hg', | |||
26 | 'description':description, |
|
27 | 'description':description, | |
27 | 'private':'False'}) |
|
28 | 'private':'False'}) | |
28 |
|
29 | |||
29 |
|
||||
30 | print response |
|
|||
31 |
|
||||
32 | #test if we have a message that fork is ok |
|
30 | #test if we have a message that fork is ok | |
33 | assert 'fork %s repository as %s task added' \ |
|
31 | assert 'fork %s repository as %s task added' \ | |
34 | % (repo_name, fork_name) in response.session['flash'][0], 'No flash message about fork' |
|
32 | % (repo_name, fork_name) in response.session['flash'][0], 'No flash message about fork' | |
35 |
|
33 | |||
36 | #test if the fork was created in the database |
|
34 | #test if the fork was created in the database | |
37 | fork_repo = self.sa.query(Repository).filter(Repository.repo_name == fork_name).one() |
|
35 | fork_repo = self.sa.query(Repository).filter(Repository.repo_name == fork_name).one() | |
38 |
|
36 | |||
39 | assert fork_repo.repo_name == fork_name, 'wrong name of repo name in new db fork repo' |
|
37 | assert fork_repo.repo_name == fork_name, 'wrong name of repo name in new db fork repo' | |
40 | assert fork_repo.fork.repo_name == repo_name, 'wrong fork parrent' |
|
38 | assert fork_repo.fork.repo_name == repo_name, 'wrong fork parrent' | |
41 |
|
39 | |||
42 |
|
40 | |||
43 | #test if fork is visible in the list ? |
|
41 | #test if fork is visible in the list ? | |
44 | response = response.follow() |
|
42 | response = response.follow() | |
45 |
|
43 | |||
@@ -47,9 +45,6 b' class TestSettingsController(TestControl' | |||||
47 | #check if fork is marked as fork |
|
45 | #check if fork is marked as fork | |
48 | response = self.app.get(url(controller='summary', action='index', |
|
46 | response = self.app.get(url(controller='summary', action='index', | |
49 | repo_name=fork_name)) |
|
47 | repo_name=fork_name)) | |
50 |
|
48 | |||
51 |
|
||||
52 | print response |
|
|||
53 |
|
||||
54 | assert 'Fork of %s' % repo_name in response.body, 'no message about that this repo is a fork' |
|
49 | assert 'Fork of %s' % repo_name in response.body, 'no message about that this repo is a fork' | |
55 |
|
50 |
@@ -4,5 +4,5 b' class TestShortlogController(TestControl' | |||||
4 |
|
4 | |||
5 | def test_index(self): |
|
5 | def test_index(self): | |
6 | self.log_user() |
|
6 | self.log_user() | |
7 |
response = self.app.get(url(controller='shortlog', action='index',repo_name= |
|
7 | response = self.app.get(url(controller='shortlog', action='index',repo_name=HG_REPO)) | |
8 | # Test response... |
|
8 | # Test response... |
@@ -4,8 +4,14 b' class TestSummaryController(TestControll' | |||||
4 |
|
4 | |||
5 | def test_index(self): |
|
5 | def test_index(self): | |
6 | self.log_user() |
|
6 | self.log_user() | |
7 |
response = self.app.get(url(controller='summary', action='index', repo_name= |
|
7 | response = self.app.get(url(controller='summary', action='index', repo_name=HG_REPO)) | |
8 | print response |
|
8 | ||
9 | assert """<img style="margin-bottom:2px" class="icon" title="public repository" alt="public" src="/images/icons/lock_open.png"/>""" in response.body |
|
9 | #repo type | |
10 |
|
10 | assert """<img style="margin-bottom:2px" class="icon" title="Mercurial repository" alt="Mercurial repository" src="/images/icons/hgicon.png"/>""" in response.body | ||
11 | # Test response... |
|
11 | assert """<img style="margin-bottom:2px" class="icon" title="public repository" alt="public repository" src="/images/icons/lock_open.png"/>""" in response.body | |
|
12 | ||||
|
13 | #codes stats | |||
|
14 | assert """var data = {"text/x-python": 42, "text/plain": 12};""" in response.body, 'wrong info about % of codes stats' | |||
|
15 | ||||
|
16 | # clone url... | |||
|
17 | assert """<input type="text" id="clone_url" readonly="readonly" value="hg clone http://test_admin@localhost:80/%s" size="70"/>""" % HG_REPO in response.body |
@@ -4,5 +4,10 b' class TestTagsController(TestController)' | |||||
4 |
|
4 | |||
5 | def test_index(self): |
|
5 | def test_index(self): | |
6 | self.log_user() |
|
6 | self.log_user() | |
7 |
response = self.app.get(url(controller='tags', action='index',repo_name= |
|
7 | response = self.app.get(url(controller='tags', action='index', repo_name=HG_REPO)) | |
|
8 | assert """<a href="/%s/changeset/27cd5cce30c96924232dffcd24178a07ffeb5dfc">tip</a>""" % HG_REPO, 'wrong info about tip tag' | |||
|
9 | assert """<a href="/%s/changeset/fd4bdb5e9b2a29b4393a4ac6caef48c17ee1a200">0.1.4</a>""" % HG_REPO, 'wrong info about 0.1.4 tag' | |||
|
10 | assert """<a href="/%s/changeset/17544fbfcd33ffb439e2b728b5d526b1ef30bfcf">0.1.3</a>""" % HG_REPO, 'wrong info about 0.1.3 tag' | |||
|
11 | assert """<a href="/%s/changeset/a7e60bff65d57ac3a1a1ce3b12a70f8a9e8a7720">0.1.2</a>""" % HG_REPO, 'wrong info about 0.1.2 tag' | |||
|
12 | assert """<a href="/%s/changeset/eb3a60fc964309c1a318b8dfe26aa2d1586c85ae">0.1.1</a>""" % HG_REPO, 'wrong info about 0.1.1 tag' | |||
8 | # Test response... |
|
13 | # Test response... |
@@ -10,7 +10,13 b' class TestUsersController(TestController' | |||||
10 | response = self.app.get(url('formatted_users', format='xml')) |
|
10 | response = self.app.get(url('formatted_users', format='xml')) | |
11 |
|
11 | |||
12 | def test_create(self): |
|
12 | def test_create(self): | |
13 | response = self.app.post(url('users')) |
|
13 | self.log_user() | |
|
14 | # user_name = 'new_user' | |||
|
15 | # response = self.app.post(url('users'),{'repo_name':user_name, | |||
|
16 | # 'repo_type':'hg', | |||
|
17 | # 'description':description, | |||
|
18 | # 'private':private}) | |||
|
19 | ||||
14 |
|
20 | |||
15 | def test_new(self): |
|
21 | def test_new(self): | |
16 | response = self.app.get(url('new_user')) |
|
22 | response = self.app.get(url('new_user')) |
@@ -43,6 +43,7 b' full_stack = true' | |||||
43 | static_files = true |
|
43 | static_files = true | |
44 | lang=en |
|
44 | lang=en | |
45 | cache_dir = %(here)s/data |
|
45 | cache_dir = %(here)s/data | |
|
46 | index_dir = /tmp/index | |||
46 |
|
47 | |||
47 | #################################### |
|
48 | #################################### | |
48 | ### BEAKER CACHE #### |
|
49 | ### BEAKER CACHE #### |
1 | NO CONTENT: file was removed, binary diff hidden |
|
NO CONTENT: file was removed, binary diff hidden |
General Comments 0
You need to be logged in to leave comments.
Login now