annotate kallithea/tests/functional/test_home.py @ 6220:7bffccee3a49

db: inline calls to get_all This method saves basically no typing, compared to "query().all()". Additionally, "all()" returns a list, forcing all records to be loaded into a memory at the same time, but some callers just need to iterate over the objects one at a time, in which case "query()" alone is more efficient. In one case, the caller can even use "count()" and avoid loading any objects from the database at all.
author Søren Løvborg <sorenl@unity3d.com>
date Fri, 23 Sep 2016 14:05:42 +0200
parents 8d98924c58b1
children 481f64dbe85c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6217
8d98924c58b1 tests: add as little code as possible in __init__.py
Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>
parents: 6116
diff changeset
1 from kallithea.tests.base import *
4186
7e5f8c12a3fc First step in two-part process to rename directories to kallithea.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4116
diff changeset
2 from kallithea.tests.fixture import Fixture
7e5f8c12a3fc First step in two-part process to rename directories to kallithea.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4116
diff changeset
3 from kallithea.model.meta import Session
4422
d51a6f5e57d1 cleanup: remove unused Python imports, found with pyflakes
Mads Kiilerich <madski@unity3d.com>
parents: 4187
diff changeset
4 from kallithea.model.db import Repository
4186
7e5f8c12a3fc First step in two-part process to rename directories to kallithea.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4116
diff changeset
5 from kallithea.model.repo import RepoModel
7e5f8c12a3fc First step in two-part process to rename directories to kallithea.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4116
diff changeset
6 from kallithea.model.repo_group import RepoGroupModel
462
298546182b41 more test suites on login, fixed strange detached instance bug found during in tests.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
7
1788
ef0613584ced test fixes
Marcin Kuzminski <marcin@python-works.com>
parents: 1481
diff changeset
8
3647
8a86836fad64 more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents: 3291
diff changeset
9 fixture = Fixture()
8a86836fad64 more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents: 3291
diff changeset
10
8a86836fad64 more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents: 3291
diff changeset
11
5922
7f2aa3ec2931 pytest migration: rename TestControllerPytest back to TestController
Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>
parents: 5711
diff changeset
12 class TestHomeController(TestController):
462
298546182b41 more test suites on login, fixed strange detached instance bug found during in tests.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
13
298546182b41 more test suites on login, fixed strange detached instance bug found during in tests.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
14 def test_index(self):
464
cbe777be5b8c some more basic tests
Marcin Kuzminski <marcin@python-works.com>
parents: 462
diff changeset
15 self.log_user()
688
8acbfa837180 Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents: 547
diff changeset
16 response = self.app.get(url(controller='home', action='index'))
464
cbe777be5b8c some more basic tests
Marcin Kuzminski <marcin@python-works.com>
parents: 462
diff changeset
17 #if global permission is set
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4010
diff changeset
18 response.mustcontain('Add Repository')
3752
1e5bb8ed77d6 index: always use lightweight - there shouldn't be any reason not to
Mads Kiilerich <madski@unity3d.com>
parents: 3734
diff changeset
19 # html in javascript variable:
6220
7bffccee3a49 db: inline calls to get_all
Søren Løvborg <sorenl@unity3d.com>
parents: 6217
diff changeset
20 response.mustcontain('var data = {"totalRecords": %s' % Repository.query().count())
3752
1e5bb8ed77d6 index: always use lightweight - there shouldn't be any reason not to
Mads Kiilerich <madski@unity3d.com>
parents: 3734
diff changeset
21 response.mustcontain(r'href=\"/%s\"' % HG_REPO)
875
0765fd5bf668 tests update
Marcin Kuzminski <marcin@python-works.com>
parents: 691
diff changeset
22
4839
1619d9ebc1b9 giticon.png: use repotag class to make an icon
Sean Farley <sean.michael.farley@gmail.com>
parents: 4602
diff changeset
23 response.mustcontain(r'<span class="repotag">git')
4602
961ef96fcc65 icon-lock-open-alt: use icon-globe to signify public repo
Sean Farley <sean.michael.farley@gmail.com>
parents: 4601
diff changeset
24 response.mustcontain(r'<i class=\"icon-globe\"')
1788
ef0613584ced test fixes
Marcin Kuzminski <marcin@python-works.com>
parents: 1481
diff changeset
25
3797
d7488551578e synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents: 3752
diff changeset
26 response.mustcontain("""fixes issue with having custom format for git-log""")
d7488551578e synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents: 3752
diff changeset
27 response.mustcontain("""/%s/changeset/5f2c6ee195929b0be80749243c18121c9864a3b3""" % GIT_REPO)
d7488551578e synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents: 3752
diff changeset
28
d7488551578e synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents: 3752
diff changeset
29 response.mustcontain("""disable security checks on hg clone for travis""")
d7488551578e synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents: 3752
diff changeset
30 response.mustcontain("""/%s/changeset/96507bd11ecc815ebc6270fdf6db110928c09c1e""" % HG_REPO)
2714
a2eaa0054430 fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents: 2427
diff changeset
31
a2eaa0054430 fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents: 2427
diff changeset
32 def test_repo_summary_with_anonymous_access_disabled(self):
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4010
diff changeset
33 with fixture.anon_access(False):
2714
a2eaa0054430 fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents: 2427
diff changeset
34 response = self.app.get(url(controller='summary',
a2eaa0054430 fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents: 2427
diff changeset
35 action='index', repo_name=HG_REPO),
a2eaa0054430 fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents: 2427
diff changeset
36 status=302)
a2eaa0054430 fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents: 2427
diff changeset
37 assert 'login' in response.location
a2eaa0054430 fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents: 2427
diff changeset
38
a2eaa0054430 fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents: 2427
diff changeset
39 def test_index_with_anonymous_access_disabled(self):
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4010
diff changeset
40 with fixture.anon_access(False):
2714
a2eaa0054430 fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents: 2427
diff changeset
41 response = self.app.get(url(controller='home', action='index'),
a2eaa0054430 fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents: 2427
diff changeset
42 status=302)
a2eaa0054430 fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents: 2427
diff changeset
43 assert 'login' in response.location
2946
dbb311201ce3 add test for enabling lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents: 2714
diff changeset
44
3167
87258a137018 fixed issue with displaying repos in groups view (without lightweight dashboard), added tests for this case
Marcin Kuzminski <marcin@python-works.com>
parents: 2973
diff changeset
45 def test_index_page_on_groups(self):
87258a137018 fixed issue with displaying repos in groups view (without lightweight dashboard), added tests for this case
Marcin Kuzminski <marcin@python-works.com>
parents: 2973
diff changeset
46 self.log_user()
5631
bd4840ad72d3 tests: more consistently use unicode where unicode is expected
Mads Kiilerich <madski@unity3d.com>
parents: 4839
diff changeset
47 gr = fixture.create_repo_group(u'gr1')
bd4840ad72d3 tests: more consistently use unicode where unicode is expected
Mads Kiilerich <madski@unity3d.com>
parents: 4839
diff changeset
48 fixture.create_repo(name=u'gr1/repo_in_group', repo_group=gr)
bd4840ad72d3 tests: more consistently use unicode where unicode is expected
Mads Kiilerich <madski@unity3d.com>
parents: 4839
diff changeset
49 response = self.app.get(url('repos_group_home', group_name=u'gr1'))
3167
87258a137018 fixed issue with displaying repos in groups view (without lightweight dashboard), added tests for this case
Marcin Kuzminski <marcin@python-works.com>
parents: 2973
diff changeset
50
87258a137018 fixed issue with displaying repos in groups view (without lightweight dashboard), added tests for this case
Marcin Kuzminski <marcin@python-works.com>
parents: 2973
diff changeset
51 try:
5631
bd4840ad72d3 tests: more consistently use unicode where unicode is expected
Mads Kiilerich <madski@unity3d.com>
parents: 4839
diff changeset
52 response.mustcontain(u"gr1/repo_in_group")
3167
87258a137018 fixed issue with displaying repos in groups view (without lightweight dashboard), added tests for this case
Marcin Kuzminski <marcin@python-works.com>
parents: 2973
diff changeset
53 finally:
5631
bd4840ad72d3 tests: more consistently use unicode where unicode is expected
Mads Kiilerich <madski@unity3d.com>
parents: 4839
diff changeset
54 RepoModel().delete(u'gr1/repo_in_group')
bd4840ad72d3 tests: more consistently use unicode where unicode is expected
Mads Kiilerich <madski@unity3d.com>
parents: 4839
diff changeset
55 RepoGroupModel().delete(repo_group=u'gr1', force_delete=True)
3167
87258a137018 fixed issue with displaying repos in groups view (without lightweight dashboard), added tests for this case
Marcin Kuzminski <marcin@python-works.com>
parents: 2973
diff changeset
56 Session().commit()