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