##// END OF EJS Templates
added repo creation filesystem test
marcink -
r1037:b1d6478d beta
parent child Browse files
Show More
@@ -1,131 +1,147 b''
1 import os
2 import vcs
3
1 from rhodecode.model.db import Repository
4 from rhodecode.model.db import Repository
2 from rhodecode.tests import *
5 from rhodecode.tests import *
3
6
4 class TestAdminReposController(TestController):
7 class TestAdminReposController(TestController):
5
8
6 def test_index(self):
9 def test_index(self):
7 self.log_user()
10 self.log_user()
8 response = self.app.get(url('repos'))
11 response = self.app.get(url('repos'))
9 # Test response...
12 # Test response...
10
13
11 def test_index_as_xml(self):
14 def test_index_as_xml(self):
12 response = self.app.get(url('formatted_repos', format='xml'))
15 response = self.app.get(url('formatted_repos', format='xml'))
13
16
14 def test_create_hg(self):
17 def test_create_hg(self):
15 self.log_user()
18 self.log_user()
16 repo_name = NEW_HG_REPO
19 repo_name = NEW_HG_REPO
17 description = 'description for newly created repo'
20 description = 'description for newly created repo'
18 private = False
21 private = False
19 response = self.app.post(url('repos'), {'repo_name':repo_name,
22 response = self.app.post(url('repos'), {'repo_name':repo_name,
20 'repo_type':'hg',
23 'repo_type':'hg',
21 'description':description,
24 'description':description,
22 'private':private})
25 'private':private})
23
26
24
27
25 #test if we have a message for that repository
28 #test if we have a message for that repository
26 assert '''created repository %s''' % (repo_name) in response.session['flash'][0], 'No flash message about new repo'
29 assert '''created repository %s''' % (repo_name) in response.session['flash'][0], 'No flash message about new repo'
27
30
28 #test if the fork was created in the database
31 #test if the fork was created in the database
29 new_repo = self.sa.query(Repository).filter(Repository.repo_name == repo_name).one()
32 new_repo = self.sa.query(Repository).filter(Repository.repo_name == repo_name).one()
30
33
31 assert new_repo.repo_name == repo_name, 'wrong name of repo name in db'
34 assert new_repo.repo_name == repo_name, 'wrong name of repo name in db'
32 assert new_repo.description == description, 'wrong description'
35 assert new_repo.description == description, 'wrong description'
33
36
34 #test if repository is visible in the list ?
37 #test if repository is visible in the list ?
35 response = response.follow()
38 response = response.follow()
36
39
37 assert repo_name in response.body, 'missing new repo from the main repos list'
40 assert repo_name in response.body, 'missing new repo from the main repos list'
38
41
42
43 #test if repository was created on filesystem
44 try:
45 vcs.get_repo(os.path.join(TESTS_TMP_PATH, repo_name))
46 except:
47 assert False , 'no repo in filesystem'
48
49
39 def test_create_git(self):
50 def test_create_git(self):
40 return
51 return
41 self.log_user()
52 self.log_user()
42 repo_name = NEW_GIT_REPO
53 repo_name = NEW_GIT_REPO
43 description = 'description for newly created repo'
54 description = 'description for newly created repo'
44 private = False
55 private = False
45 response = self.app.post(url('repos'), {'repo_name':repo_name,
56 response = self.app.post(url('repos'), {'repo_name':repo_name,
46 'repo_type':'git',
57 'repo_type':'git',
47 'description':description,
58 'description':description,
48 'private':private})
59 'private':private})
49
60
50
61
51 #test if we have a message for that repository
62 #test if we have a message for that repository
52 assert '''created repository %s''' % (repo_name) in response.session['flash'][0], 'No flash message about new repo'
63 assert '''created repository %s''' % (repo_name) in response.session['flash'][0], 'No flash message about new repo'
53
64
54 #test if the fork was created in the database
65 #test if the fork was created in the database
55 new_repo = self.sa.query(Repository).filter(Repository.repo_name == repo_name).one()
66 new_repo = self.sa.query(Repository).filter(Repository.repo_name == repo_name).one()
56
67
57 assert new_repo.repo_name == repo_name, 'wrong name of repo name in db'
68 assert new_repo.repo_name == repo_name, 'wrong name of repo name in db'
58 assert new_repo.description == description, 'wrong description'
69 assert new_repo.description == description, 'wrong description'
59
70
60 #test if repository is visible in the list ?
71 #test if repository is visible in the list ?
61 response = response.follow()
72 response = response.follow()
62
73
63 assert repo_name in response.body, 'missing new repo from the main repos list'
74 assert repo_name in response.body, 'missing new repo from the main repos list'
64
75
76 #test if repository was created on filesystem
77 try:
78 vcs.get_repo(os.path.join(TESTS_TMP_PATH, repo_name))
79 except:
80 assert False , 'no repo in filesystem'
65
81
66 def test_new(self):
82 def test_new(self):
67 self.log_user()
83 self.log_user()
68 response = self.app.get(url('new_repo'))
84 response = self.app.get(url('new_repo'))
69
85
70 def test_new_as_xml(self):
86 def test_new_as_xml(self):
71 response = self.app.get(url('formatted_new_repo', format='xml'))
87 response = self.app.get(url('formatted_new_repo', format='xml'))
72
88
73 def test_update(self):
89 def test_update(self):
74 response = self.app.put(url('repo', repo_name=HG_REPO))
90 response = self.app.put(url('repo', repo_name=HG_REPO))
75
91
76 def test_update_browser_fakeout(self):
92 def test_update_browser_fakeout(self):
77 response = self.app.post(url('repo', repo_name=HG_REPO), params=dict(_method='put'))
93 response = self.app.post(url('repo', repo_name=HG_REPO), params=dict(_method='put'))
78
94
79 def test_delete(self):
95 def test_delete(self):
80 self.log_user()
96 self.log_user()
81 repo_name = 'vcs_test_new_to_delete'
97 repo_name = 'vcs_test_new_to_delete'
82 description = 'description for newly created repo'
98 description = 'description for newly created repo'
83 private = False
99 private = False
84 response = self.app.post(url('repos'), {'repo_name':repo_name,
100 response = self.app.post(url('repos'), {'repo_name':repo_name,
85 'repo_type':'hg',
101 'repo_type':'hg',
86 'description':description,
102 'description':description,
87 'private':private})
103 'private':private})
88
104
89
105
90 #test if we have a message for that repository
106 #test if we have a message for that repository
91 assert '''created repository %s''' % (repo_name) in response.session['flash'][0], 'No flash message about new repo'
107 assert '''created repository %s''' % (repo_name) in response.session['flash'][0], 'No flash message about new repo'
92
108
93 #test if the repo was created in the database
109 #test if the repo was created in the database
94 new_repo = self.sa.query(Repository).filter(Repository.repo_name == repo_name).one()
110 new_repo = self.sa.query(Repository).filter(Repository.repo_name == repo_name).one()
95
111
96 assert new_repo.repo_name == repo_name, 'wrong name of repo name in db'
112 assert new_repo.repo_name == repo_name, 'wrong name of repo name in db'
97 assert new_repo.description == description, 'wrong description'
113 assert new_repo.description == description, 'wrong description'
98
114
99 #test if repository is visible in the list ?
115 #test if repository is visible in the list ?
100 response = response.follow()
116 response = response.follow()
101
117
102 assert repo_name in response.body, 'missing new repo from the main repos list'
118 assert repo_name in response.body, 'missing new repo from the main repos list'
103
119
104
120
105 response = self.app.delete(url('repo', repo_name=repo_name))
121 response = self.app.delete(url('repo', repo_name=repo_name))
106
122
107 assert '''deleted repository %s''' % (repo_name) in response.session['flash'][0], 'No flash message about delete repo'
123 assert '''deleted repository %s''' % (repo_name) in response.session['flash'][0], 'No flash message about delete repo'
108
124
109 response.follow()
125 response.follow()
110
126
111 #check if repo was deleted from db
127 #check if repo was deleted from db
112 deleted_repo = self.sa.query(Repository).filter(Repository.repo_name == repo_name).scalar()
128 deleted_repo = self.sa.query(Repository).filter(Repository.repo_name == repo_name).scalar()
113
129
114 assert deleted_repo is None, 'Deleted repository was found in db'
130 assert deleted_repo is None, 'Deleted repository was found in db'
115
131
116
132
117 def test_delete_browser_fakeout(self):
133 def test_delete_browser_fakeout(self):
118 response = self.app.post(url('repo', repo_name=HG_REPO), params=dict(_method='delete'))
134 response = self.app.post(url('repo', repo_name=HG_REPO), params=dict(_method='delete'))
119
135
120 def test_show(self):
136 def test_show(self):
121 self.log_user()
137 self.log_user()
122 response = self.app.get(url('repo', repo_name=HG_REPO))
138 response = self.app.get(url('repo', repo_name=HG_REPO))
123
139
124 def test_show_as_xml(self):
140 def test_show_as_xml(self):
125 response = self.app.get(url('formatted_repo', repo_name=HG_REPO, format='xml'))
141 response = self.app.get(url('formatted_repo', repo_name=HG_REPO, format='xml'))
126
142
127 def test_edit(self):
143 def test_edit(self):
128 response = self.app.get(url('edit_repo', repo_name=HG_REPO))
144 response = self.app.get(url('edit_repo', repo_name=HG_REPO))
129
145
130 def test_edit_as_xml(self):
146 def test_edit_as_xml(self):
131 response = self.app.get(url('formatted_edit_repo', repo_name=HG_REPO, format='xml'))
147 response = self.app.get(url('formatted_edit_repo', repo_name=HG_REPO, format='xml'))
General Comments 0
You need to be logged in to leave comments. Login now