Mercurial > kallithea
annotate rhodecode/tests/functional/test_changeset_comments.py @ 3089:4cc9bb83ecb4 beta
Fixed some issues with edit form
- unified code (but still a lot of duplicated code left over)
- fixed forms
- fixed validators
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Thu, 13 Dec 2012 03:34:19 +0100 |
parents | c4d8ed624728 |
children | d7488551578e |
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 |
2149 | 5 |
6 class TestChangeSetCommentsController(TestController): | |
1715
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
7 |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
8 def setUp(self): |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
9 for x in ChangesetComment.query().all(): |
1749
8ecc6b8229a5
commit less models
Marcin Kuzminski <marcin@python-works.com>
parents:
1723
diff
changeset
|
10 self.Session.delete(x) |
8ecc6b8229a5
commit less models
Marcin Kuzminski <marcin@python-works.com>
parents:
1723
diff
changeset
|
11 self.Session.commit() |
1715
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
12 |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
13 for x in Notification.query().all(): |
1749
8ecc6b8229a5
commit less models
Marcin Kuzminski <marcin@python-works.com>
parents:
1723
diff
changeset
|
14 self.Session.delete(x) |
8ecc6b8229a5
commit less models
Marcin Kuzminski <marcin@python-works.com>
parents:
1723
diff
changeset
|
15 self.Session.commit() |
1715
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
16 |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
17 def tearDown(self): |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
18 for x in ChangesetComment.query().all(): |
1749
8ecc6b8229a5
commit less models
Marcin Kuzminski <marcin@python-works.com>
parents:
1723
diff
changeset
|
19 self.Session.delete(x) |
8ecc6b8229a5
commit less models
Marcin Kuzminski <marcin@python-works.com>
parents:
1723
diff
changeset
|
20 self.Session.commit() |
1715
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
21 |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
22 for x in Notification.query().all(): |
1749
8ecc6b8229a5
commit less models
Marcin Kuzminski <marcin@python-works.com>
parents:
1723
diff
changeset
|
23 self.Session.delete(x) |
8ecc6b8229a5
commit less models
Marcin Kuzminski <marcin@python-works.com>
parents:
1723
diff
changeset
|
24 self.Session.commit() |
1715
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
25 |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
26 def test_create(self): |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
27 self.log_user() |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
28 rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc' |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
29 text = u'CommentOnRevision' |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
30 |
2149 | 31 params = {'text': text} |
1715
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
32 response = self.app.post(url(controller='changeset', action='comment', |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
33 repo_name=HG_REPO, revision=rev), |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
34 params=params) |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
35 # Test response... |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
36 self.assertEqual(response.status, '302 Found') |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
37 response.follow() |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
38 |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
39 response = self.app.get(url(controller='changeset', action='index', |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
40 repo_name=HG_REPO, revision=rev)) |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
41 # test DB |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
42 self.assertEqual(ChangesetComment.query().count(), 1) |
2317
c4d8ed624728
Fixed tests for new i18n changes
Marcin Kuzminski <marcin@python-works.com>
parents:
2194
diff
changeset
|
43 response.mustcontain('''<div class="comments-number">%s comment ''' |
c4d8ed624728
Fixed tests for new i18n changes
Marcin Kuzminski <marcin@python-works.com>
parents:
2194
diff
changeset
|
44 '''(0 inline)</div>''' % 1) |
1715
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
45 |
2149 | 46 self.assertEqual(Notification.query().count(), 1) |
47 self.assertEqual(ChangesetComment.query().count(), 1) | |
1715
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 notification = Notification.query().all()[0] |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
50 |
2149 | 51 ID = ChangesetComment.query().first().comment_id |
2150
a8c9c0094ddf
White space cleanup
Marcin Kuzminski <marcin@python-works.com>
parents:
2149
diff
changeset
|
52 self.assertEqual(notification.type_, |
2149 | 53 Notification.TYPE_CHANGESET_COMMENT) |
54 sbj = (u'/vcs_test_hg/changeset/' | |
55 '27cd5cce30c96924232dffcd24178a07ffeb5dfc#comment-%s' % ID) | |
56 print "%s vs %s" % (sbj, notification.subject) | |
57 self.assertTrue(sbj in notification.subject) | |
1715
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
58 |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
59 def test_create_inline(self): |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
60 self.log_user() |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
61 rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc' |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
62 text = u'CommentOnRevision' |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
63 f_path = 'vcs/web/simplevcs/views/repository.py' |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
64 line = 'n1' |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
65 |
2149 | 66 params = {'text': text, 'f_path': f_path, 'line': line} |
1715
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
67 response = self.app.post(url(controller='changeset', action='comment', |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
68 repo_name=HG_REPO, revision=rev), |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
69 params=params) |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
70 # Test response... |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
71 self.assertEqual(response.status, '302 Found') |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
72 response.follow() |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
73 |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
74 response = self.app.get(url(controller='changeset', action='index', |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
75 repo_name=HG_REPO, revision=rev)) |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
76 #test DB |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
77 self.assertEqual(ChangesetComment.query().count(), 1) |
2194 | 78 response.mustcontain( |
2317
c4d8ed624728
Fixed tests for new i18n changes
Marcin Kuzminski <marcin@python-works.com>
parents:
2194
diff
changeset
|
79 '''<div class="comments-number">0 comments''' |
2194 | 80 ''' (%s inline)</div>''' % 1 |
81 ) | |
82 response.mustcontain( | |
83 '''<div style="display:none" class="inline-comment-placeholder" ''' | |
84 '''path="vcs/web/simplevcs/views/repository.py" ''' | |
85 '''target_id="vcswebsimplevcsviewsrepositorypy">''' | |
86 ) | |
1715
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 self.assertEqual(Notification.query().count(), 1) |
2149 | 89 self.assertEqual(ChangesetComment.query().count(), 1) |
1715
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
90 |
2149 | 91 notification = Notification.query().all()[0] |
92 ID = ChangesetComment.query().first().comment_id | |
2150
a8c9c0094ddf
White space cleanup
Marcin Kuzminski <marcin@python-works.com>
parents:
2149
diff
changeset
|
93 self.assertEqual(notification.type_, |
2149 | 94 Notification.TYPE_CHANGESET_COMMENT) |
95 sbj = (u'/vcs_test_hg/changeset/' | |
96 '27cd5cce30c96924232dffcd24178a07ffeb5dfc#comment-%s' % ID) | |
97 print "%s vs %s" % (sbj, notification.subject) | |
98 self.assertTrue(sbj in notification.subject) | |
1715
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
99 |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
100 def test_create_with_mention(self): |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
101 self.log_user() |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
102 |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
103 rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc' |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
104 text = u'@test_regular check CommentOnRevision' |
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 params = {'text':text} |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
107 response = self.app.post(url(controller='changeset', action='comment', |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
108 repo_name=HG_REPO, revision=rev), |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
109 params=params) |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
110 # Test response... |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
111 self.assertEqual(response.status, '302 Found') |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
112 response.follow() |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
113 |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
114 response = self.app.get(url(controller='changeset', action='index', |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
115 repo_name=HG_REPO, revision=rev)) |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
116 # test DB |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
117 self.assertEqual(ChangesetComment.query().count(), 1) |
2317
c4d8ed624728
Fixed tests for new i18n changes
Marcin Kuzminski <marcin@python-works.com>
parents:
2194
diff
changeset
|
118 response.mustcontain('''<div class="comments-number">%s ''' |
c4d8ed624728
Fixed tests for new i18n changes
Marcin Kuzminski <marcin@python-works.com>
parents:
2194
diff
changeset
|
119 '''comment (0 inline)</div>''' % 1) |
1715
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
120 |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
121 self.assertEqual(Notification.query().count(), 2) |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
122 users = [x.user.username for x in UserNotification.query().all()] |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
123 |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
124 # 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
|
125 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
|
126 |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
127 def test_delete(self): |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
128 self.log_user() |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
129 rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc' |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
130 text = u'CommentOnRevision' |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
131 |
2149 | 132 params = {'text': text} |
1715
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
133 response = self.app.post(url(controller='changeset', action='comment', |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
134 repo_name=HG_REPO, revision=rev), |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
135 params=params) |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
136 |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
137 comments = ChangesetComment.query().all() |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
138 self.assertEqual(len(comments), 1) |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
139 comment_id = comments[0].comment_id |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
140 |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
141 self.app.delete(url(controller='changeset', |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
142 action='delete_comment', |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
143 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
|
144 comment_id=comment_id)) |
1715
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
145 |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
146 comments = ChangesetComment.query().all() |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
147 self.assertEqual(len(comments), 0) |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
148 |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
149 response = self.app.get(url(controller='changeset', action='index', |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
150 repo_name=HG_REPO, revision=rev)) |
2317
c4d8ed624728
Fixed tests for new i18n changes
Marcin Kuzminski <marcin@python-works.com>
parents:
2194
diff
changeset
|
151 response.mustcontain('''<div class="comments-number">0 comments''' |
c4d8ed624728
Fixed tests for new i18n changes
Marcin Kuzminski <marcin@python-works.com>
parents:
2194
diff
changeset
|
152 ''' (0 inline)</div>''') |