Mercurial > kallithea
annotate rhodecode/tests/functional/test_changeset_comments.py @ 3797:d7488551578e beta
synced vcs with upstream
- moved subprocessio module to VCS
- many small changes to make embedded vcs as similar to to external lib
- use only absolute imports
- patch vcs config during load pylons env
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Sat, 27 Apr 2013 11:24:25 +0200 |
parents | c4d8ed624728 |
children | a5888ca796b5 |
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 |
3797
d7488551578e
synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents:
2317
diff
changeset
|
4 from rhodecode.model.meta import Session |
1715
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
5 |
2149 | 6 |
7 class TestChangeSetCommentsController(TestController): | |
1715
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
8 |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
9 def setUp(self): |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
10 for x in ChangesetComment.query().all(): |
3797
d7488551578e
synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents:
2317
diff
changeset
|
11 Session().delete(x) |
d7488551578e
synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents:
2317
diff
changeset
|
12 Session().commit() |
1715
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
13 |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
14 for x in Notification.query().all(): |
3797
d7488551578e
synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents:
2317
diff
changeset
|
15 Session().delete(x) |
d7488551578e
synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents:
2317
diff
changeset
|
16 Session().commit() |
1715
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
17 |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
18 def tearDown(self): |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
19 for x in ChangesetComment.query().all(): |
3797
d7488551578e
synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents:
2317
diff
changeset
|
20 Session().delete(x) |
d7488551578e
synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents:
2317
diff
changeset
|
21 Session().commit() |
1715
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
22 |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
23 for x in Notification.query().all(): |
3797
d7488551578e
synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents:
2317
diff
changeset
|
24 Session().delete(x) |
d7488551578e
synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents:
2317
diff
changeset
|
25 Session().commit() |
1715
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
26 |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
27 def test_create(self): |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
28 self.log_user() |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
29 rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc' |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
30 text = u'CommentOnRevision' |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
31 |
2149 | 32 params = {'text': text} |
1715
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
33 response = self.app.post(url(controller='changeset', action='comment', |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
34 repo_name=HG_REPO, revision=rev), |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
35 params=params) |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
36 # Test response... |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
37 self.assertEqual(response.status, '302 Found') |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
38 response.follow() |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
39 |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
40 response = self.app.get(url(controller='changeset', action='index', |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
41 repo_name=HG_REPO, revision=rev)) |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
42 # test DB |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
43 self.assertEqual(ChangesetComment.query().count(), 1) |
2317
c4d8ed624728
Fixed tests for new i18n changes
Marcin Kuzminski <marcin@python-works.com>
parents:
2194
diff
changeset
|
44 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
|
45 '''(0 inline)</div>''' % 1) |
1715
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
46 |
2149 | 47 self.assertEqual(Notification.query().count(), 1) |
48 self.assertEqual(ChangesetComment.query().count(), 1) | |
1715
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
49 |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
50 notification = Notification.query().all()[0] |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
51 |
2149 | 52 ID = ChangesetComment.query().first().comment_id |
2150
a8c9c0094ddf
White space cleanup
Marcin Kuzminski <marcin@python-works.com>
parents:
2149
diff
changeset
|
53 self.assertEqual(notification.type_, |
2149 | 54 Notification.TYPE_CHANGESET_COMMENT) |
55 sbj = (u'/vcs_test_hg/changeset/' | |
56 '27cd5cce30c96924232dffcd24178a07ffeb5dfc#comment-%s' % ID) | |
57 print "%s vs %s" % (sbj, notification.subject) | |
58 self.assertTrue(sbj in notification.subject) | |
1715
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 def test_create_inline(self): |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
61 self.log_user() |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
62 rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc' |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
63 text = u'CommentOnRevision' |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
64 f_path = 'vcs/web/simplevcs/views/repository.py' |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
65 line = 'n1' |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
66 |
2149 | 67 params = {'text': text, 'f_path': f_path, 'line': line} |
1715
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
68 response = self.app.post(url(controller='changeset', action='comment', |
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 params=params) |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
71 # Test response... |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
72 self.assertEqual(response.status, '302 Found') |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
73 response.follow() |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
74 |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
75 response = self.app.get(url(controller='changeset', action='index', |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
76 repo_name=HG_REPO, revision=rev)) |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
77 #test DB |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
78 self.assertEqual(ChangesetComment.query().count(), 1) |
2194 | 79 response.mustcontain( |
2317
c4d8ed624728
Fixed tests for new i18n changes
Marcin Kuzminski <marcin@python-works.com>
parents:
2194
diff
changeset
|
80 '''<div class="comments-number">0 comments''' |
2194 | 81 ''' (%s inline)</div>''' % 1 |
82 ) | |
83 response.mustcontain( | |
84 '''<div style="display:none" class="inline-comment-placeholder" ''' | |
85 '''path="vcs/web/simplevcs/views/repository.py" ''' | |
86 '''target_id="vcswebsimplevcsviewsrepositorypy">''' | |
87 ) | |
1715
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
88 |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
89 self.assertEqual(Notification.query().count(), 1) |
2149 | 90 self.assertEqual(ChangesetComment.query().count(), 1) |
1715
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
91 |
2149 | 92 notification = Notification.query().all()[0] |
93 ID = ChangesetComment.query().first().comment_id | |
2150
a8c9c0094ddf
White space cleanup
Marcin Kuzminski <marcin@python-works.com>
parents:
2149
diff
changeset
|
94 self.assertEqual(notification.type_, |
2149 | 95 Notification.TYPE_CHANGESET_COMMENT) |
96 sbj = (u'/vcs_test_hg/changeset/' | |
97 '27cd5cce30c96924232dffcd24178a07ffeb5dfc#comment-%s' % ID) | |
98 print "%s vs %s" % (sbj, notification.subject) | |
99 self.assertTrue(sbj in notification.subject) | |
1715
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
100 |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
101 def test_create_with_mention(self): |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
102 self.log_user() |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
103 |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
104 rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc' |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
105 text = u'@test_regular check CommentOnRevision' |
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 params = {'text':text} |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
108 response = self.app.post(url(controller='changeset', action='comment', |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
109 repo_name=HG_REPO, revision=rev), |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
110 params=params) |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
111 # Test response... |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
112 self.assertEqual(response.status, '302 Found') |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
113 response.follow() |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
114 |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
115 response = self.app.get(url(controller='changeset', action='index', |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
116 repo_name=HG_REPO, revision=rev)) |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
117 # test DB |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
118 self.assertEqual(ChangesetComment.query().count(), 1) |
2317
c4d8ed624728
Fixed tests for new i18n changes
Marcin Kuzminski <marcin@python-works.com>
parents:
2194
diff
changeset
|
119 response.mustcontain('''<div class="comments-number">%s ''' |
c4d8ed624728
Fixed tests for new i18n changes
Marcin Kuzminski <marcin@python-works.com>
parents:
2194
diff
changeset
|
120 '''comment (0 inline)</div>''' % 1) |
1715
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
121 |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
122 self.assertEqual(Notification.query().count(), 2) |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
123 users = [x.user.username for x in UserNotification.query().all()] |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
124 |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
125 # 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
|
126 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
|
127 |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
128 def test_delete(self): |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
129 self.log_user() |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
130 rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc' |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
131 text = u'CommentOnRevision' |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
132 |
2149 | 133 params = {'text': text} |
1715
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
134 response = self.app.post(url(controller='changeset', action='comment', |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
135 repo_name=HG_REPO, revision=rev), |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
136 params=params) |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
137 |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
138 comments = ChangesetComment.query().all() |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
139 self.assertEqual(len(comments), 1) |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
140 comment_id = comments[0].comment_id |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
141 |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
142 self.app.delete(url(controller='changeset', |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
143 action='delete_comment', |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
144 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
|
145 comment_id=comment_id)) |
1715
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
146 |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
147 comments = ChangesetComment.query().all() |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
148 self.assertEqual(len(comments), 0) |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
149 |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
150 response = self.app.get(url(controller='changeset', action='index', |
e1e482093077
tests for changeset comments
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
151 repo_name=HG_REPO, revision=rev)) |
2317
c4d8ed624728
Fixed tests for new i18n changes
Marcin Kuzminski <marcin@python-works.com>
parents:
2194
diff
changeset
|
152 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
|
153 ''' (0 inline)</div>''') |