annotate rhodecode/tests/functional/test_summary.py @ 3693:6843cabe9925 beta

removed duplicated logic of how we invalidate caches for repos
author Marcin Kuzminski <marcin@python-works.com>
date Wed, 03 Apr 2013 02:35:01 +0200
parents ec6354949623
children d7488551578e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
547
1e757ac98988 renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 473
diff changeset
1 from rhodecode.tests import *
3647
8a86836fad64 more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents: 3291
diff changeset
2 from rhodecode.tests.fixture import Fixture
1080
c334e972f459 fixed summary tests
Marcin Kuzminski <marcin@python-works.com>
parents: 782
diff changeset
3 from rhodecode.model.db import Repository
2822
1670ee0aded7 fixed issue #559 fixed bug in routing that mapped repo names with <name>_<num> in name as
Marcin Kuzminski <marcin@python-works.com>
parents: 2459
diff changeset
4 from rhodecode.model.repo import RepoModel
1670ee0aded7 fixed issue #559 fixed bug in routing that mapped repo names with <name>_<num> in name as
Marcin Kuzminski <marcin@python-works.com>
parents: 2459
diff changeset
5 from rhodecode.model.meta import Session
3693
6843cabe9925 removed duplicated logic of how we invalidate caches for repos
Marcin Kuzminski <marcin@python-works.com>
parents: 3654
diff changeset
6 from rhodecode.model.scm import ScmModel
82
670713507d03 Moved summary to seperate controller,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
7
3647
8a86836fad64 more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents: 3291
diff changeset
8 fixture = Fixture()
8a86836fad64 more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents: 3291
diff changeset
9
1813
a8c66e870bd0 implements #285: Implemented non changeable urls for clone url, and web views
Marcin Kuzminski <marcin@python-works.com>
parents: 1749
diff changeset
10
82
670713507d03 Moved summary to seperate controller,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
11 class TestSummaryController(TestController):
670713507d03 Moved summary to seperate controller,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
12
670713507d03 Moved summary to seperate controller,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
13 def test_index(self):
473
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 459
diff changeset
14 self.log_user()
1813
a8c66e870bd0 implements #285: Implemented non changeable urls for clone url, and web views
Marcin Kuzminski <marcin@python-works.com>
parents: 1749
diff changeset
15 ID = Repository.get_by_repo_name(HG_REPO).repo_id
1366
9c0f5d558789 fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached
Marcin Kuzminski <marcin@python-works.com>
parents: 1203
diff changeset
16 response = self.app.get(url(controller='summary',
1818
cf51bbfb120e auto white-space removal
Marcin Kuzminski <marcin@python-works.com>
parents: 1813
diff changeset
17 action='index',
1813
a8c66e870bd0 implements #285: Implemented non changeable urls for clone url, and web views
Marcin Kuzminski <marcin@python-works.com>
parents: 1749
diff changeset
18 repo_name=HG_REPO))
688
8acbfa837180 Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents: 567
diff changeset
19
8acbfa837180 Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents: 567
diff changeset
20 #repo type
1895
b7adbd5456c2 test fixes for latest changes
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
21 response.mustcontain(
b7adbd5456c2 test fixes for latest changes
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
22 """<img style="margin-bottom:2px" class="icon" """
2451
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 1895
diff changeset
23 """title="Mercurial repository" alt="Mercurial repository" """
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 1895
diff changeset
24 """src="/images/icons/hgicon.png"/>"""
1895
b7adbd5456c2 test fixes for latest changes
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
25 )
b7adbd5456c2 test fixes for latest changes
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
26 response.mustcontain(
b7adbd5456c2 test fixes for latest changes
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
27 """<img style="margin-bottom:2px" class="icon" """
3654
ec6354949623 Fix a lot of casings - use standard casing in most places
Mads Kiilerich <madski@unity3d.com>
parents: 3647
diff changeset
28 """title="Public repository" alt="Public """
1895
b7adbd5456c2 test fixes for latest changes
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
29 """repository" src="/images/icons/lock_open.png"/>"""
b7adbd5456c2 test fixes for latest changes
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
30 )
688
8acbfa837180 Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents: 567
diff changeset
31
8acbfa837180 Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents: 567
diff changeset
32 #codes stats
1366
9c0f5d558789 fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached
Marcin Kuzminski <marcin@python-works.com>
parents: 1203
diff changeset
33 self._enable_stats()
1080
c334e972f459 fixed summary tests
Marcin Kuzminski <marcin@python-works.com>
parents: 782
diff changeset
34
3693
6843cabe9925 removed duplicated logic of how we invalidate caches for repos
Marcin Kuzminski <marcin@python-works.com>
parents: 3654
diff changeset
35 ScmModel().mark_for_invalidation(HG_REPO)
1366
9c0f5d558789 fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached
Marcin Kuzminski <marcin@python-works.com>
parents: 1203
diff changeset
36 response = self.app.get(url(controller='summary', action='index',
9c0f5d558789 fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached
Marcin Kuzminski <marcin@python-works.com>
parents: 1203
diff changeset
37 repo_name=HG_REPO))
1895
b7adbd5456c2 test fixes for latest changes
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
38 response.mustcontain(
b7adbd5456c2 test fixes for latest changes
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
39 """var data = [["py", {"count": 42, "desc": ["Python"]}], """
b7adbd5456c2 test fixes for latest changes
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
40 """["rst", {"count": 11, "desc": ["Rst"]}], """
b7adbd5456c2 test fixes for latest changes
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
41 """["sh", {"count": 2, "desc": ["Bash"]}], """
b7adbd5456c2 test fixes for latest changes
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
42 """["makefile", {"count": 1, "desc": ["Makefile", "Makefile"]}],"""
b7adbd5456c2 test fixes for latest changes
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
43 """ ["cfg", {"count": 1, "desc": ["Ini"]}], """
b7adbd5456c2 test fixes for latest changes
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
44 """["css", {"count": 1, "desc": ["Css"]}], """
b7adbd5456c2 test fixes for latest changes
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
45 """["bat", {"count": 1, "desc": ["Batch"]}]];"""
b7adbd5456c2 test fixes for latest changes
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
46 )
688
8acbfa837180 Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents: 567
diff changeset
47
8acbfa837180 Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents: 567
diff changeset
48 # clone url...
3291
f4ce9416cbd5 fixed tests
Marcin Kuzminski <marcin@python-works.com>
parents: 2822
diff changeset
49 response.mustcontain('''id="clone_url" readonly="readonly" value="http://test_admin@localhost:80/%s"''' % HG_REPO)
f4ce9416cbd5 fixed tests
Marcin Kuzminski <marcin@python-works.com>
parents: 2822
diff changeset
50 response.mustcontain('''id="clone_url_id" readonly="readonly" value="http://test_admin@localhost:80/_%s"''' % ID)
2451
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 1895
diff changeset
51
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 1895
diff changeset
52 def test_index_git(self):
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 1895
diff changeset
53 self.log_user()
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 1895
diff changeset
54 ID = Repository.get_by_repo_name(GIT_REPO).repo_id
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 1895
diff changeset
55 response = self.app.get(url(controller='summary',
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 1895
diff changeset
56 action='index',
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 1895
diff changeset
57 repo_name=GIT_REPO))
782
51127b2efb33 fixed broken test after latest changes
Marcin Kuzminski <marcin@python-works.com>
parents: 688
diff changeset
58
2451
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 1895
diff changeset
59 #repo type
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 1895
diff changeset
60 response.mustcontain(
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 1895
diff changeset
61 """<img style="margin-bottom:2px" class="icon" """
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 1895
diff changeset
62 """title="Git repository" alt="Git repository" """
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 1895
diff changeset
63 """src="/images/icons/giticon.png"/>"""
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 1895
diff changeset
64 )
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 1895
diff changeset
65 response.mustcontain(
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 1895
diff changeset
66 """<img style="margin-bottom:2px" class="icon" """
3654
ec6354949623 Fix a lot of casings - use standard casing in most places
Mads Kiilerich <madski@unity3d.com>
parents: 3647
diff changeset
67 """title="Public repository" alt="Public """
2451
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 1895
diff changeset
68 """repository" src="/images/icons/lock_open.png"/>"""
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 1895
diff changeset
69 )
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 1895
diff changeset
70
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 1895
diff changeset
71 # clone url...
3291
f4ce9416cbd5 fixed tests
Marcin Kuzminski <marcin@python-works.com>
parents: 2822
diff changeset
72 response.mustcontain('''id="clone_url" readonly="readonly" value="http://test_admin@localhost:80/%s"''' % GIT_REPO)
f4ce9416cbd5 fixed tests
Marcin Kuzminski <marcin@python-works.com>
parents: 2822
diff changeset
73 response.mustcontain('''id="clone_url_id" readonly="readonly" value="http://test_admin@localhost:80/_%s"''' % ID)
2451
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 1895
diff changeset
74
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 1895
diff changeset
75 def test_index_by_id_hg(self):
1813
a8c66e870bd0 implements #285: Implemented non changeable urls for clone url, and web views
Marcin Kuzminski <marcin@python-works.com>
parents: 1749
diff changeset
76 self.log_user()
a8c66e870bd0 implements #285: Implemented non changeable urls for clone url, and web views
Marcin Kuzminski <marcin@python-works.com>
parents: 1749
diff changeset
77 ID = Repository.get_by_repo_name(HG_REPO).repo_id
a8c66e870bd0 implements #285: Implemented non changeable urls for clone url, and web views
Marcin Kuzminski <marcin@python-works.com>
parents: 1749
diff changeset
78 response = self.app.get(url(controller='summary',
1818
cf51bbfb120e auto white-space removal
Marcin Kuzminski <marcin@python-works.com>
parents: 1813
diff changeset
79 action='index',
1813
a8c66e870bd0 implements #285: Implemented non changeable urls for clone url, and web views
Marcin Kuzminski <marcin@python-works.com>
parents: 1749
diff changeset
80 repo_name='_%s' % ID))
a8c66e870bd0 implements #285: Implemented non changeable urls for clone url, and web views
Marcin Kuzminski <marcin@python-works.com>
parents: 1749
diff changeset
81
a8c66e870bd0 implements #285: Implemented non changeable urls for clone url, and web views
Marcin Kuzminski <marcin@python-works.com>
parents: 1749
diff changeset
82 #repo type
a8c66e870bd0 implements #285: Implemented non changeable urls for clone url, and web views
Marcin Kuzminski <marcin@python-works.com>
parents: 1749
diff changeset
83 response.mustcontain("""<img style="margin-bottom:2px" class="icon" """
a8c66e870bd0 implements #285: Implemented non changeable urls for clone url, and web views
Marcin Kuzminski <marcin@python-works.com>
parents: 1749
diff changeset
84 """title="Mercurial repository" alt="Mercurial """
a8c66e870bd0 implements #285: Implemented non changeable urls for clone url, and web views
Marcin Kuzminski <marcin@python-works.com>
parents: 1749
diff changeset
85 """repository" src="/images/icons/hgicon.png"/>""")
a8c66e870bd0 implements #285: Implemented non changeable urls for clone url, and web views
Marcin Kuzminski <marcin@python-works.com>
parents: 1749
diff changeset
86 response.mustcontain("""<img style="margin-bottom:2px" class="icon" """
3654
ec6354949623 Fix a lot of casings - use standard casing in most places
Mads Kiilerich <madski@unity3d.com>
parents: 3647
diff changeset
87 """title="Public repository" alt="Public """
1813
a8c66e870bd0 implements #285: Implemented non changeable urls for clone url, and web views
Marcin Kuzminski <marcin@python-works.com>
parents: 1749
diff changeset
88 """repository" src="/images/icons/lock_open.png"/>""")
782
51127b2efb33 fixed broken test after latest changes
Marcin Kuzminski <marcin@python-works.com>
parents: 688
diff changeset
89
2822
1670ee0aded7 fixed issue #559 fixed bug in routing that mapped repo names with <name>_<num> in name as
Marcin Kuzminski <marcin@python-works.com>
parents: 2459
diff changeset
90 def test_index_by_repo_having_id_path_in_name_hg(self):
1670ee0aded7 fixed issue #559 fixed bug in routing that mapped repo names with <name>_<num> in name as
Marcin Kuzminski <marcin@python-works.com>
parents: 2459
diff changeset
91 self.log_user()
3647
8a86836fad64 more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents: 3291
diff changeset
92 fixture.create_repo(name='repo_1')
2822
1670ee0aded7 fixed issue #559 fixed bug in routing that mapped repo names with <name>_<num> in name as
Marcin Kuzminski <marcin@python-works.com>
parents: 2459
diff changeset
93 response = self.app.get(url(controller='summary',
1670ee0aded7 fixed issue #559 fixed bug in routing that mapped repo names with <name>_<num> in name as
Marcin Kuzminski <marcin@python-works.com>
parents: 2459
diff changeset
94 action='index',
1670ee0aded7 fixed issue #559 fixed bug in routing that mapped repo names with <name>_<num> in name as
Marcin Kuzminski <marcin@python-works.com>
parents: 2459
diff changeset
95 repo_name='repo_1'))
1670ee0aded7 fixed issue #559 fixed bug in routing that mapped repo names with <name>_<num> in name as
Marcin Kuzminski <marcin@python-works.com>
parents: 2459
diff changeset
96
1670ee0aded7 fixed issue #559 fixed bug in routing that mapped repo names with <name>_<num> in name as
Marcin Kuzminski <marcin@python-works.com>
parents: 2459
diff changeset
97 try:
3647
8a86836fad64 more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents: 3291
diff changeset
98 response.mustcontain("repo_1")
2822
1670ee0aded7 fixed issue #559 fixed bug in routing that mapped repo names with <name>_<num> in name as
Marcin Kuzminski <marcin@python-works.com>
parents: 2459
diff changeset
99 finally:
1670ee0aded7 fixed issue #559 fixed bug in routing that mapped repo names with <name>_<num> in name as
Marcin Kuzminski <marcin@python-works.com>
parents: 2459
diff changeset
100 RepoModel().delete(Repository.get_by_repo_name('repo_1'))
1670ee0aded7 fixed issue #559 fixed bug in routing that mapped repo names with <name>_<num> in name as
Marcin Kuzminski <marcin@python-works.com>
parents: 2459
diff changeset
101 Session().commit()
1670ee0aded7 fixed issue #559 fixed bug in routing that mapped repo names with <name>_<num> in name as
Marcin Kuzminski <marcin@python-works.com>
parents: 2459
diff changeset
102
2451
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 1895
diff changeset
103 def test_index_by_id_git(self):
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 1895
diff changeset
104 self.log_user()
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 1895
diff changeset
105 ID = Repository.get_by_repo_name(GIT_REPO).repo_id
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 1895
diff changeset
106 response = self.app.get(url(controller='summary',
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 1895
diff changeset
107 action='index',
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 1895
diff changeset
108 repo_name='_%s' % ID))
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 1895
diff changeset
109
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 1895
diff changeset
110 #repo type
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 1895
diff changeset
111 response.mustcontain("""<img style="margin-bottom:2px" class="icon" """
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 1895
diff changeset
112 """title="Git repository" alt="Git """
2459
9492ab68331f Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents: 2451
diff changeset
113 """repository" src="/images/icons/giticon.png"/>""")
2451
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 1895
diff changeset
114 response.mustcontain("""<img style="margin-bottom:2px" class="icon" """
3654
ec6354949623 Fix a lot of casings - use standard casing in most places
Mads Kiilerich <madski@unity3d.com>
parents: 3647
diff changeset
115 """title="Public repository" alt="Public """
2451
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 1895
diff changeset
116 """repository" src="/images/icons/lock_open.png"/>""")
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 1895
diff changeset
117
1080
c334e972f459 fixed summary tests
Marcin Kuzminski <marcin@python-works.com>
parents: 782
diff changeset
118 def _enable_stats(self):
1530
04027bdb876c Refactoring of model get functions
Marcin Kuzminski <marcin@python-works.com>
parents: 1366
diff changeset
119 r = Repository.get_by_repo_name(HG_REPO)
1080
c334e972f459 fixed summary tests
Marcin Kuzminski <marcin@python-works.com>
parents: 782
diff changeset
120 r.enable_statistics = True
1749
8ecc6b8229a5 commit less models
Marcin Kuzminski <marcin@python-works.com>
parents: 1713
diff changeset
121 self.Session.add(r)
8ecc6b8229a5 commit less models
Marcin Kuzminski <marcin@python-works.com>
parents: 1713
diff changeset
122 self.Session.commit()