Skip to content

Commit

Permalink
Increased coverage by using vocabulary methods instead of redefining …
Browse files Browse the repository at this point in the history
…it in tests.
  • Loading branch information
gbastien committed Jan 18, 2016
1 parent 38ff4d0 commit 36f5118
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
3 changes: 2 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ Changelog
0.9 (unreleased)
----------------

- Nothing changed yet.
- Increased coverage by using vocabulary methods instead of redefining it in tests.
[gbastien]


0.8 (2016-01-18)
Expand Down
11 changes: 6 additions & 5 deletions src/collective/messagesviewlet/tests/test_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

from DateTime import DateTime

from Products.CMFCore.utils import getToolByName

from zope.component import queryUtility
from zope.component import createObject

Expand All @@ -17,6 +15,8 @@

from collective.messagesviewlet.browser.messagesviewlet import MessagesViewlet
from collective.messagesviewlet.message import IMessage
from collective.messagesviewlet.message import location
from collective.messagesviewlet.message import msg_types
from collective.messagesviewlet.testing import COLLECTIVE_MESSAGESVIEWLET_INTEGRATION_TESTING # noqa
from collective.messagesviewlet.utils import add_message

Expand All @@ -28,8 +28,7 @@ class MessageIntegrationTest(unittest.TestCase):
def _changeUser(self, loginName):
logout()
login(self.portal, loginName)
membershipTool = getToolByName(self.portal, 'portal_membership')
self.member = membershipTool.getAuthenticatedMember()
self.member = api.user.get_current()
self.portal.REQUEST['AUTHENTICATED_USER'] = self.member

def _set_viewlet(self):
Expand All @@ -44,9 +43,9 @@ def _set_viewlet(self):

def setUp(self):
"""Custom shared utility setup for tests."""
self.message_types = ["info", "significant", "warning"]
self.isHidden = [True, True, False]
self.portal = self.layer['portal']
self.message_types = [term.token for term in msg_types(self.portal)._terms]
# The products build the "special" folder "messages-config" to store messages.
self.message_config_folder = self.portal["messages-config"]
setRoles(self.portal, TEST_USER_ID, ['Manager'])
Expand Down Expand Up @@ -140,6 +139,8 @@ def test_getAllMessages_tal_condition(self):
def test_getAllMessages_location(self):
viewlet = self._set_viewlet()
self.assertEqual(len(viewlet.getAllMessages()), len(self.message_types))
locations = [term.token for term in location(self.portal)._terms]
self.assertEquals(locations, ['fullsite', 'homepage'])
message = self.messages[2]
message.location = "homepage"
message.reindexObject()
Expand Down

0 comments on commit 36f5118

Please sign in to comment.