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