annotate rhodecode/tests/functional/test_changeset_comments.py @ 1818:cf51bbfb120e beta

auto white-space removal
author Marcin Kuzminski <marcin@python-works.com>
date Thu, 29 Dec 2011 07:35:51 +0200
parents 8ecc6b8229a5
children 50aa7cb78cfe
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1715
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
1 from rhodecode.tests import *
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
2 from rhodecode.model.db import ChangesetComment, Notification, User, \
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
3 UserNotification
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
4
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
5 class TestChangeSetCommentrController(TestController):
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
6
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
7 def setUp(self):
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
8 for x in ChangesetComment.query().all():
1749
8ecc6b8229a5 commit less models
Marcin Kuzminski <marcin@python-works.com>
parents: 1723
diff changeset
9 self.Session.delete(x)
8ecc6b8229a5 commit less models
Marcin Kuzminski <marcin@python-works.com>
parents: 1723
diff changeset
10 self.Session.commit()
1715
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
11
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
12 for x in Notification.query().all():
1749
8ecc6b8229a5 commit less models
Marcin Kuzminski <marcin@python-works.com>
parents: 1723
diff changeset
13 self.Session.delete(x)
8ecc6b8229a5 commit less models
Marcin Kuzminski <marcin@python-works.com>
parents: 1723
diff changeset
14 self.Session.commit()
1715
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
15
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
16 def tearDown(self):
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
17 for x in ChangesetComment.query().all():
1749
8ecc6b8229a5 commit less models
Marcin Kuzminski <marcin@python-works.com>
parents: 1723
diff changeset
18 self.Session.delete(x)
8ecc6b8229a5 commit less models
Marcin Kuzminski <marcin@python-works.com>
parents: 1723
diff changeset
19 self.Session.commit()
1715
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
20
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
21 for x in Notification.query().all():
1749
8ecc6b8229a5 commit less models
Marcin Kuzminski <marcin@python-works.com>
parents: 1723
diff changeset
22 self.Session.delete(x)
8ecc6b8229a5 commit less models
Marcin Kuzminski <marcin@python-works.com>
parents: 1723
diff changeset
23 self.Session.commit()
1715
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
24
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
25 def test_create(self):
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
26 self.log_user()
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
27 rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc'
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
28 text = u'CommentOnRevision'
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
29
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
30 params = {'text':text}
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
31 response = self.app.post(url(controller='changeset', action='comment',
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
32 repo_name=HG_REPO, revision=rev),
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
33 params=params)
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
34 # Test response...
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
35 self.assertEqual(response.status, '302 Found')
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
36 response.follow()
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
37
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
38 response = self.app.get(url(controller='changeset', action='index',
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
39 repo_name=HG_REPO, revision=rev))
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
40 # test DB
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
41 self.assertEqual(ChangesetComment.query().count(), 1)
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
42 self.assertTrue('''<div class="comments-number">%s '''
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
43 '''comment(s) (0 inline)</div>''' % 1 in response.body)
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
44
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
45
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
46 self.assertEqual(Notification.query().count(), 1)
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
47 notification = Notification.query().all()[0]
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
48
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
49 self.assertEqual(notification.type_, Notification.TYPE_CHANGESET_COMMENT)
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
50 self.assertTrue((u'/vcs_test_hg/changeset/27cd5cce30c96924232df'
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
51 'fcd24178a07ffeb5dfc#comment-1') in notification.subject)
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
52
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
53 def test_create_inline(self):
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
54 self.log_user()
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
55 rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc'
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
56 text = u'CommentOnRevision'
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
57 f_path = 'vcs/web/simplevcs/views/repository.py'
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
58 line = 'n1'
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
59
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
60 params = {'text':text, 'f_path':f_path, 'line':line}
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
61 response = self.app.post(url(controller='changeset', action='comment',
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
62 repo_name=HG_REPO, revision=rev),
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
63 params=params)
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
64 # Test response...
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
65 self.assertEqual(response.status, '302 Found')
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
66 response.follow()
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
67
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
68 response = self.app.get(url(controller='changeset', action='index',
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
69 repo_name=HG_REPO, revision=rev))
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
70 #test DB
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
71 self.assertEqual(ChangesetComment.query().count(), 1)
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
72 self.assertTrue('''<div class="comments-number">0 comment(s)'''
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
73 ''' (%s inline)</div>''' % 1 in response.body)
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
74 self.assertTrue('''<div class="inline-comment-placeholder-line"'''
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
75 ''' line="n1" target_id="vcswebsimplevcsviews'''
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
76 '''repositorypy">''' in response.body)
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
77
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
78 self.assertEqual(Notification.query().count(), 1)
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
79 notification = Notification.query().all()[0]
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
80
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
81 self.assertEqual(notification.type_, Notification.TYPE_CHANGESET_COMMENT)
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
82 self.assertTrue((u'/vcs_test_hg/changeset/27cd5cce30c96924232df'
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
83 'fcd24178a07ffeb5dfc#comment-1') in notification.subject)
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
84
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
85 def test_create_with_mention(self):
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
86 self.log_user()
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
87
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
88 rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc'
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
89 text = u'@test_regular check CommentOnRevision'
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
90
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
91 params = {'text':text}
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
92 response = self.app.post(url(controller='changeset', action='comment',
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
93 repo_name=HG_REPO, revision=rev),
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
94 params=params)
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
95 # Test response...
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
96 self.assertEqual(response.status, '302 Found')
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
97 response.follow()
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
98
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
99 response = self.app.get(url(controller='changeset', action='index',
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
100 repo_name=HG_REPO, revision=rev))
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
101 # test DB
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
102 self.assertEqual(ChangesetComment.query().count(), 1)
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
103 self.assertTrue('''<div class="comments-number">%s '''
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
104 '''comment(s) (0 inline)</div>''' % 1 in response.body)
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
105
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
106
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
107 self.assertEqual(Notification.query().count(), 2)
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
108 users = [x.user.username for x in UserNotification.query().all()]
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
109
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
110 # test_regular get's notification by @mention
1723
64e91067b996 - refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents: 1715
diff changeset
111 self.assertEqual(sorted(users), [u'test_admin', u'test_regular'])
1715
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
112
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
113 def test_delete(self):
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
114 self.log_user()
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
115 rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc'
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
116 text = u'CommentOnRevision'
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
117
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
118 params = {'text':text}
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
119 response = self.app.post(url(controller='changeset', action='comment',
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
120 repo_name=HG_REPO, revision=rev),
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
121 params=params)
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
122
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
123 comments = ChangesetComment.query().all()
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
124 self.assertEqual(len(comments), 1)
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
125 comment_id = comments[0].comment_id
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
126
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
127
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
128 self.app.delete(url(controller='changeset',
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
129 action='delete_comment',
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
130 repo_name=HG_REPO,
1723
64e91067b996 - refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents: 1715
diff changeset
131 comment_id=comment_id))
1715
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
132
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
133 comments = ChangesetComment.query().all()
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
134 self.assertEqual(len(comments), 0)
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
135
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
136 response = self.app.get(url(controller='changeset', action='index',
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
137 repo_name=HG_REPO, revision=rev))
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
138 self.assertTrue('''<div class="comments-number">0 comment(s)'''
e1e482093077 tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
139 ''' (0 inline)</div>''' in response.body)