black/flake8
This commit is contained in:
parent
0d643964a2
commit
2380bdacb3
@ -1,8 +1,6 @@
|
|||||||
from AccessControl import getSecurityManager
|
from AccessControl import getSecurityManager
|
||||||
from AccessControl import Unauthorized
|
from AccessControl import Unauthorized
|
||||||
from Acquisition import aq_inner
|
from Acquisition import aq_inner
|
||||||
from datetime import datetime
|
|
||||||
from datetime import timezone
|
|
||||||
from DateTime import DateTime
|
from DateTime import DateTime
|
||||||
from plone.app.discussion import _
|
from plone.app.discussion import _
|
||||||
from plone.app.discussion.browser.validator import CaptchaValidator
|
from plone.app.discussion.browser.validator import CaptchaValidator
|
||||||
|
@ -5,11 +5,10 @@ from AccessControl.SecurityManagement import getSecurityManager
|
|||||||
from Acquisition import aq_base
|
from Acquisition import aq_base
|
||||||
from Acquisition import aq_parent
|
from Acquisition import aq_parent
|
||||||
from Acquisition import Implicit
|
from Acquisition import Implicit
|
||||||
from datetime import datetime
|
|
||||||
from datetime import timezone
|
|
||||||
from OFS.owner import Owned
|
from OFS.owner import Owned
|
||||||
from OFS.role import RoleManager
|
from OFS.role import RoleManager
|
||||||
from OFS.Traversable import Traversable
|
from OFS.Traversable import Traversable
|
||||||
|
from datetime import timezone
|
||||||
from persistent import Persistent
|
from persistent import Persistent
|
||||||
from plone.app.discussion import _
|
from plone.app.discussion import _
|
||||||
from plone.app.discussion.events import CommentAddedEvent
|
from plone.app.discussion.events import CommentAddedEvent
|
||||||
|
@ -81,7 +81,8 @@ class ConversationTest(unittest.TestCase):
|
|||||||
self.assertTrue(
|
self.assertTrue(
|
||||||
datetime.now().astimezone(tz.gettz(default_timezone()))
|
datetime.now().astimezone(tz.gettz(default_timezone()))
|
||||||
- conversation.last_comment_date
|
- conversation.last_comment_date
|
||||||
>= timedelta(seconds=0) <= timedelta(seconds=1),
|
>= timedelta(seconds=0)
|
||||||
|
<= timedelta(seconds=1),
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_timezone_naive_comment(self):
|
def test_timezone_naive_comment(self):
|
||||||
@ -94,13 +95,11 @@ class ConversationTest(unittest.TestCase):
|
|||||||
comment = createObject("plone.Comment")
|
comment = createObject("plone.Comment")
|
||||||
comment.text = "Comment text"
|
comment.text = "Comment text"
|
||||||
|
|
||||||
new_id = conversation.addComment(comment)
|
conversation.addComment(comment)
|
||||||
|
|
||||||
# Check that comments have the correct portal timezones
|
# Check that comments have the correct portal timezones
|
||||||
self.assertTrue(comment.creation_date.tzinfo,
|
self.assertTrue(comment.creation_date.tzinfo, tz.gettz("Europe/Berlin"))
|
||||||
tz.gettz("Europe/Berlin"))
|
self.assertTrue(comment.modification_date.tzinfo, tz.gettz("Europe/Berlin"))
|
||||||
self.assertTrue(comment.modification_date.tzinfo,
|
|
||||||
tz.gettz("Europe/Berlin"))
|
|
||||||
|
|
||||||
# Remove the timezone from the comment dates
|
# Remove the timezone from the comment dates
|
||||||
comment.creation_date = datetime.utcnow()
|
comment.creation_date = datetime.utcnow()
|
||||||
@ -111,7 +110,8 @@ class ConversationTest(unittest.TestCase):
|
|||||||
self.assertTrue(
|
self.assertTrue(
|
||||||
datetime.utcnow().replace(tzinfo=timezone.utc)
|
datetime.utcnow().replace(tzinfo=timezone.utc)
|
||||||
- conversation.last_comment_date
|
- conversation.last_comment_date
|
||||||
>= timedelta(seconds=0) <= timedelta(seconds=1),
|
>= timedelta(seconds=0)
|
||||||
|
<= timedelta(seconds=1),
|
||||||
)
|
)
|
||||||
self.assertTrue(comment.creation_date.tzinfo, timezone.utc)
|
self.assertTrue(comment.creation_date.tzinfo, timezone.utc)
|
||||||
self.assertTrue(comment.modification_date.tzinfo, timezone.utc)
|
self.assertTrue(comment.modification_date.tzinfo, timezone.utc)
|
||||||
@ -531,20 +531,23 @@ class ConversationTest(unittest.TestCase):
|
|||||||
# swapped in
|
# swapped in
|
||||||
comment1 = createObject("plone.Comment")
|
comment1 = createObject("plone.Comment")
|
||||||
comment1.text = "Comment text"
|
comment1.text = "Comment text"
|
||||||
comment1.creation_date =\
|
comment1.creation_date = datetime.now().astimezone(
|
||||||
datetime.now().astimezone(tz.gettz(default_timezone())) - timedelta(4)
|
tz.gettz(default_timezone())
|
||||||
|
) - timedelta(4)
|
||||||
conversation.addComment(comment1)
|
conversation.addComment(comment1)
|
||||||
|
|
||||||
comment2 = createObject("plone.Comment")
|
comment2 = createObject("plone.Comment")
|
||||||
comment2.text = "Comment text"
|
comment2.text = "Comment text"
|
||||||
comment2.creation_date =\
|
comment2.creation_date = datetime.now().astimezone(
|
||||||
datetime.now().astimezone(tz.gettz(default_timezone())) - timedelta(2)
|
tz.gettz(default_timezone())
|
||||||
|
) - timedelta(2)
|
||||||
new_comment2_id = conversation.addComment(comment2)
|
new_comment2_id = conversation.addComment(comment2)
|
||||||
|
|
||||||
comment3 = createObject("plone.Comment")
|
comment3 = createObject("plone.Comment")
|
||||||
comment3.text = "Comment text"
|
comment3.text = "Comment text"
|
||||||
comment3.creation_date =\
|
comment3.creation_date = datetime.now().astimezone(
|
||||||
datetime.now().astimezone(tz.gettz(default_timezone())) - timedelta(1)
|
tz.gettz(default_timezone())
|
||||||
|
) - timedelta(1)
|
||||||
new_comment3_id = conversation.addComment(comment3)
|
new_comment3_id = conversation.addComment(comment3)
|
||||||
|
|
||||||
# check if the latest comment is exactly one day old
|
# check if the latest comment is exactly one day old
|
||||||
|
@ -4,10 +4,8 @@ from .. import catalog
|
|||||||
from ..interfaces import IConversation
|
from ..interfaces import IConversation
|
||||||
from ..testing import PLONE_APP_DISCUSSION_INTEGRATION_TESTING # noqa
|
from ..testing import PLONE_APP_DISCUSSION_INTEGRATION_TESTING # noqa
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from datetime import timezone
|
|
||||||
from dateutil import tz
|
from dateutil import tz
|
||||||
from DateTime import DateTime
|
from DateTime import DateTime
|
||||||
from plone.app.event.base import localized_now
|
|
||||||
from plone.app.event.base import default_timezone
|
from plone.app.event.base import default_timezone
|
||||||
from plone.app.testing import setRoles
|
from plone.app.testing import setRoles
|
||||||
from plone.app.testing import TEST_USER_ID
|
from plone.app.testing import TEST_USER_ID
|
||||||
@ -16,8 +14,6 @@ from plone.registry.interfaces import IRegistry
|
|||||||
from zope.component import createObject
|
from zope.component import createObject
|
||||||
from zope.component import getUtility
|
from zope.component import getUtility
|
||||||
|
|
||||||
import time
|
|
||||||
import os
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user