black/flake8
This commit is contained in:
		
							parent
							
								
									0d643964a2
								
							
						
					
					
						commit
						2380bdacb3
					
				@ -1,8 +1,6 @@
 | 
			
		||||
from AccessControl import getSecurityManager
 | 
			
		||||
from AccessControl import Unauthorized
 | 
			
		||||
from Acquisition import aq_inner
 | 
			
		||||
from datetime import datetime
 | 
			
		||||
from datetime import timezone
 | 
			
		||||
from DateTime import DateTime
 | 
			
		||||
from plone.app.discussion import _
 | 
			
		||||
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_parent
 | 
			
		||||
from Acquisition import Implicit
 | 
			
		||||
from datetime import datetime
 | 
			
		||||
from datetime import timezone
 | 
			
		||||
from OFS.owner import Owned
 | 
			
		||||
from OFS.role import RoleManager
 | 
			
		||||
from OFS.Traversable import Traversable
 | 
			
		||||
from datetime import timezone
 | 
			
		||||
from persistent import Persistent
 | 
			
		||||
from plone.app.discussion import _
 | 
			
		||||
from plone.app.discussion.events import CommentAddedEvent
 | 
			
		||||
 | 
			
		||||
@ -80,8 +80,9 @@ class ConversationTest(unittest.TestCase):
 | 
			
		||||
        self.assertEqual(conversation.total_comments(), 1)
 | 
			
		||||
        self.assertTrue(
 | 
			
		||||
            datetime.now().astimezone(tz.gettz(default_timezone()))
 | 
			
		||||
            - conversation.last_comment_date 
 | 
			
		||||
            >= timedelta(seconds=0) <= timedelta(seconds=1),
 | 
			
		||||
            - conversation.last_comment_date
 | 
			
		||||
            >= timedelta(seconds=0)
 | 
			
		||||
            <= timedelta(seconds=1),
 | 
			
		||||
        )
 | 
			
		||||
 | 
			
		||||
    def test_timezone_naive_comment(self):
 | 
			
		||||
@ -94,24 +95,23 @@ class ConversationTest(unittest.TestCase):
 | 
			
		||||
        comment = createObject("plone.Comment")
 | 
			
		||||
        comment.text = "Comment text"
 | 
			
		||||
 | 
			
		||||
        new_id = conversation.addComment(comment)
 | 
			
		||||
        conversation.addComment(comment)
 | 
			
		||||
 | 
			
		||||
        # Check that comments have the correct portal timezones
 | 
			
		||||
        self.assertTrue(comment.creation_date.tzinfo,
 | 
			
		||||
                        tz.gettz("Europe/Berlin"))
 | 
			
		||||
        self.assertTrue(comment.modification_date.tzinfo,
 | 
			
		||||
                        tz.gettz("Europe/Berlin"))
 | 
			
		||||
        
 | 
			
		||||
        self.assertTrue(comment.creation_date.tzinfo, tz.gettz("Europe/Berlin"))
 | 
			
		||||
        self.assertTrue(comment.modification_date.tzinfo, tz.gettz("Europe/Berlin"))
 | 
			
		||||
 | 
			
		||||
        # Remove the timezone from the comment dates
 | 
			
		||||
        comment.creation_date = datetime.utcnow()
 | 
			
		||||
        comment.modification_date = datetime.utcnow()
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        # Check that the timezone naive date is converted to UTC
 | 
			
		||||
        # See https://github.com/plone/plone.app.discussion/pull/204
 | 
			
		||||
        self.assertTrue(
 | 
			
		||||
            datetime.utcnow().replace(tzinfo=timezone.utc) 
 | 
			
		||||
            - conversation.last_comment_date 
 | 
			
		||||
            >= timedelta(seconds=0) <= timedelta(seconds=1),
 | 
			
		||||
            datetime.utcnow().replace(tzinfo=timezone.utc)
 | 
			
		||||
            - conversation.last_comment_date
 | 
			
		||||
            >= timedelta(seconds=0)
 | 
			
		||||
            <= timedelta(seconds=1),
 | 
			
		||||
        )
 | 
			
		||||
        self.assertTrue(comment.creation_date.tzinfo, timezone.utc)
 | 
			
		||||
        self.assertTrue(comment.modification_date.tzinfo, timezone.utc)
 | 
			
		||||
@ -531,20 +531,23 @@ class ConversationTest(unittest.TestCase):
 | 
			
		||||
        # swapped in
 | 
			
		||||
        comment1 = createObject("plone.Comment")
 | 
			
		||||
        comment1.text = "Comment text"
 | 
			
		||||
        comment1.creation_date =\
 | 
			
		||||
            datetime.now().astimezone(tz.gettz(default_timezone())) - timedelta(4)
 | 
			
		||||
        comment1.creation_date = datetime.now().astimezone(
 | 
			
		||||
            tz.gettz(default_timezone())
 | 
			
		||||
        ) - timedelta(4)
 | 
			
		||||
        conversation.addComment(comment1)
 | 
			
		||||
 | 
			
		||||
        comment2 = createObject("plone.Comment")
 | 
			
		||||
        comment2.text = "Comment text"
 | 
			
		||||
        comment2.creation_date =\
 | 
			
		||||
            datetime.now().astimezone(tz.gettz(default_timezone())) - timedelta(2)
 | 
			
		||||
        comment2.creation_date = datetime.now().astimezone(
 | 
			
		||||
            tz.gettz(default_timezone())
 | 
			
		||||
        ) - timedelta(2)
 | 
			
		||||
        new_comment2_id = conversation.addComment(comment2)
 | 
			
		||||
 | 
			
		||||
        comment3 = createObject("plone.Comment")
 | 
			
		||||
        comment3.text = "Comment text"
 | 
			
		||||
        comment3.creation_date =\
 | 
			
		||||
            datetime.now().astimezone(tz.gettz(default_timezone())) - timedelta(1)
 | 
			
		||||
        comment3.creation_date = datetime.now().astimezone(
 | 
			
		||||
            tz.gettz(default_timezone())
 | 
			
		||||
        ) - timedelta(1)
 | 
			
		||||
        new_comment3_id = conversation.addComment(comment3)
 | 
			
		||||
 | 
			
		||||
        # check if the latest comment is exactly one day old
 | 
			
		||||
 | 
			
		||||
@ -4,10 +4,8 @@ from .. import catalog
 | 
			
		||||
from ..interfaces import IConversation
 | 
			
		||||
from ..testing import PLONE_APP_DISCUSSION_INTEGRATION_TESTING  # noqa
 | 
			
		||||
from datetime import datetime
 | 
			
		||||
from datetime import timezone
 | 
			
		||||
from dateutil import tz
 | 
			
		||||
from DateTime import DateTime
 | 
			
		||||
from plone.app.event.base import localized_now
 | 
			
		||||
from plone.app.event.base import default_timezone
 | 
			
		||||
from plone.app.testing import setRoles
 | 
			
		||||
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 getUtility
 | 
			
		||||
 | 
			
		||||
import time
 | 
			
		||||
import os
 | 
			
		||||
import unittest
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -147,10 +143,10 @@ class CommentIndexersTest(unittest.TestCase):
 | 
			
		||||
        comment.text = "Lorem ipsum dolor sit amet."
 | 
			
		||||
        comment.creator = "jim"
 | 
			
		||||
        comment.author_name = "Jim"
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        # Create date in CEST (ie not daylight savings = UTC+2)
 | 
			
		||||
        comment.creation_date = datetime(2006, 9, 17, 14, 18, 12).replace(tzinfo=tz.gettz("Europe/Berlin"))
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        # Create date in CET (ie daylight savings = UTC+1)
 | 
			
		||||
        comment.modification_date = datetime(2008, 3, 12, 7, 32, 52).replace(tzinfo=tz.gettz("Europe/Berlin"))
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user