Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set timezone for creation and modification dates of comments #204

Merged
merged 24 commits into from
Oct 24, 2022
Merged
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
16123e2
Set timezone for creation and modification dates of comments
instification Oct 18, 2022
42e5238
Update tests
instification Oct 18, 2022
9f34a7f
Add changelog
instification Oct 18, 2022
f1b753d
Update tests
instification Oct 18, 2022
d6bbff8
update conversation tests
instification Oct 18, 2022
45ef9a5
Fix syntax errors
instification Oct 18, 2022
fd1cfa8
Use local timezone when setting dates
instification Oct 21, 2022
103bd89
Use correct timezone when indexing comments
instification Oct 21, 2022
2506286
Create custom __getattribute__ method to return timezone aware dates …
instification Oct 21, 2022
c70abe2
Create a test for the custom getter to ensure timezones are being added
instification Oct 21, 2022
f0cd076
Update test_indexers to account for local timezones. Test across dayl…
instification Oct 21, 2022
9944796
Fix timezone tests
instification Oct 21, 2022
b28d6d1
Don't set the server timezone, seems to break other tests
instification Oct 21, 2022
194f2d9
Use configured portal timezone in tests
instification Oct 22, 2022
35b11a0
Prevent test failures when converting to timezone
instification Oct 22, 2022
2df8ff4
Try reindexing comment and increasing delta (in case of slow test cau…
instification Oct 22, 2022
0d64396
Don't convert time when adding timezone in getter. Refactor time comp…
instification Oct 23, 2022
2380bda
black/flake8
instification Oct 23, 2022
a069f49
Change timezone to America/Los_Angeles to expose DateTime exceptions
instification Oct 24, 2022
ab92def
Use plone.app.event.base.DT to convert datetime -> DateTime
instification Oct 24, 2022
a95e67b
Use py3 super syntax
instification Oct 24, 2022
a3818a4
Update changelog
instification Oct 24, 2022
c5f17dc
Bump version for linked plone.restapi test_statictime version check
instification Oct 24, 2022
aa38be3
Use correct date when indexing. Update comment indexes to use America…
instification Oct 24, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Don't set the server timezone, seems to break other tests
  • Loading branch information
instification committed Oct 21, 2022
commit b28d6d1f91a964d880089003e184147bff5b51b6
12 changes: 3 additions & 9 deletions plone/app/discussion/tests/test_indexers.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ def setUp(self):
workflow.doActionFor(self.portal.doc1, "publish")

# Change the timezone to europe to test timezones properly
os.environ['TZ'] = 'Europe/Berlin'
time.tzset()
reg_key = "plone.portal_timezone"
registry = getUtility(IRegistry)
registry[reg_key] = "Europe/Berlin"
Expand Down Expand Up @@ -140,25 +138,21 @@ def setUp(self):
# Add a comment. Note: in real life, we always create comments via the
# factory to allow different factories to be swapped in

# Change the timezone to europe to test timezones properly
os.environ['TZ'] = 'Europe/Berlin'
time.tzset()
# Get the default timezone from the portal
reg_key = "plone.portal_timezone"
registry = getUtility(IRegistry)
registry[reg_key] = "Europe/Berlin"
portal_timezone = tz.gettz(default_timezone())


comment = createObject("plone.Comment")
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).astimezone(portal_timezone)
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).astimezone(portal_timezone)
comment.modification_date = datetime(2008, 3, 12, 7, 32, 52).replace(tzinfo=tz.gettz("Europe/Berlin"))

self.comment_id = conversation.addComment(comment)
self.comment = comment.__of__(conversation)
Expand Down