[d23a6c]: Allura / allura / tests / functional / test_neighborhood.py  Maximize  Restore  History

Download this file

181 lines (163 with data), 9.4 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
from pylons import g, c
import os
import allura
from ming.orm.ormsession import ThreadLocalORMSession
import Image, StringIO
from allura.tests import TestController
class TestNeighborhood(TestController):
def test_home_project(self):
r = self.app.get('/adobe/home/')
assert r.location.endswith('/adobe/home/Home/')
r = r.follow()
assert 'Welcome' in str(r), str(r)
r = self.app.get('/adobe/admin/')
assert 'admin' in str(r), str(r)
def test_redirect(self):
r = self.app.post('/adobe/_admin/update',
params=dict(redirect='home/Home/'),
extra_environ=dict(username='root'))
r = self.app.get('/adobe/')
assert r.location.endswith('/adobe/home/Home/')
def test_admin(self):
r = self.app.get('/adobe/_admin/', extra_environ=dict(username='root'))
r = self.app.get('/adobe/_admin/overview', extra_environ=dict(username='root'))
r = self.app.get('/adobe/_admin/permissions', extra_environ=dict(username='root'))
r = self.app.get('/adobe/_admin/accolades', extra_environ=dict(username='root'))
r = self.app.post('/adobe/_admin/update_acl',
params={'permission':'moderate',
'new.add':'on',
'new.username':'test-user'},
extra_environ=dict(username='root'))
r = self.app.post('/adobe/_admin/update_acl',
params={'permission':'read',
'new.username':'',
'user-0.id':'',
'user-0.delete':'on'},
extra_environ=dict(username='root'))
r = self.app.post('/adobe/_admin/update',
params=dict(name='Mozq1', css='', homepage='# MozQ1!'),
extra_environ=dict(username='root'))
r = self.app.post('/adobe/_admin/update',
params=dict(name='Mozq1', css='', homepage='# MozQ1!\n[Root]'),
extra_environ=dict(username='root'))
def test_icon(self):
file_name = 'neo-icon-set-454545-256x350.png'
file_path = os.path.join(allura.__path__[0],'public','nf','allura','images',file_name)
file_data = file(file_path).read()
upload = ('icon', file_name, file_data)
r = self.app.get('/adobe/_admin/', extra_environ=dict(username='root'))
r = self.app.post('/adobe/_admin/update',
params=dict(name='Mozq1', css='', homepage='# MozQ1'),
extra_environ=dict(username='root'), upload_files=[upload])
r = self.app.get('/adobe/icon')
image = Image.open(StringIO.StringIO(r.body))
assert image.size == (48,48)
def test_invite(self):
r = self.app.get('/adobe/_moderate/', extra_environ=dict(username='root'))
r = self.app.post('/adobe/_moderate/invite',
params=dict(pid='adobe-1', invite='on'),
extra_environ=dict(username='root'))
r = self.app.get(r.location, extra_environ=dict(username='root'))
assert 'error' in r
r = self.app.post('/adobe/_moderate/invite',
params=dict(pid='no_such_user', invite='on'),
extra_environ=dict(username='root'))
r = self.app.get(r.location, extra_environ=dict(username='root'))
assert 'error' in r
r = self.app.post('/adobe/_moderate/invite',
params=dict(pid='test', invite='on'),
extra_environ=dict(username='root'))
r = self.app.get(r.location, extra_environ=dict(username='root'))
assert 'invited' in r
assert 'warning' not in r
r = self.app.post('/adobe/_moderate/invite',
params=dict(pid='test', invite='on'),
extra_environ=dict(username='root'))
r = self.app.get(r.location, extra_environ=dict(username='root'))
assert 'warning' in r
r = self.app.post('/adobe/_moderate/invite',
params=dict(pid='test', uninvite='on'),
extra_environ=dict(username='root'))
r = self.app.get(r.location, extra_environ=dict(username='root'))
assert 'uninvited' in r
assert 'warning' not in r
r = self.app.post('/adobe/_moderate/invite',
params=dict(pid='test', uninvite='on'),
extra_environ=dict(username='root'))
r = self.app.get(r.location, extra_environ=dict(username='root'))
assert 'warning' in r
r = self.app.post('/adobe/_moderate/invite',
params=dict(pid='test', invite='on'),
extra_environ=dict(username='root'))
r = self.app.get(r.location, extra_environ=dict(username='root'))
assert 'invited' in r
assert 'warning' not in r
def test_evict(self):
r = self.app.get('/adobe/_moderate/', extra_environ=dict(username='root'))
r = self.app.post('/adobe/_moderate/evict',
params=dict(pid='test'),
extra_environ=dict(username='root'))
r = self.app.get(r.location, extra_environ=dict(username='root'))
assert 'error' in r
r = self.app.post('/adobe/_moderate/evict',
params=dict(pid='adobe-1'),
extra_environ=dict(username='root'))
r = self.app.get(r.location, extra_environ=dict(username='root'))
assert 'adobe-1 evicted to Projects' in r
def test_home(self):
r = self.app.get('/adobe/')
def test_register(self):
r = self.app.get('/adobe/register', status=405)
r = self.app.post('/adobe/register',
params=dict(project_unixname='', project_name='', project_description='', neighborhood='Adobe'),
extra_environ=dict(username='root'))
assert r.html.find('div',{'class':'error'}).string == 'Please enter a value'
r = self.app.post('/adobe/register',
params=dict(project_unixname='mymoz', project_name='', project_description='', neighborhood='Adobe'),
extra_environ=dict(username='*anonymous'),
status=302)
r = self.app.post('/adobe/register',
params=dict(project_unixname='foo.mymoz', project_name='', project_description='', neighborhood='Adobe'),
extra_environ=dict(username='root'))
assert r.html.find('div',{'class':'error'}).string == 'Invalid project shortname'
r = self.app.post('/p/register',
params=dict(project_unixname='test', project_name='', project_description='', neighborhood='Adobe'),
extra_environ=dict(username='root'))
assert r.html.find('div',{'class':'error'}).string == 'A project already exists with that name, please choose another.'
r = self.app.post('/adobe/register',
params=dict(project_unixname='mymoz', project_name='', project_description='', neighborhood='Adobe'),
extra_environ=dict(username='root'))
def test_neighborhood_project(self):
r = self.app.get('/adobe/test/home/', status=302)
r = self.app.get('/adobe/adobe-1/home/', status=200)
r = self.app.get('/p/test/sub1/home/')
r = self.app.get('/p/test/sub1/', status=302)
r = self.app.get('/p/test/no-such-app/', status=404)
def test_neighborhood_awards(self):
file_name = 'adobe_icon.png'
file_path = os.path.join(allura.__path__[0],'public','nf','images',file_name)
file_data = file(file_path).read()
upload = ('icon', file_name, file_data)
r = self.app.get('/adobe/_admin/awards', extra_environ=dict(username='root'))
r = self.app.post('/adobe/_admin/awards/create',
params=dict(short='FOO', full='A basic foo award'),
extra_environ=dict(username='root'), upload_files=[upload])
r = self.app.get('/adobe/_admin/awards/FOO', extra_environ=dict(username='root'))
r = self.app.get('/adobe/_admin/awards/FOO/icon', extra_environ=dict(username='root'))
image = Image.open(StringIO.StringIO(r.body))
assert image.size == (48,48)
r = self.app.post('/adobe/_admin/awards/grant',
params=dict(grant='FOO', recipient='adobe-1'),
extra_environ=dict(username='root'))
r = self.app.get('/adobe/_admin/awards/FOO/adobe-1', extra_environ=dict(username='root'))
r = self.app.post('/adobe/_admin/awards/FOO/adobe-1/revoke',
extra_environ=dict(username='root'))
r = self.app.post('/adobe/_admin/awards/FOO/delete',
extra_environ=dict(username='root'))
def test_add_a_project_link(self):
r = self.app.get('/p/')
assert 'Add a Project' in r
r = self.app.get('/u/')
assert 'Add a Project' not in r
r = self.app.get('/adobe/')
assert 'Add a Project' not in r

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks