Parent: [328198] (diff)

Child: [50cc98] (diff)

Download this file

test_site_admin.py    63 lines (52 with data), 2.6 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
import os, allura
from allura.tests import TestController
class TestSiteAdmin(TestController):
def test_access(self):
r = self.app.get('/nf/admin/', extra_environ=dict(
username='test-user'), status=403)
r = self.app.get('/nf/admin/', extra_environ=dict(
username='*anonymous'), status=302)
r = r.follow()
assert 'Login' in r
def test_home(self):
r = self.app.get('/nf/admin/', extra_environ=dict(
username='root'))
assert 'Forge Site Admin' in r.html.find('h2',{'class':'dark title'}).contents[0]
stats_table = r.html.find('table')
cells = stats_table.findAll('td')
assert cells[0].contents[0] == 'Adobe', cells[0].contents[0]
def test_performance(self):
r = self.app.get('/nf/admin/stats', extra_environ=dict(
username='test-user'), status=403)
r = self.app.get('/nf/admin/stats', extra_environ=dict(
username='root'))
assert 'Forge Site Admin' in r.html.find('h2',{'class':'dark title'}).contents[0]
stats_table = r.html.find('table')
headers = stats_table.findAll('th')
assert headers[0].contents[0] == 'Url'
assert headers[1].contents[0] == 'Ming'
assert headers[2].contents[0] == 'Mongo'
assert headers[3].contents[0] == 'Render'
assert headers[4].contents[0] == 'Template'
assert headers[5].contents[0] == 'Total Time'
def test_tickets_access(self):
r = self.app.get('/nf/admin/api_tickets', extra_environ=dict(
username='test-user'), status=403)
def test_new_projects_access(self):
self.app.get('/nf/admin/new_projects', extra_environ=dict(
username='test_user'), status=403)
r = self.app.get('/nf/admin/new_projects', extra_environ=dict(
username='*anonymous'), status=302).follow()
assert 'Login' in r
def test_new_projects(self):
r = self.app.get('/nf/admin/new_projects', extra_environ=dict(
username='root'))
headers = r.html.find('table').findAll('th')
assert headers[1].contents[0] == 'Created'
assert headers[2].contents[0] == 'Shortname'
assert headers[3].contents[0] == 'Name'
assert headers[4].contents[0] == 'Short description'
assert headers[5].contents[0] == 'Summary'
assert headers[6].contents[0] == 'Deleted?'
assert headers[7].contents[0] == 'Homepage'
assert headers[8].contents[0] == 'Admins'