def test_create(self): self.log_user() rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc' text = u'CommentOnRevision' params = {'text': text} response = self.app.post(url(controller='changeset', action='comment', repo_name=HG_REPO, revision=rev), params=params) # Test response... self.assertEqual(response.status, '302 Found') response.follow() response = self.app.get(url(controller='changeset', action='index', repo_name=HG_REPO, revision=rev)) # test DB self.assertEqual(ChangesetComment.query().count(), 1) response.mustcontain('''<div class="comments-number">%s comment ''' '''(0 inline)</div>''' % 1) self.assertEqual(Notification.query().count(), 1) self.assertEqual(ChangesetComment.query().count(), 1) notification = Notification.query().all()[0] ID = ChangesetComment.query().first().comment_id self.assertEqual(notification.type_, Notification.TYPE_CHANGESET_COMMENT) sbj = (u'/vcs_test_hg/changeset/' '27cd5cce30c96924232dffcd24178a07ffeb5dfc#comment-%s' % ID) print "%s vs %s" % (sbj, notification.subject) self.assertTrue(sbj in notification.subject)
def test_create(self): self.log_user() rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc' text = u'CommentOnRevision' params = {'text': text} response = self.app.post(url(controller='changeset', action='comment', repo_name=HG_REPO, revision=rev), params=params) # Test response... self.assertEqual(response.status, '302 Found') response.follow() response = self.app.get(url(controller='changeset', action='index', repo_name=HG_REPO, revision=rev)) # test DB self.assertEqual(ChangesetComment.query().count(), 1) self.assertTrue('''<div class="comments-number">%s ''' '''comment(s) (0 inline)</div>''' % 1 in response.body) self.assertEqual(Notification.query().count(), 1) self.assertEqual(ChangesetComment.query().count(), 1) notification = Notification.query().all()[0] ID = ChangesetComment.query().first().comment_id self.assertEqual(notification.type_, Notification.TYPE_CHANGESET_COMMENT) sbj = (u'/vcs_test_hg/changeset/' '27cd5cce30c96924232dffcd24178a07ffeb5dfc#comment-%s' % ID) print "%s vs %s" % (sbj, notification.subject) self.assertTrue(sbj in notification.subject)
def _clean_notifications(self, request, pylonsapp): for n in Notification.query().all(): Session().delete(n) Session().commit() assert [] == Notification.query().all() assert [] == UserNotification.query().all()
def test_create_notification(self): self.assertEqual([], Notification.query().all()) self.assertEqual([], UserNotification.query().all()) usrs = [self.u1, self.u2] notification = NotificationModel().create(created_by=self.u1, subject=u'subj', body=u'hi there', recipients=usrs) Session().commit() u1 = User.get(self.u1) u2 = User.get(self.u2) u3 = User.get(self.u3) notifications = Notification.query().all() self.assertEqual(len(notifications), 1) self.assertEqual(notifications[0].recipients, [u1, u2]) self.assertEqual(notification.notification_id, notifications[0].notification_id) unotification = UserNotification.query()\ .filter(UserNotification.notification == notification).all() self.assertEqual(len(unotification), len(usrs)) self.assertEqual(set([x.user.user_id for x in unotification]), set(usrs))
def test_create_inline(self): self.log_user() rev = "27cd5cce30c96924232dffcd24178a07ffeb5dfc" text = u"CommentOnRevision" f_path = "vcs/web/simplevcs/views/repository.py" line = "n1" params = {"text": text, "f_path": f_path, "line": line} response = self.app.post( url(controller="changeset", action="comment", repo_name=HG_REPO, revision=rev), params=params ) # Test response... self.assertEqual(response.status, "302 Found") response.follow() response = self.app.get(url(controller="changeset", action="index", repo_name=HG_REPO, revision=rev)) # test DB self.assertEqual(ChangesetComment.query().count(), 1) response.mustcontain("""<div class="comments-number">0 comment(s)""" """ (%s inline)</div>""" % 1) response.mustcontain( """<div style="display:none" class="inline-comment-placeholder" """ """path="vcs/web/simplevcs/views/repository.py" """ """target_id="vcswebsimplevcsviewsrepositorypy">""" ) self.assertEqual(Notification.query().count(), 1) self.assertEqual(ChangesetComment.query().count(), 1) notification = Notification.query().all()[0] ID = ChangesetComment.query().first().comment_id self.assertEqual(notification.type_, Notification.TYPE_CHANGESET_COMMENT) sbj = u"/vcs_test_hg/changeset/" "27cd5cce30c96924232dffcd24178a07ffeb5dfc#comment-%s" % ID print "%s vs %s" % (sbj, notification.subject) self.assertTrue(sbj in notification.subject)
def test_create(self): self.log_user() rev = "27cd5cce30c96924232dffcd24178a07ffeb5dfc" text = u"CommentOnRevision" params = {"text": text} response = self.app.post( url(controller="changeset", action="comment", repo_name=HG_REPO, revision=rev), params=params ) # Test response... self.assertEqual(response.status, "302 Found") response.follow() response = self.app.get(url(controller="changeset", action="index", repo_name=HG_REPO, revision=rev)) # test DB self.assertEqual(ChangesetComment.query().count(), 1) self.assertTrue("""<div class="comments-number">%s """ """comment(s) (0 inline)</div>""" % 1 in response.body) self.assertEqual(Notification.query().count(), 1) self.assertEqual(ChangesetComment.query().count(), 1) notification = Notification.query().all()[0] ID = ChangesetComment.query().first().comment_id self.assertEqual(notification.type_, Notification.TYPE_CHANGESET_COMMENT) sbj = u"/vcs_test_hg/changeset/" "27cd5cce30c96924232dffcd24178a07ffeb5dfc#comment-%s" % ID print "%s vs %s" % (sbj, notification.subject) self.assertTrue(sbj in notification.subject)
def test_create_inline(self, backend): self.log_user() commit_id = backend.repo.get_commit('300').raw_id text = u'CommentOnCommit' f_path = 'vcs/web/simplevcs/views/repository.py' line = 'n1' params = { 'text': text, 'f_path': f_path, 'line': line, 'csrf_token': self.csrf_token } self.app.post(url(controller='changeset', action='comment', repo_name=backend.repo_name, revision=commit_id), params=params) response = self.app.get( url(controller='changeset', action='index', repo_name=backend.repo_name, revision=commit_id)) # test DB assert ChangesetComment.query().count() == 1 assert_comment_links(response, 0, ChangesetComment.query().count()) response.mustcontain( '''class="inline-comment-placeholder" ''' '''path="vcs/web/simplevcs/views/repository.py" ''' '''target_id="vcswebsimplevcsviewsrepositorypy"''') assert Notification.query().count() == 1 assert ChangesetComment.query().count() == 1 notification = Notification.query().all()[0] comment = ChangesetComment.query().first() assert notification.type_ == Notification.TYPE_CHANGESET_COMMENT assert comment.revision == commit_id sbj = 'commented on commit of {0}'.format(backend.repo_name) assert sbj in notification.subject lnk = (u'/{0}/changeset/{1}#comment-{2}'.format( backend.repo_name, commit_id, comment.comment_id)) assert lnk in notification.body assert 'on line n1' in notification.body
def test_create_with_mention(self, backend): self.log_user() commit_id = backend.repo.get_commit('300').raw_id text = u'@test_regular check CommentOnCommit' params = {'text': text, 'csrf_token': self.csrf_token} self.app.post(url(controller='changeset', action='comment', repo_name=backend.repo_name, revision=commit_id), params=params) response = self.app.get( url(controller='changeset', action='index', repo_name=backend.repo_name, revision=commit_id)) # test DB assert ChangesetComment.query().count() == 1 assert_comment_links(response, ChangesetComment.query().count(), 0) notification = Notification.query().one() assert len(notification.recipients) == 2 users = [x.username for x in notification.recipients] # test_regular gets notification by @mention assert sorted(users) == [u'test_admin', u'test_regular']
def test_delete_association(self): notification = NotificationModel().create( created_by=self.u1, notification_subject=u'title', notification_body=u'hi there3', recipients=[self.u3, self.u1, self.u2]) Session().commit() unotification = (UserNotification.query().filter( UserNotification.notification == notification).filter( UserNotification.user_id == self.u3).scalar()) assert unotification.user_id == self.u3 NotificationModel().delete(self.u3, notification.notification_id) Session().commit() u3notification = (UserNotification.query().filter( UserNotification.notification == notification).filter( UserNotification.user_id == self.u3).scalar()) assert u3notification is None # notification object is still there assert Notification.query().all() == [notification] # u1 and u2 still have assignments u1notification = (UserNotification.query().filter( UserNotification.notification == notification).filter( UserNotification.user_id == self.u1).scalar()) assert u1notification is not None u2notification = (UserNotification.query().filter( UserNotification.notification == notification).filter( UserNotification.user_id == self.u2).scalar()) assert u2notification is not None
def test_create_with_mention(self): self.log_user() rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc' text = u'@test_regular check CommentOnRevision' params = {'text': text} response = self.app.post(url(controller='changeset', action='comment', repo_name=HG_REPO, revision=rev), params=params) # Test response... self.assertEqual(response.status, '302 Found') response.follow() response = self.app.get( url(controller='changeset', action='index', repo_name=HG_REPO, revision=rev)) # test DB self.assertEqual(ChangesetComment.query().count(), 1) response.mustcontain('''<div class="comments-number">%s ''' '''comment (0 inline)</div>''' % 1) self.assertEqual(Notification.query().count(), 2) users = [x.user.username for x in UserNotification.query().all()] # test_regular get's notification by @mention self.assertEqual(sorted(users), [u'test_admin', u'test_regular'])
def test_notification_counter(self): self._clean_notifications() self.assertEqual([], Notification.query().all()) self.assertEqual([], UserNotification.query().all()) NotificationModel().create(created_by=self.u1, subject=u'title', body=u'hi there_delete', recipients=[self.u3, self.u1]) Session().commit() self.assertEqual(NotificationModel() .get_unread_cnt_for_user(self.u1), 1) self.assertEqual(NotificationModel() .get_unread_cnt_for_user(self.u2), 0) self.assertEqual(NotificationModel() .get_unread_cnt_for_user(self.u3), 1) notification = NotificationModel().create(created_by=self.u1, subject=u'title', body=u'hi there3', recipients=[self.u3, self.u1, self.u2]) Session().commit() self.assertEqual(NotificationModel() .get_unread_cnt_for_user(self.u1), 2) self.assertEqual(NotificationModel() .get_unread_cnt_for_user(self.u2), 1) self.assertEqual(NotificationModel() .get_unread_cnt_for_user(self.u3), 2)
def test_notification_counter(self): self._clean_notifications() self.assertEqual([], Notification.query().all()) self.assertEqual([], UserNotification.query().all()) NotificationModel().create(created_by=self.u1, subject=u'title', body=u'hi there_delete', recipients=[self.u3, self.u1]) Session.commit() self.assertEqual(NotificationModel().get_unread_cnt_for_user(self.u1), 1) self.assertEqual(NotificationModel().get_unread_cnt_for_user(self.u2), 0) self.assertEqual(NotificationModel().get_unread_cnt_for_user(self.u3), 1) notification = NotificationModel().create( created_by=self.u1, subject=u'title', body=u'hi there3', recipients=[self.u3, self.u1, self.u2]) Session.commit() self.assertEqual(NotificationModel().get_unread_cnt_for_user(self.u1), 2) self.assertEqual(NotificationModel().get_unread_cnt_for_user(self.u2), 1) self.assertEqual(NotificationModel().get_unread_cnt_for_user(self.u3), 2)
def test_create_with_mention(self): self.log_user() rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc' text = u'@test_regular check CommentOnRevision' params = {'text':text} response = self.app.post(url(controller='changeset', action='comment', repo_name=HG_REPO, revision=rev), params=params) # Test response... self.assertEqual(response.status, '302 Found') response.follow() response = self.app.get(url(controller='changeset', action='index', repo_name=HG_REPO, revision=rev)) # test DB self.assertEqual(ChangesetComment.query().count(), 1) response.mustcontain('''<div class="comments-number">%s ''' '''comment (0 inline)</div>''' % 1) self.assertEqual(Notification.query().count(), 2) users = [x.user.username for x in UserNotification.query().all()] # test_regular get's notification by @mention self.assertEqual(sorted(users), [u'test_admin', u'test_regular'])
def test_delete_association(self): self.assertEqual([], Notification.query().all()) self.assertEqual([], UserNotification.query().all()) notification = NotificationModel().create( created_by=self.u1, subject=u'title', body=u'hi there3', recipients=[self.u3, self.u1, self.u2]) Session.commit() unotification = UserNotification.query()\ .filter(UserNotification.notification == notification)\ .filter(UserNotification.user_id == self.u3)\ .scalar() self.assertEqual(unotification.user_id, self.u3) NotificationModel().delete(self.u3, notification.notification_id) Session.commit() u3notification = UserNotification.query()\ .filter(UserNotification.notification == notification)\ .filter(UserNotification.user_id == self.u3)\ .scalar() self.assertEqual(u3notification, None) # notification object is still there self.assertEqual(Notification.query().all(), [notification]) #u1 and u2 still have assignments u1notification = UserNotification.query()\ .filter(UserNotification.notification == notification)\ .filter(UserNotification.user_id == self.u1)\ .scalar() self.assertNotEqual(u1notification, None) u2notification = UserNotification.query()\ .filter(UserNotification.notification == notification)\ .filter(UserNotification.user_id == self.u2)\ .scalar() self.assertNotEqual(u2notification, None)
def setUp(self): for x in ChangesetComment.query().all(): self.Session.delete(x) self.Session.commit() for x in Notification.query().all(): self.Session.delete(x) self.Session.commit()
def test_delete_association(self): self.assertEqual([], Notification.query().all()) self.assertEqual([], UserNotification.query().all()) notification = NotificationModel().create(created_by=self.u1, subject=u'title', body=u'hi there3', recipients=[self.u3, self.u1, self.u2]) Session().commit() unotification = UserNotification.query()\ .filter(UserNotification.notification == notification)\ .filter(UserNotification.user_id == self.u3)\ .scalar() self.assertEqual(unotification.user_id, self.u3) NotificationModel().delete(self.u3, notification.notification_id) Session().commit() u3notification = UserNotification.query()\ .filter(UserNotification.notification == notification)\ .filter(UserNotification.user_id == self.u3)\ .scalar() self.assertEqual(u3notification, None) # notification object is still there self.assertEqual(Notification.query().all(), [notification]) #u1 and u2 still have assignments u1notification = UserNotification.query()\ .filter(UserNotification.notification == notification)\ .filter(UserNotification.user_id == self.u1)\ .scalar() self.assertNotEqual(u1notification, None) u2notification = UserNotification.query()\ .filter(UserNotification.notification == notification)\ .filter(UserNotification.user_id == self.u2)\ .scalar() self.assertNotEqual(u2notification, None)
def cleanup(self): for x in ChangesetComment.query().all(): Session().delete(x) Session().commit() for x in Notification.query().all(): Session().delete(x) Session().commit()
def setUp(self): for x in ChangesetComment.query().all(): Session().delete(x) Session().commit() for x in Notification.query().all(): Session().delete(x) Session().commit()
def tearDown(self): for x in ChangesetComment.query().all(): self.Session.delete(x) self.Session.commit() for x in Notification.query().all(): self.Session.delete(x) self.Session.commit()
def test_delete_notifications(self): notification = NotificationModel().create( created_by=self.u1, notification_subject=u'title', notification_body=u'hi there3', recipients=[self.u3, self.u1, self.u2]) Session().commit() notifications = Notification.query().all() assert notification in notifications Notification.delete(notification.notification_id) Session().commit() notifications = Notification.query().all() assert notification not in notifications un = UserNotification.query().filter( UserNotification.notification == notification).all() assert un == []
def prepare(self, request, pylonsapp): for x in ChangesetComment.query().all(): Session().delete(x) Session().commit() for x in Notification.query().all(): Session().delete(x) Session().commit() request.addfinalizer(self.cleanup)
def test_create_inline(self): self.log_user() rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc' text = u'CommentOnRevision' f_path = 'vcs/web/simplevcs/views/repository.py' line = 'n1' params = {'text': text, 'f_path': f_path, 'line': line} response = self.app.post(url(controller='changeset', action='comment', repo_name=HG_REPO, revision=rev), params=params) # Test response... self.assertEqual(response.status, '302 Found') response.follow() response = self.app.get( url(controller='changeset', action='index', repo_name=HG_REPO, revision=rev)) #test DB self.assertEqual(ChangesetComment.query().count(), 1) response.mustcontain('''<div class="comments-number">0 comments''' ''' (%s inline)</div>''' % 1) response.mustcontain( '''<div style="display:none" class="inline-comment-placeholder" ''' '''path="vcs/web/simplevcs/views/repository.py" ''' '''target_id="vcswebsimplevcsviewsrepositorypy">''') self.assertEqual(Notification.query().count(), 1) self.assertEqual(ChangesetComment.query().count(), 1) notification = Notification.query().all()[0] ID = ChangesetComment.query().first().comment_id self.assertEqual(notification.type_, Notification.TYPE_CHANGESET_COMMENT) sbj = (u'/vcs_test_hg/changeset/' '27cd5cce30c96924232dffcd24178a07ffeb5dfc#comment-%s' % ID) print "%s vs %s" % (sbj, notification.subject) self.assertTrue(sbj in notification.subject)
def test_delete_notifications(self): self.assertEqual([], Notification.query().all()) self.assertEqual([], UserNotification.query().all()) notification = NotificationModel().create(created_by=self.u1, subject=u'title', body=u'hi there3', recipients=[self.u3, self.u1, self.u2]) Session().commit() notifications = Notification.query().all() self.assertTrue(notification in notifications) Notification.delete(notification.notification_id) Session().commit() notifications = Notification.query().all() self.assertFalse(notification in notifications) un = UserNotification.query().filter(UserNotification.notification == notification).all() self.assertEqual(un, [])
def test_reviewer_notifications(self, backend, csrf_token): # We have to use the app.post for this test so it will create the # notifications properly with the new PR commits = [ {'message': 'ancestor', 'added': [FileNode('file_A', content='content_of_ancestor')]}, {'message': 'change', 'added': [FileNode('file_a', content='content_of_change')]}, {'message': 'change-child'}, {'message': 'ancestor-child', 'parents': ['ancestor'], 'added': [ FileNode('file_B', content='content_of_ancestor_child')]}, {'message': 'ancestor-child-2'}, ] commit_ids = backend.create_master_repo(commits) target = backend.create_repo(heads=['ancestor-child']) source = backend.create_repo(heads=['change']) response = self.app.post( url( controller='pullrequests', action='create', repo_name=source.repo_name), params={ 'source_repo': source.repo_name, 'source_ref': 'branch:default:' + commit_ids['change'], 'target_repo': target.repo_name, 'target_ref': 'branch:default:' + commit_ids['ancestor-child'], 'pullrequest_desc': 'Description', 'pullrequest_title': 'Title', 'review_members': '2', 'revisions': commit_ids['change'], 'user': '', 'csrf_token': csrf_token, }, status=302) location = response.headers['Location'] pull_request_id = int(location.rsplit('/', 1)[1]) pull_request = PullRequest.get(pull_request_id) # Check that a notification was made notifications = Notification.query()\ .filter(Notification.created_by == pull_request.author.user_id, Notification.type_ == Notification.TYPE_PULL_REQUEST, Notification.subject.contains("wants you to review " "pull request #%d" % pull_request_id)) assert len(notifications.all()) == 1 # Change reviewers and check that a notification was made PullRequestModel().update_reviewers(pull_request.pull_request_id, [1]) assert len(notifications.all()) == 2
def test_create_inline(self): self.log_user() rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc' text = u'CommentOnRevision' f_path = 'vcs/web/simplevcs/views/repository.py' line = 'n1' params = {'text': text, 'f_path': f_path, 'line': line} response = self.app.post(url(controller='changeset', action='comment', repo_name=HG_REPO, revision=rev), params=params) # Test response... self.assertEqual(response.status, '302 Found') response.follow() response = self.app.get(url(controller='changeset', action='index', repo_name=HG_REPO, revision=rev)) #test DB self.assertEqual(ChangesetComment.query().count(), 1) response.mustcontain( '''<div class="comments-number">0 comments''' ''' (%s inline)</div>''' % 1 ) response.mustcontain( '''<div style="display:none" class="inline-comment-placeholder" ''' '''path="vcs/web/simplevcs/views/repository.py" ''' '''target_id="vcswebsimplevcsviewsrepositorypy">''' ) self.assertEqual(Notification.query().count(), 1) self.assertEqual(ChangesetComment.query().count(), 1) notification = Notification.query().all()[0] ID = ChangesetComment.query().first().comment_id self.assertEqual(notification.type_, Notification.TYPE_CHANGESET_COMMENT) sbj = (u'/vcs_test_hg/changeset/' '27cd5cce30c96924232dffcd24178a07ffeb5dfc#comment-%s' % ID) print "%s vs %s" % (sbj, notification.subject) self.assertTrue(sbj in notification.subject)
def test_delete_notifications(self): self.assertEqual([], Notification.query().all()) self.assertEqual([], UserNotification.query().all()) notification = NotificationModel().create( created_by=self.u1, subject=u'title', body=u'hi there3', recipients=[self.u3, self.u1, self.u2]) Session.commit() notifications = Notification.query().all() self.assertTrue(notification in notifications) Notification.delete(notification.notification_id) Session.commit() notifications = Notification.query().all() self.assertFalse(notification in notifications) un = UserNotification.query().filter( UserNotification.notification == notification).all() self.assertEqual(un, [])
def test_create(self, backend): self.log_user() commit_id = backend.repo.get_commit('300').raw_id text = u'CommentOnCommit' params = {'text': text, 'csrf_token': self.csrf_token} self.app.post(url(controller='changeset', action='comment', repo_name=backend.repo_name, revision=commit_id), params=params) response = self.app.get( url(controller='changeset', action='index', repo_name=backend.repo_name, revision=commit_id)) # test DB assert ChangesetComment.query().count() == 1 assert_comment_links(response, ChangesetComment.query().count(), 0) assert Notification.query().count() == 1 assert ChangesetComment.query().count() == 1 notification = Notification.query().all()[0] comment_id = ChangesetComment.query().first().comment_id assert notification.type_ == Notification.TYPE_CHANGESET_COMMENT sbj = 'commented on commit of {0}'.format(backend.repo_name) assert sbj in notification.subject lnk = (u'/{0}/changeset/{1}#comment-{2}'.format( backend.repo_name, commit_id, comment_id)) assert lnk in notification.body
def test_user_notifications(self): self.assertEqual([], Notification.query().all()) self.assertEqual([], UserNotification.query().all()) notification1 = NotificationModel().create(created_by=self.u1, subject=u'subj', body=u'hi there1', recipients=[self.u3]) Session().commit() notification2 = NotificationModel().create(created_by=self.u1, subject=u'subj', body=u'hi there2', recipients=[self.u3]) Session().commit() u3 = Session().query(User).get(self.u3) self.assertEqual(sorted([x.notification for x in u3.notifications]), sorted([notification2, notification1]))
def test_user_notifications(self): self.assertEqual([], Notification.query().all()) self.assertEqual([], UserNotification.query().all()) notification1 = NotificationModel().create(created_by=self.u1, subject=u'subj', body=u'hi there1', recipients=[self.u3]) Session.commit() notification2 = NotificationModel().create(created_by=self.u1, subject=u'subj', body=u'hi there2', recipients=[self.u3]) Session.commit() u3 = Session.query(User).get(self.u3) self.assertEqual(sorted([x.notification for x in u3.notifications]), sorted([notification2, notification1]))
def test_create_notification(self): usrs = [self.u1, self.u2] notification = NotificationModel().create( created_by=self.u1, notification_subject=u'subj', notification_body=u'hi there', recipients=usrs) Session().commit() u1 = User.get(self.u1) u2 = User.get(self.u2) notifications = Notification.query().all() assert len(notifications) == 1 assert notifications[0].recipients, [u1 == u2] assert notification.notification_id == notifications[0].notification_id unotification = UserNotification.query()\ .filter(UserNotification.notification == notification).all() assert len(unotification) == len(usrs) assert set([x.user.user_id for x in unotification]) == set(usrs)
def test_create_with_mention(self): self.log_user() rev = "27cd5cce30c96924232dffcd24178a07ffeb5dfc" text = u"@test_regular check CommentOnRevision" params = {"text": text} response = self.app.post( url(controller="changeset", action="comment", repo_name=HG_REPO, revision=rev), params=params ) # Test response... self.assertEqual(response.status, "302 Found") response.follow() response = self.app.get(url(controller="changeset", action="index", repo_name=HG_REPO, revision=rev)) # test DB self.assertEqual(ChangesetComment.query().count(), 1) self.assertTrue("""<div class="comments-number">%s """ """comment(s) (0 inline)</div>""" % 1 in response.body) self.assertEqual(Notification.query().count(), 2) users = [x.user.username for x in UserNotification.query().all()] # test_regular get's notification by @mention self.assertEqual(sorted(users), [u"test_admin", u"test_regular"])
def teardown_method(self, method): for n in Notification.query().all(): inst = Notification.get(n.notification_id) Session().delete(inst) Session().commit()
def _clean_notifications(self): for n in Notification.query().all(): Session().delete(n) Session().commit() self.assertEqual(Notification.query().all(), [])
def teardown_method(self, method): for n in Notification.query().all(): Session().delete(n) Session().commit() assert Notification.query().all() == []
def tearDown(self): for n in Notification.query().all(): self.Session().delete(n) self.Session().commit() self.assertEqual(Notification.query().all(), [])
def _clean_notifications(self): for n in Notification.query().all(): Session.delete(n) Session.commit() self.assertEqual(Notification.query().all(), [])
def tearDown(self): for n in Notification.query().all(): inst = Notification.get(n.notification_id) self.Session().delete(inst) self.Session().commit()
def tearDown(self): for n in Notification.query().all(): inst = Notification.get(n.notification_id) Session().delete(inst) Session().commit()