annotate rhodecode/tests/functional/test_admin_repos.py @ 723:bf26b46e82d6 beta

some tests update
author Marcin Kuzminski <marcin@python-works.com>
date Thu, 18 Nov 2010 23:11:51 +0100
parents 7486da5f0628
children f1629c0c28cc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
567
80dc0a23edf7 fixed whoosh failure on new repository
Marcin Kuzminski <marcin@python-works.com>
parents: 547
diff changeset
1 from rhodecode.model.db import Repository
547
1e757ac98988 renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 459
diff changeset
2 from rhodecode.tests import *
47
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
3
691
7486da5f0628 Refactor codes for scm model
Marcin Kuzminski <marcin@python-works.com>
parents: 688
diff changeset
4 class TestAdminReposController(TestController):
47
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
5
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
6 def test_index(self):
567
80dc0a23edf7 fixed whoosh failure on new repository
Marcin Kuzminski <marcin@python-works.com>
parents: 547
diff changeset
7 self.log_user()
47
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
8 response = self.app.get(url('repos'))
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
9 # Test response...
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
10
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
11 def test_index_as_xml(self):
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
12 response = self.app.get(url('formatted_repos', format='xml'))
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
13
688
8acbfa837180 Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents: 628
diff changeset
14 def test_create_hg(self):
567
80dc0a23edf7 fixed whoosh failure on new repository
Marcin Kuzminski <marcin@python-works.com>
parents: 547
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: 628
diff changeset
16 repo_name = NEW_HG_REPO
567
80dc0a23edf7 fixed whoosh failure on new repository
Marcin Kuzminski <marcin@python-works.com>
parents: 547
diff changeset
17 description = 'description for newly created repo'
80dc0a23edf7 fixed whoosh failure on new repository
Marcin Kuzminski <marcin@python-works.com>
parents: 547
diff changeset
18 private = False
80dc0a23edf7 fixed whoosh failure on new repository
Marcin Kuzminski <marcin@python-works.com>
parents: 547
diff changeset
19 response = self.app.post(url('repos'), {'repo_name':repo_name,
688
8acbfa837180 Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents: 628
diff changeset
20 'repo_type':'hg',
8acbfa837180 Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents: 628
diff changeset
21 'description':description,
8acbfa837180 Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents: 628
diff changeset
22 'private':private})
567
80dc0a23edf7 fixed whoosh failure on new repository
Marcin Kuzminski <marcin@python-works.com>
parents: 547
diff changeset
23
688
8acbfa837180 Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents: 628
diff changeset
24
628
dd06bdf974c8 fixed tests,
Marcin Kuzminski <marcin@python-works.com>
parents: 567
diff changeset
25 #test if we have a message for that repository
567
80dc0a23edf7 fixed whoosh failure on new repository
Marcin Kuzminski <marcin@python-works.com>
parents: 547
diff changeset
26 assert '''created repository %s''' % (repo_name) in response.session['flash'][0], 'No flash message about new repo'
688
8acbfa837180 Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents: 628
diff changeset
27
567
80dc0a23edf7 fixed whoosh failure on new repository
Marcin Kuzminski <marcin@python-works.com>
parents: 547
diff changeset
28 #test if the fork was created in the database
80dc0a23edf7 fixed whoosh failure on new repository
Marcin Kuzminski <marcin@python-works.com>
parents: 547
diff changeset
29 new_repo = self.sa.query(Repository).filter(Repository.repo_name == repo_name).one()
688
8acbfa837180 Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents: 628
diff changeset
30
567
80dc0a23edf7 fixed whoosh failure on new repository
Marcin Kuzminski <marcin@python-works.com>
parents: 547
diff changeset
31 assert new_repo.repo_name == repo_name, 'wrong name of repo name in db'
80dc0a23edf7 fixed whoosh failure on new repository
Marcin Kuzminski <marcin@python-works.com>
parents: 547
diff changeset
32 assert new_repo.description == description, 'wrong description'
688
8acbfa837180 Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents: 628
diff changeset
33
567
80dc0a23edf7 fixed whoosh failure on new repository
Marcin Kuzminski <marcin@python-works.com>
parents: 547
diff changeset
34 #test if repository is visible in the list ?
80dc0a23edf7 fixed whoosh failure on new repository
Marcin Kuzminski <marcin@python-works.com>
parents: 547
diff changeset
35 response = response.follow()
688
8acbfa837180 Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents: 628
diff changeset
36
567
80dc0a23edf7 fixed whoosh failure on new repository
Marcin Kuzminski <marcin@python-works.com>
parents: 547
diff changeset
37 assert repo_name in response.body, 'missing new repo from the main repos list'
688
8acbfa837180 Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents: 628
diff changeset
38
8acbfa837180 Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents: 628
diff changeset
39 def test_create_git(self):
8acbfa837180 Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents: 628
diff changeset
40 self.log_user()
8acbfa837180 Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents: 628
diff changeset
41 repo_name = NEW_GIT_REPO
8acbfa837180 Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents: 628
diff changeset
42 description = 'description for newly created repo'
8acbfa837180 Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents: 628
diff changeset
43 private = False
8acbfa837180 Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents: 628
diff changeset
44 response = self.app.post(url('repos'), {'repo_name':repo_name,
8acbfa837180 Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents: 628
diff changeset
45 'repo_type':'git',
8acbfa837180 Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents: 628
diff changeset
46 'description':description,
8acbfa837180 Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents: 628
diff changeset
47 'private':private})
8acbfa837180 Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents: 628
diff changeset
48
8acbfa837180 Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents: 628
diff changeset
49
8acbfa837180 Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents: 628
diff changeset
50 #test if we have a message for that repository
8acbfa837180 Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents: 628
diff changeset
51 assert '''created repository %s''' % (repo_name) in response.session['flash'][0], 'No flash message about new repo'
8acbfa837180 Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents: 628
diff changeset
52
8acbfa837180 Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents: 628
diff changeset
53 #test if the fork was created in the database
8acbfa837180 Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents: 628
diff changeset
54 new_repo = self.sa.query(Repository).filter(Repository.repo_name == repo_name).one()
8acbfa837180 Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents: 628
diff changeset
55
8acbfa837180 Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents: 628
diff changeset
56 assert new_repo.repo_name == repo_name, 'wrong name of repo name in db'
8acbfa837180 Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents: 628
diff changeset
57 assert new_repo.description == description, 'wrong description'
8acbfa837180 Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents: 628
diff changeset
58
8acbfa837180 Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents: 628
diff changeset
59 #test if repository is visible in the list ?
8acbfa837180 Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents: 628
diff changeset
60 response = response.follow()
8acbfa837180 Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents: 628
diff changeset
61
8acbfa837180 Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents: 628
diff changeset
62 assert repo_name in response.body, 'missing new repo from the main repos list'
567
80dc0a23edf7 fixed whoosh failure on new repository
Marcin Kuzminski <marcin@python-works.com>
parents: 547
diff changeset
63
47
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
64
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
65 def test_new(self):
567
80dc0a23edf7 fixed whoosh failure on new repository
Marcin Kuzminski <marcin@python-works.com>
parents: 547
diff changeset
66 self.log_user()
47
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
67 response = self.app.get(url('new_repo'))
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
68
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
69 def test_new_as_xml(self):
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
70 response = self.app.get(url('formatted_new_repo', format='xml'))
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
71
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
72 def test_update(self):
688
8acbfa837180 Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents: 628
diff changeset
73 response = self.app.put(url('repo', repo_name=HG_REPO))
47
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
74
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
75 def test_update_browser_fakeout(self):
688
8acbfa837180 Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents: 628
diff changeset
76 response = self.app.post(url('repo', repo_name=HG_REPO), params=dict(_method='put'))
47
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
77
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
78 def test_delete(self):
628
dd06bdf974c8 fixed tests,
Marcin Kuzminski <marcin@python-works.com>
parents: 567
diff changeset
79 self.log_user()
dd06bdf974c8 fixed tests,
Marcin Kuzminski <marcin@python-works.com>
parents: 567
diff changeset
80 repo_name = 'vcs_test_new_to_delete'
dd06bdf974c8 fixed tests,
Marcin Kuzminski <marcin@python-works.com>
parents: 567
diff changeset
81 description = 'description for newly created repo'
dd06bdf974c8 fixed tests,
Marcin Kuzminski <marcin@python-works.com>
parents: 567
diff changeset
82 private = False
dd06bdf974c8 fixed tests,
Marcin Kuzminski <marcin@python-works.com>
parents: 567
diff changeset
83 response = self.app.post(url('repos'), {'repo_name':repo_name,
688
8acbfa837180 Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents: 628
diff changeset
84 'repo_type':'hg',
628
dd06bdf974c8 fixed tests,
Marcin Kuzminski <marcin@python-works.com>
parents: 567
diff changeset
85 'description':description,
dd06bdf974c8 fixed tests,
Marcin Kuzminski <marcin@python-works.com>
parents: 567
diff changeset
86 'private':private})
dd06bdf974c8 fixed tests,
Marcin Kuzminski <marcin@python-works.com>
parents: 567
diff changeset
87
688
8acbfa837180 Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents: 628
diff changeset
88
628
dd06bdf974c8 fixed tests,
Marcin Kuzminski <marcin@python-works.com>
parents: 567
diff changeset
89 #test if we have a message for that repository
dd06bdf974c8 fixed tests,
Marcin Kuzminski <marcin@python-works.com>
parents: 567
diff changeset
90 assert '''created repository %s''' % (repo_name) in response.session['flash'][0], 'No flash message about new repo'
688
8acbfa837180 Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents: 628
diff changeset
91
628
dd06bdf974c8 fixed tests,
Marcin Kuzminski <marcin@python-works.com>
parents: 567
diff changeset
92 #test if the repo was created in the database
dd06bdf974c8 fixed tests,
Marcin Kuzminski <marcin@python-works.com>
parents: 567
diff changeset
93 new_repo = self.sa.query(Repository).filter(Repository.repo_name == repo_name).one()
688
8acbfa837180 Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents: 628
diff changeset
94
628
dd06bdf974c8 fixed tests,
Marcin Kuzminski <marcin@python-works.com>
parents: 567
diff changeset
95 assert new_repo.repo_name == repo_name, 'wrong name of repo name in db'
dd06bdf974c8 fixed tests,
Marcin Kuzminski <marcin@python-works.com>
parents: 567
diff changeset
96 assert new_repo.description == description, 'wrong description'
688
8acbfa837180 Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents: 628
diff changeset
97
628
dd06bdf974c8 fixed tests,
Marcin Kuzminski <marcin@python-works.com>
parents: 567
diff changeset
98 #test if repository is visible in the list ?
dd06bdf974c8 fixed tests,
Marcin Kuzminski <marcin@python-works.com>
parents: 567
diff changeset
99 response = response.follow()
688
8acbfa837180 Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents: 628
diff changeset
100
628
dd06bdf974c8 fixed tests,
Marcin Kuzminski <marcin@python-works.com>
parents: 567
diff changeset
101 assert repo_name in response.body, 'missing new repo from the main repos list'
688
8acbfa837180 Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents: 628
diff changeset
102
8acbfa837180 Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents: 628
diff changeset
103
628
dd06bdf974c8 fixed tests,
Marcin Kuzminski <marcin@python-works.com>
parents: 567
diff changeset
104 response = self.app.delete(url('repo', repo_name=repo_name))
688
8acbfa837180 Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents: 628
diff changeset
105
628
dd06bdf974c8 fixed tests,
Marcin Kuzminski <marcin@python-works.com>
parents: 567
diff changeset
106 assert '''deleted repository %s''' % (repo_name) in response.session['flash'][0], 'No flash message about delete repo'
688
8acbfa837180 Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents: 628
diff changeset
107
628
dd06bdf974c8 fixed tests,
Marcin Kuzminski <marcin@python-works.com>
parents: 567
diff changeset
108 response.follow()
688
8acbfa837180 Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents: 628
diff changeset
109
628
dd06bdf974c8 fixed tests,
Marcin Kuzminski <marcin@python-works.com>
parents: 567
diff changeset
110 #check if repo was deleted from db
dd06bdf974c8 fixed tests,
Marcin Kuzminski <marcin@python-works.com>
parents: 567
diff changeset
111 deleted_repo = self.sa.query(Repository).filter(Repository.repo_name == repo_name).scalar()
688
8acbfa837180 Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents: 628
diff changeset
112
628
dd06bdf974c8 fixed tests,
Marcin Kuzminski <marcin@python-works.com>
parents: 567
diff changeset
113 assert deleted_repo is None, 'Deleted repository was found in db'
688
8acbfa837180 Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents: 628
diff changeset
114
47
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
115
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
116 def test_delete_browser_fakeout(self):
688
8acbfa837180 Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents: 628
diff changeset
117 response = self.app.post(url('repo', repo_name=HG_REPO), params=dict(_method='delete'))
47
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
118
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
119 def test_show(self):
567
80dc0a23edf7 fixed whoosh failure on new repository
Marcin Kuzminski <marcin@python-works.com>
parents: 547
diff changeset
120 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: 628
diff changeset
121 response = self.app.get(url('repo', repo_name=HG_REPO))
47
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
122
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
123 def test_show_as_xml(self):
688
8acbfa837180 Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents: 628
diff changeset
124 response = self.app.get(url('formatted_repo', repo_name=HG_REPO, format='xml'))
47
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
125
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
126 def test_edit(self):
688
8acbfa837180 Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents: 628
diff changeset
127 response = self.app.get(url('edit_repo', repo_name=HG_REPO))
47
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
128
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
129 def test_edit_as_xml(self):
688
8acbfa837180 Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents: 628
diff changeset
130 response = self.app.get(url('formatted_edit_repo', repo_name=HG_REPO, format='xml'))