def agenda( request: Request, db: Session = Depends(get_db), start_date: Optional[date] = None, end_date: Optional[date] = None, days: Optional[int] = None, ) -> _TemplateResponse: """Route for the agenda page, using dates range or exact amount of days.""" user_id = 1 # there is no user session yet, so I use user id- 1. start_date, end_date = calc_dates_range_for_agenda(start_date, end_date, days) events_objects = agenda_events.get_events_per_dates( db, user_id, start_date, end_date) events = defaultdict(list) for event_obj in events_objects: event_duration = agenda_events.get_time_delta_string( event_obj.start, event_obj.end) events[event_obj.start.date()].append((event_obj, event_duration)) return templates.TemplateResponse( "agenda.html", { "request": request, "events": events, "start_date": start_date, "end_date": end_date, })
def test_get_events_per_dates_failure(self, yesterday_event, session): events = get_events_per_dates( session=session, user_id=yesterday_event.owner_id, start=date.today(), end=date.today(), ) assert list(events) == []
def test_get_events_per_dates_success(self, today_event, session): events = get_events_per_dates( session=session, user_id=today_event.owner_id, start=today_event.start.date(), end=today_event.end.date(), ) assert list(events) == [today_event]