Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
petrjasek committed Jul 16, 2024
1 parent bc7b47d commit 56e2e6e
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
50 changes: 50 additions & 0 deletions server/features/search_events.feature
Original file line number Diff line number Diff line change
Expand Up @@ -326,3 +326,53 @@ Feature: Event Search
]}
"""

@auth
Scenario: Filter by date using America/Toronto timezone
Given "events"
"""
[{
"guid": "all_day_multi",
"name": "all day event multiday",
"dates": {"start": "2024-07-14T00:00:00+0000", "end": "2024-07-16T00:00:00+0000", "all_day": true}
}, {
"guid": "all_day_single",
"name": "all day single day",
"dates": {"start": "2024-07-15T00:00:00+0000", "end": "2024-07-15T00:00:00+0000", "all_day": true}
}, {
"guid": "no_end_time_multi",
"name": "no end time multiday",
"dates": {"start": "2024-07-13T10:00:00+0000", "end": "2024-07-15T00:00:00+0000", "no_end_time": true}
}, {
"guid": "no_end_time_single",
"name": "no end time single day",
"dates": {"start": "2024-07-15T10:00:00+0000", "end": "2024-07-15T10:00:00+0000", "no_end_time": true}
}, {
"guid": "matching",
"name": "regular",
"dates": {"start": "2024-07-15T10:00:00+0000", "end": "2024-07-16T00:00:00+0000"}
},
{
"guid": "not matching",
"name": "not matching",
"dates": {"start": "2024-07-01T10:00:00+0000", "end": "2024-07-02T00:00:00+0000"}
}
]
"""
When we get "/events_planning_search?repo=events&only_future=false&time_zone=America/Toronto&start_date=2024-07-15T04:00:00"
Then we get list with 5 items
"""
{"_items": [
{"guid": "all_day_multi"},
{"guid": "all_day_single"},
{"guid": "no_end_time_multi"},
{"guid": "no_end_time_single"},
{"guid": "matching"}
]}
"""
When we get "/events_planning_search?repo=events&only_future=false&time_zone=America/Toronto&start_date=2024-07-16T04:00:00"
Then we get list with 1 items
"""
{"_items": [
{"guid": "all_day_multi"}
]}
"""
1 change: 1 addition & 0 deletions server/planning/search/queries/elastic.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ def field_range(query: ElasticRangeParams):
# so we first convert it to local timezone
# and then we take only date part of it
local_params = params.copy()
local_params.pop("time_zone", None)
for key in ("gt", "gte", "lt", "lte"):
if local_params.get(key) and "T" in local_params[key] and params.get("time_zone"):
tz = pytz.timezone(params["time_zone"])
Expand Down

0 comments on commit 56e2e6e

Please sign in to comment.