Show More
@@ -1,83 +1,83 | |||||
1 | import time |
|
1 | import time | |
2 | from rhodecode.tests import * |
|
2 | from rhodecode.tests import * | |
3 | from rhodecode.tests.fixture import Fixture |
|
3 | from rhodecode.tests.fixture import Fixture | |
4 | from rhodecode.model.meta import Session |
|
4 | from rhodecode.model.meta import Session | |
5 | from rhodecode.model.db import User, Repository |
|
5 | from rhodecode.model.db import User, Repository | |
6 | from rhodecode.model.repo import RepoModel |
|
6 | from rhodecode.model.repo import RepoModel | |
7 | from rhodecode.model.repos_group import ReposGroupModel |
|
7 | from rhodecode.model.repos_group import ReposGroupModel | |
8 |
|
8 | |||
9 |
|
9 | |||
10 | fixture = Fixture() |
|
10 | fixture = Fixture() | |
11 |
|
11 | |||
12 |
|
12 | |||
13 | class TestHomeController(TestController): |
|
13 | class TestHomeController(TestController): | |
14 |
|
14 | |||
15 | def test_index(self): |
|
15 | def test_index(self): | |
16 | self.log_user() |
|
16 | self.log_user() | |
17 | response = self.app.get(url(controller='home', action='index')) |
|
17 | response = self.app.get(url(controller='home', action='index')) | |
18 | #if global permission is set |
|
18 | #if global permission is set | |
19 | response.mustcontain('Add repository') |
|
19 | response.mustcontain('Add repository') | |
20 | # html in javascript variable: |
|
20 | # html in javascript variable: | |
21 | response.mustcontain("""var data = {"totalRecords": %s""" |
|
21 | response.mustcontain("""var data = {"totalRecords": %s""" | |
22 | % len(Repository.getAll())) |
|
22 | % len(Repository.getAll())) | |
23 | response.mustcontain(r'href=\"/%s\"' % HG_REPO) |
|
23 | response.mustcontain(r'href=\"/%s\"' % HG_REPO) | |
24 |
|
24 | |||
25 | response.mustcontain(r"""<img class=\"icon\" title=\"Mercurial repository\" """ |
|
25 | response.mustcontain(r"""<img class=\"icon\" title=\"Mercurial repository\" """ | |
26 | r"""alt=\"Mercurial repository\" src=\"/images/icons/hg""" |
|
26 | r"""alt=\"Mercurial repository\" src=\"/images/icons/hg""" | |
27 | r"""icon.png\"/>""") |
|
27 | r"""icon.png\"/>""") | |
28 | response.mustcontain(r"""<img class=\"icon\" title=\"Public repository\" """ |
|
28 | response.mustcontain(r"""<img class=\"icon\" title=\"Public repository\" """ | |
29 |
r"""alt=\"Public repository\" src=\"/images/icons/ |
|
29 | r"""alt=\"Public repository\" src=\"/images/icons/public_""" | |
30 |
r""" |
|
30 | r"""repo.png\"/>""") | |
31 |
|
31 | |||
32 | response.mustcontain("""fixes issue with having custom format for git-log""") |
|
32 | response.mustcontain("""fixes issue with having custom format for git-log""") | |
33 | response.mustcontain("""/%s/changeset/5f2c6ee195929b0be80749243c18121c9864a3b3""" % GIT_REPO) |
|
33 | response.mustcontain("""/%s/changeset/5f2c6ee195929b0be80749243c18121c9864a3b3""" % GIT_REPO) | |
34 |
|
34 | |||
35 | response.mustcontain("""disable security checks on hg clone for travis""") |
|
35 | response.mustcontain("""disable security checks on hg clone for travis""") | |
36 | response.mustcontain("""/%s/changeset/96507bd11ecc815ebc6270fdf6db110928c09c1e""" % HG_REPO) |
|
36 | response.mustcontain("""/%s/changeset/96507bd11ecc815ebc6270fdf6db110928c09c1e""" % HG_REPO) | |
37 |
|
37 | |||
38 | def test_repo_summary_with_anonymous_access_disabled(self): |
|
38 | def test_repo_summary_with_anonymous_access_disabled(self): | |
39 | anon = User.get_default_user() |
|
39 | anon = User.get_default_user() | |
40 | anon.active = False |
|
40 | anon.active = False | |
41 | Session().add(anon) |
|
41 | Session().add(anon) | |
42 | Session().commit() |
|
42 | Session().commit() | |
43 | time.sleep(1.5) # must sleep for cache (1s to expire) |
|
43 | time.sleep(1.5) # must sleep for cache (1s to expire) | |
44 | try: |
|
44 | try: | |
45 | response = self.app.get(url(controller='summary', |
|
45 | response = self.app.get(url(controller='summary', | |
46 | action='index', repo_name=HG_REPO), |
|
46 | action='index', repo_name=HG_REPO), | |
47 | status=302) |
|
47 | status=302) | |
48 | assert 'login' in response.location |
|
48 | assert 'login' in response.location | |
49 |
|
49 | |||
50 | finally: |
|
50 | finally: | |
51 | anon = User.get_default_user() |
|
51 | anon = User.get_default_user() | |
52 | anon.active = True |
|
52 | anon.active = True | |
53 | Session().add(anon) |
|
53 | Session().add(anon) | |
54 | Session().commit() |
|
54 | Session().commit() | |
55 |
|
55 | |||
56 | def test_index_with_anonymous_access_disabled(self): |
|
56 | def test_index_with_anonymous_access_disabled(self): | |
57 | anon = User.get_default_user() |
|
57 | anon = User.get_default_user() | |
58 | anon.active = False |
|
58 | anon.active = False | |
59 | Session().add(anon) |
|
59 | Session().add(anon) | |
60 | Session().commit() |
|
60 | Session().commit() | |
61 | time.sleep(1.5) # must sleep for cache (1s to expire) |
|
61 | time.sleep(1.5) # must sleep for cache (1s to expire) | |
62 | try: |
|
62 | try: | |
63 | response = self.app.get(url(controller='home', action='index'), |
|
63 | response = self.app.get(url(controller='home', action='index'), | |
64 | status=302) |
|
64 | status=302) | |
65 | assert 'login' in response.location |
|
65 | assert 'login' in response.location | |
66 | finally: |
|
66 | finally: | |
67 | anon = User.get_default_user() |
|
67 | anon = User.get_default_user() | |
68 | anon.active = True |
|
68 | anon.active = True | |
69 | Session().add(anon) |
|
69 | Session().add(anon) | |
70 | Session().commit() |
|
70 | Session().commit() | |
71 |
|
71 | |||
72 | def test_index_page_on_groups(self): |
|
72 | def test_index_page_on_groups(self): | |
73 | self.log_user() |
|
73 | self.log_user() | |
74 | gr = fixture.create_group('gr1') |
|
74 | gr = fixture.create_group('gr1') | |
75 | fixture.create_repo(name='gr1/repo_in_group', repos_group=gr) |
|
75 | fixture.create_repo(name='gr1/repo_in_group', repos_group=gr) | |
76 | response = self.app.get(url('repos_group_home', group_name='gr1')) |
|
76 | response = self.app.get(url('repos_group_home', group_name='gr1')) | |
77 |
|
77 | |||
78 | try: |
|
78 | try: | |
79 | response.mustcontain("gr1/repo_in_group") |
|
79 | response.mustcontain("gr1/repo_in_group") | |
80 | finally: |
|
80 | finally: | |
81 | RepoModel().delete('gr1/repo_in_group') |
|
81 | RepoModel().delete('gr1/repo_in_group') | |
82 | ReposGroupModel().delete(repos_group='gr1', force_delete=True) |
|
82 | ReposGroupModel().delete(repos_group='gr1', force_delete=True) | |
83 | Session().commit() |
|
83 | Session().commit() |
@@ -1,125 +1,125 | |||||
1 | from rhodecode.tests import * |
|
1 | from rhodecode.tests import * | |
2 | from rhodecode.tests.fixture import Fixture |
|
2 | from rhodecode.tests.fixture import Fixture | |
3 | from rhodecode.model.db import Repository |
|
3 | from rhodecode.model.db import Repository | |
4 | from rhodecode.model.repo import RepoModel |
|
4 | from rhodecode.model.repo import RepoModel | |
5 | from rhodecode.model.meta import Session |
|
5 | from rhodecode.model.meta import Session | |
6 | from rhodecode.model.scm import ScmModel |
|
6 | from rhodecode.model.scm import ScmModel | |
7 |
|
7 | |||
8 | fixture = Fixture() |
|
8 | fixture = Fixture() | |
9 |
|
9 | |||
10 |
|
10 | |||
11 | class TestSummaryController(TestController): |
|
11 | class TestSummaryController(TestController): | |
12 |
|
12 | |||
13 | def test_index(self): |
|
13 | def test_index(self): | |
14 | self.log_user() |
|
14 | self.log_user() | |
15 | ID = Repository.get_by_repo_name(HG_REPO).repo_id |
|
15 | ID = Repository.get_by_repo_name(HG_REPO).repo_id | |
16 | response = self.app.get(url(controller='summary', |
|
16 | response = self.app.get(url(controller='summary', | |
17 | action='index', |
|
17 | action='index', | |
18 | repo_name=HG_REPO)) |
|
18 | repo_name=HG_REPO)) | |
19 |
|
19 | |||
20 | #repo type |
|
20 | #repo type | |
21 | response.mustcontain( |
|
21 | response.mustcontain( | |
22 | """<img style="margin-bottom:2px" class="icon" """ |
|
22 | """<img style="margin-bottom:2px" class="icon" """ | |
23 | """title="Mercurial repository" alt="Mercurial repository" """ |
|
23 | """title="Mercurial repository" alt="Mercurial repository" """ | |
24 | """src="/images/icons/hgicon.png"/>""" |
|
24 | """src="/images/icons/hgicon.png"/>""" | |
25 | ) |
|
25 | ) | |
26 | response.mustcontain( |
|
26 | response.mustcontain( | |
27 | """<img style="margin-bottom:2px" class="icon" """ |
|
27 | """<img style="margin-bottom:2px" class="icon" """ | |
28 | """title="Public repository" alt="Public """ |
|
28 | """title="Public repository" alt="Public """ | |
29 |
"""repository" src="/images/icons/ |
|
29 | """repository" src="/images/icons/public_repo.png"/>""" | |
30 | ) |
|
30 | ) | |
31 |
|
31 | |||
32 | #codes stats |
|
32 | #codes stats | |
33 | self._enable_stats() |
|
33 | self._enable_stats() | |
34 |
|
34 | |||
35 | ScmModel().mark_for_invalidation(HG_REPO) |
|
35 | ScmModel().mark_for_invalidation(HG_REPO) | |
36 | response = self.app.get(url(controller='summary', action='index', |
|
36 | response = self.app.get(url(controller='summary', action='index', | |
37 | repo_name=HG_REPO)) |
|
37 | repo_name=HG_REPO)) | |
38 | response.mustcontain( |
|
38 | response.mustcontain( | |
39 | """var data = [["py", {"count": 68, "desc": ["Python"]}], """ |
|
39 | """var data = [["py", {"count": 68, "desc": ["Python"]}], """ | |
40 | """["rst", {"count": 16, "desc": ["Rst"]}], """ |
|
40 | """["rst", {"count": 16, "desc": ["Rst"]}], """ | |
41 | """["css", {"count": 2, "desc": ["Css"]}], """ |
|
41 | """["css", {"count": 2, "desc": ["Css"]}], """ | |
42 | """["sh", {"count": 2, "desc": ["Bash"]}], """ |
|
42 | """["sh", {"count": 2, "desc": ["Bash"]}], """ | |
43 | """["yml", {"count": 1, "desc": ["Yaml"]}], """ |
|
43 | """["yml", {"count": 1, "desc": ["Yaml"]}], """ | |
44 | """["makefile", {"count": 1, "desc": ["Makefile", "Makefile"]}], """ |
|
44 | """["makefile", {"count": 1, "desc": ["Makefile", "Makefile"]}], """ | |
45 | """["js", {"count": 1, "desc": ["Javascript"]}], """ |
|
45 | """["js", {"count": 1, "desc": ["Javascript"]}], """ | |
46 | """["cfg", {"count": 1, "desc": ["Ini"]}], """ |
|
46 | """["cfg", {"count": 1, "desc": ["Ini"]}], """ | |
47 | """["ini", {"count": 1, "desc": ["Ini"]}], """ |
|
47 | """["ini", {"count": 1, "desc": ["Ini"]}], """ | |
48 | """["html", {"count": 1, "desc": ["EvoqueHtml", "Html"]}]];""" |
|
48 | """["html", {"count": 1, "desc": ["EvoqueHtml", "Html"]}]];""" | |
49 | ) |
|
49 | ) | |
50 |
|
50 | |||
51 | # clone url... |
|
51 | # clone url... | |
52 | response.mustcontain('''id="clone_url" readonly="readonly" value="http://test_admin@localhost:80/%s"''' % HG_REPO) |
|
52 | response.mustcontain('''id="clone_url" readonly="readonly" value="http://test_admin@localhost:80/%s"''' % HG_REPO) | |
53 | response.mustcontain('''id="clone_url_id" readonly="readonly" value="http://test_admin@localhost:80/_%s"''' % ID) |
|
53 | response.mustcontain('''id="clone_url_id" readonly="readonly" value="http://test_admin@localhost:80/_%s"''' % ID) | |
54 |
|
54 | |||
55 | def test_index_git(self): |
|
55 | def test_index_git(self): | |
56 | self.log_user() |
|
56 | self.log_user() | |
57 | ID = Repository.get_by_repo_name(GIT_REPO).repo_id |
|
57 | ID = Repository.get_by_repo_name(GIT_REPO).repo_id | |
58 | response = self.app.get(url(controller='summary', |
|
58 | response = self.app.get(url(controller='summary', | |
59 | action='index', |
|
59 | action='index', | |
60 | repo_name=GIT_REPO)) |
|
60 | repo_name=GIT_REPO)) | |
61 |
|
61 | |||
62 | #repo type |
|
62 | #repo type | |
63 | response.mustcontain( |
|
63 | response.mustcontain( | |
64 | """<img style="margin-bottom:2px" class="icon" """ |
|
64 | """<img style="margin-bottom:2px" class="icon" """ | |
65 | """title="Git repository" alt="Git repository" """ |
|
65 | """title="Git repository" alt="Git repository" """ | |
66 | """src="/images/icons/giticon.png"/>""" |
|
66 | """src="/images/icons/giticon.png"/>""" | |
67 | ) |
|
67 | ) | |
68 | response.mustcontain( |
|
68 | response.mustcontain( | |
69 | """<img style="margin-bottom:2px" class="icon" """ |
|
69 | """<img style="margin-bottom:2px" class="icon" """ | |
70 | """title="Public repository" alt="Public """ |
|
70 | """title="Public repository" alt="Public """ | |
71 |
"""repository" src="/images/icons/ |
|
71 | """repository" src="/images/icons/public_repo.png"/>""" | |
72 | ) |
|
72 | ) | |
73 |
|
73 | |||
74 | # clone url... |
|
74 | # clone url... | |
75 | response.mustcontain('''id="clone_url" readonly="readonly" value="http://test_admin@localhost:80/%s"''' % GIT_REPO) |
|
75 | response.mustcontain('''id="clone_url" readonly="readonly" value="http://test_admin@localhost:80/%s"''' % GIT_REPO) | |
76 | response.mustcontain('''id="clone_url_id" readonly="readonly" value="http://test_admin@localhost:80/_%s"''' % ID) |
|
76 | response.mustcontain('''id="clone_url_id" readonly="readonly" value="http://test_admin@localhost:80/_%s"''' % ID) | |
77 |
|
77 | |||
78 | def test_index_by_id_hg(self): |
|
78 | def test_index_by_id_hg(self): | |
79 | self.log_user() |
|
79 | self.log_user() | |
80 | ID = Repository.get_by_repo_name(HG_REPO).repo_id |
|
80 | ID = Repository.get_by_repo_name(HG_REPO).repo_id | |
81 | response = self.app.get(url(controller='summary', |
|
81 | response = self.app.get(url(controller='summary', | |
82 | action='index', |
|
82 | action='index', | |
83 | repo_name='_%s' % ID)) |
|
83 | repo_name='_%s' % ID)) | |
84 |
|
84 | |||
85 | #repo type |
|
85 | #repo type | |
86 | response.mustcontain("""<img style="margin-bottom:2px" class="icon" """ |
|
86 | response.mustcontain("""<img style="margin-bottom:2px" class="icon" """ | |
87 | """title="Mercurial repository" alt="Mercurial """ |
|
87 | """title="Mercurial repository" alt="Mercurial """ | |
88 | """repository" src="/images/icons/hgicon.png"/>""") |
|
88 | """repository" src="/images/icons/hgicon.png"/>""") | |
89 | response.mustcontain("""<img style="margin-bottom:2px" class="icon" """ |
|
89 | response.mustcontain("""<img style="margin-bottom:2px" class="icon" """ | |
90 | """title="Public repository" alt="Public """ |
|
90 | """title="Public repository" alt="Public """ | |
91 |
"""repository" src="/images/icons/ |
|
91 | """repository" src="/images/icons/public_repo.png"/>""") | |
92 |
|
92 | |||
93 | def test_index_by_repo_having_id_path_in_name_hg(self): |
|
93 | def test_index_by_repo_having_id_path_in_name_hg(self): | |
94 | self.log_user() |
|
94 | self.log_user() | |
95 | fixture.create_repo(name='repo_1') |
|
95 | fixture.create_repo(name='repo_1') | |
96 | response = self.app.get(url(controller='summary', |
|
96 | response = self.app.get(url(controller='summary', | |
97 | action='index', |
|
97 | action='index', | |
98 | repo_name='repo_1')) |
|
98 | repo_name='repo_1')) | |
99 |
|
99 | |||
100 | try: |
|
100 | try: | |
101 | response.mustcontain("repo_1") |
|
101 | response.mustcontain("repo_1") | |
102 | finally: |
|
102 | finally: | |
103 | RepoModel().delete(Repository.get_by_repo_name('repo_1')) |
|
103 | RepoModel().delete(Repository.get_by_repo_name('repo_1')) | |
104 | Session().commit() |
|
104 | Session().commit() | |
105 |
|
105 | |||
106 | def test_index_by_id_git(self): |
|
106 | def test_index_by_id_git(self): | |
107 | self.log_user() |
|
107 | self.log_user() | |
108 | ID = Repository.get_by_repo_name(GIT_REPO).repo_id |
|
108 | ID = Repository.get_by_repo_name(GIT_REPO).repo_id | |
109 | response = self.app.get(url(controller='summary', |
|
109 | response = self.app.get(url(controller='summary', | |
110 | action='index', |
|
110 | action='index', | |
111 | repo_name='_%s' % ID)) |
|
111 | repo_name='_%s' % ID)) | |
112 |
|
112 | |||
113 | #repo type |
|
113 | #repo type | |
114 | response.mustcontain("""<img style="margin-bottom:2px" class="icon" """ |
|
114 | response.mustcontain("""<img style="margin-bottom:2px" class="icon" """ | |
115 | """title="Git repository" alt="Git """ |
|
115 | """title="Git repository" alt="Git """ | |
116 | """repository" src="/images/icons/giticon.png"/>""") |
|
116 | """repository" src="/images/icons/giticon.png"/>""") | |
117 | response.mustcontain("""<img style="margin-bottom:2px" class="icon" """ |
|
117 | response.mustcontain("""<img style="margin-bottom:2px" class="icon" """ | |
118 | """title="Public repository" alt="Public """ |
|
118 | """title="Public repository" alt="Public """ | |
119 |
"""repository" src="/images/icons/ |
|
119 | """repository" src="/images/icons/public_repo.png"/>""") | |
120 |
|
120 | |||
121 | def _enable_stats(self): |
|
121 | def _enable_stats(self): | |
122 | r = Repository.get_by_repo_name(HG_REPO) |
|
122 | r = Repository.get_by_repo_name(HG_REPO) | |
123 | r.enable_statistics = True |
|
123 | r.enable_statistics = True | |
124 | Session().add(r) |
|
124 | Session().add(r) | |
125 | Session().commit() |
|
125 | Session().commit() |
General Comments 0
You need to be logged in to leave comments.
Login now