[69d856]: ForgeTracker / forgetracker / tests / functional / test_root.py  Maximize  Restore  History

Download this file

162 lines (144 with data), 6.3 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
from nose.tools import assert_true, assert_false
from forgetracker.tests import TestController
from pyforge import model
from forgewiki import model as wm
from forgetracker import model as tm
# These are needed for faking reactor actions
import mock
from pyforge.lib import helpers as h
from pyforge.command import reactor
from pyforge.ext.search import search_main
from ming.orm.ormsession import ThreadLocalORMSession
class TestFunctionalController(TestController):
def new_ticket(self, summary, mp='/bugs/'):
response = self.app.get(mp + 'new/')
form = response.form
form['summary'] = summary
return form.submit().follow()
def test_new_ticket(self):
summary = 'test new ticket'
ticket_view = self.new_ticket(summary)
assert_true(summary in ticket_view)
def test_two_trackers(self):
summary = 'test two trackers'
ticket_view = self.new_ticket(summary, '/doc_bugs/')
assert_true(summary in ticket_view)
index_view = self.app.get('/bugs/')
assert_false(summary in index_view)
def test_new_comment(self):
self.new_ticket('test new comment')
comment = 'comment testing new comment'
self.app.post('/bugs/1/comments/reply', { 'text': comment })
ticket_view = self.app.get('/bugs/1/')
assert_true(comment in ticket_view)
def test_render_ticket(self):
summary = 'test render ticket'
ticket_view = self.new_ticket(summary)
ticket_view.mustcontain(summary, 'Comments', 'Make a comment')
def test_render_index(self):
summary = 'test render index'
self.new_ticket(summary)
index_view = self.app.get('/bugs/')
assert_true(summary in index_view)
def test_ticket_tag_untag(self):
summary = 'test tagging and untagging a ticket'
self.new_ticket(summary)
self.app.post('/bugs/1/update_ticket',{
'summary':'aaa',
'description':'bbb',
'status':'ccc',
'assigned_to':'',
'tags':'red,blue',
'tags_old':'red,blue'
})
response = self.app.get('/bugs/1/')
assert_true('aaa' in response)
self.app.post('/bugs/1/update_ticket',{
'summary':'zzz',
'description':'bbb',
'status':'ccc',
'assigned_to':'',
'tags':'red',
'tags_old':'red'
})
response = self.app.get('/bugs/1/')
assert_true('zzz' in response)
def test_new_attachment(self):
file_name = 'test_root.py'
file_data = file(__file__).read()
upload = ('file_info', file_name, file_data)
self.new_ticket('test new attachment')
ticket_editor = self.app.post('/bugs/1/attach', upload_files=[upload]).follow()
assert_true(file_name in ticket_editor)
def test_new_attachment_content(self):
file_name = 'test_root.py'
file_data = file(__file__).read()
upload = ('file_info', file_name, file_data)
self.new_ticket('test new attachment')
ticket_editor = self.app.post('/bugs/1/attach', upload_files=[upload]).follow()
download = ticket_editor.click(description=file_name)
assert_true(download.body == file_data)
def test_sidebar_static_page(self):
response = self.app.get('/bugs/search/')
assert 'Create New Ticket' in response
assert 'Update this Ticket' not in response
assert 'Related Artifacts' not in response
def test_sidebar_ticket_page(self):
summary = 'test sidebar logic for a ticket page'
self.new_ticket(summary)
response = self.app.get('/projects/test/bugs/1/')
assert 'Create New Ticket' in response
assert 'Update this Ticket' in response
assert 'Related Artifacts' not in response
self.app.get('/Wiki/aaa/')
self.new_ticket('bbb')
# Fake out updating the pages since reactor doesn't work with tests
app = search_main.SearchApp
cmd = reactor.ReactorCommand('reactor')
cmd.args = [ 'test.ini' ]
cmd.options = mock.Mock()
cmd.options.dry_run = True
cmd.options.proc = 1
configs = cmd.command()
add_artifacts = cmd.route_audit('search', app.add_artifacts)
del_artifacts = cmd.route_audit('search', app.del_artifacts)
msg = mock.Mock()
msg.ack = lambda:None
msg.delivery_info = dict(routing_key='search.add_artifacts')
h.set_context('test', 'wiki')
a = wm.Page.query.find(dict(title='aaa')).first()
a.text = '\n[bugs:#1]\n'
msg.data = dict(project_id=a.project_id,
mount_point=a.app_config.options.mount_point,
artifacts=[a.dump_ref()])
add_artifacts(msg.data, msg)
b = tm.Ticket.query.find(dict(ticket_num=2)).first()
b.description = '\n[#1]\n'
msg.data = dict(project_id=b.project_id,
mount_point=b.app_config.options.mount_point,
artifacts=[b.dump_ref()])
add_artifacts(msg.data, msg)
ThreadLocalORMSession.flush_all()
ThreadLocalORMSession.close_all()
response = self.app.get('/projects/test/bugs/1/')
assert 'Related Artifacts' in response
assert 'aaa' in response
assert '#2' in response
def test_assign_ticket(self):
summary = 'test assign ticket'
self.new_ticket(summary)
response = self.app.get('/projects/test/bugs/1/edit/')
assert response.html.find('span', {'class': 'viewer ticket-assigned-to'}).string == 'nobody'
test_user = response.html.find(id="assigned_to").findAll('option')[1]
test_user_id = test_user['value']
test_user_name = test_user.string
self.app.post('/bugs/1/update_ticket',{
'summary':'zzz',
'description':'bbb',
'status':'ccc',
'assigned_to':test_user_id,
'tags':'',
'tags_old':''
})
response = self.app.get('/projects/test/bugs/1/edit/')
assert response.html.find('span', {'class': 'viewer ticket-assigned-to'}).string == test_user_name

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

Sign up for the SourceForge newsletter:





No, thanks