refactor: update all_day detection logic
#2601
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Instead of using a particular resolution on an object, which differs between
datetime.dateanddatetime.datetimeobjects, operate on parent class ofdatetimeand convert alldtto timezone-awaredatetimevalues.This is also in accordance to the model field being a
DateTimeField, so we should always be passing the correctly-created object, instead of adatetime.date(), raisingreceived a naive datetimewarnings.Removes unused constants.
Closes
Closes #2415
Other notes, for fun.
The warnings stem from this little bitty function:
pythondotorg/events/utils.py
Lines 23 to 26 in 8a02c10
Since the ICS importer is often met with a string that looks like a date-only, like this one:
pythondotorg/events/tests/test_importer.py
Line 39 in 8a02c10
the returned type is
datetime.date, not adatetime.datetime.The change in
events/utils.pydrops the warnings, but fails two test cases:====================================================================== FAIL: test_import_event_excludes_ending_day_when_all_day_is_true (events.tests.test_importer.EventsImporterTestCase.test_import_event_excludes_ending_day_when_all_day_is_true) ---------------------------------------------------------------------- Traceback (most recent call last): File "/code/events/tests/test_importer.py", line 131, in test_import_event_excludes_ending_day_when_all_day_is_true self.assertTrue(all_day_event.next_or_previous_time.all_day) AssertionError: False is not true ====================================================================== FAIL: test_modified_event (events.tests.test_importer.EventsImporterTestCase.test_modified_event) ---------------------------------------------------------------------- Traceback (most recent call last): File "/code/events/tests/test_importer.py", line 63, in test_modified_event self.assertTrue(e.next_or_previous_time.all_day) AssertionError: False is not trueThese come from the
all_daycalculation over here:pythondotorg/events/importer.py
Lines 33 to 37 in 74e659c
which has now been updated.