Skip to content

Commit

Permalink
Make tests work on Plone 4 too?
Browse files Browse the repository at this point in the history
  • Loading branch information
jaroel committed May 16, 2017
1 parent 299801a commit bf5ac9f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 39 deletions.
12 changes: 7 additions & 5 deletions src/plone/restapi/tests/test_comments.py
Expand Up @@ -7,8 +7,10 @@
from plone.app.discussion.interfaces import IDiscussionSettings
from plone.app.discussion.interfaces import IConversation
from plone.app.discussion.interfaces import IReplies
from plone.registry.interfaces import IRegistry

from zope.component import createObject
from zope.component import getUtility

from plone import api

Expand All @@ -23,11 +25,11 @@ def setUp(self):
self.portal_url = self.portal.absolute_url()

# Allow discussion
api.portal.set_registry_record(
'globally_enabled',
True,
interface=IDiscussionSettings
)
registry = getUtility(IRegistry)
settings = registry.forInterface(IDiscussionSettings, check=False)
settings.globally_enabled = True
settings.edit_comment_enabled = True
settings.delete_own_comment_enabled = True

# doc with comments
self.doc = api.content.create(
Expand Down
24 changes: 7 additions & 17 deletions src/plone/restapi/tests/test_documentation.py
Expand Up @@ -16,11 +16,13 @@
from plone.app.textfield.value import RichTextValue
from plone.namedfile.file import NamedBlobFile
from plone.namedfile.file import NamedBlobImage
from plone.registry.interfaces import IRegistry
from plone.restapi.testing import PLONE_RESTAPI_DX_FUNCTIONAL_TESTING
from plone.restapi.testing import register_static_uuid_utility
from plone.restapi.testing import RelativeSession
from plone.testing.z2 import Browser
from zope.component import createObject
from zope.component import getUtility
from zope.site.hooks import getSite

import collections
Expand Down Expand Up @@ -812,23 +814,11 @@ def setUp(self):
self.time_freezer = freeze_time("2016-10-21 19:00:00")
self.frozen_time = self.time_freezer.start()

api.portal.set_registry_record(
'globally_enabled',
True,
interface=IDiscussionSettings
)

api.portal.set_registry_record(
'edit_comment_enabled',
True,
interface=IDiscussionSettings
)

api.portal.set_registry_record(
'delete_own_comment_enabled',
True,
interface=IDiscussionSettings
)
registry = getUtility(IRegistry)
settings = registry.forInterface(IDiscussionSettings, check=False)
settings.globally_enabled = True
settings.edit_comment_enabled = True
settings.delete_own_comment_enabled = True

self.api_session = RelativeSession(self.portal_url)
self.api_session.headers.update({'Accept': 'application/json'})
Expand Down
25 changes: 8 additions & 17 deletions src/plone/restapi/tests/test_services_comments.py
Expand Up @@ -2,11 +2,14 @@
from plone import api
from plone.app.testing import SITE_OWNER_NAME
from plone.app.testing import SITE_OWNER_PASSWORD
from plone.registry.interfaces import IRegistry
from plone.restapi.testing import PLONE_RESTAPI_DX_FUNCTIONAL_TESTING
from plone.restapi.testing import RelativeSession

from plone.app.discussion.interfaces import IDiscussionSettings

from zope.component import getUtility

import transaction
import unittest

Expand All @@ -22,23 +25,11 @@ def setUp(self):
self.portal_url = self.portal.absolute_url()

# Allow discussion
api.portal.set_registry_record(
'globally_enabled',
True,
interface=IDiscussionSettings
)

api.portal.set_registry_record(
'edit_comment_enabled',
True,
interface=IDiscussionSettings
)

api.portal.set_registry_record(
'delete_own_comment_enabled',
True,
interface=IDiscussionSettings
)
registry = getUtility(IRegistry)
settings = registry.forInterface(IDiscussionSettings, check=False)
settings.globally_enabled = True
settings.edit_comment_enabled = True
settings.delete_own_comment_enabled = True

# doc with comments
self.doc = api.content.create(
Expand Down

0 comments on commit bf5ac9f

Please sign in to comment.