def tearDownModule(): """ Cleans up toggl with all the unittest entries we just created. This relies on TimeEntryList and TimeEntry.delete. """ print("Removing toggl entries created by the test...") for entry in toggl.TimeEntryList(): if entry.get('description') is not None and entry.get('description').startswith('unittest_'): entry.delete()
def get_entries(start_date, end_date, client=None): finished = False start_search, end_search = start_date, end_date # TODO: This is a manual way to search through time entry list pages. Switch to reports API rather if client: projects = toggl.ProjectList() valid_project_ids = { project['id'] for project in projects if project.get('cid', None) == client['id'] } while not finished: search_list = toggl.TimeEntryList(start_search, end_search) max_date = None for toggl_entry in search_list: entry_end = toggl_entry.get('end') if entry_end > max_date: max_date = entry_end if not client or toggl_entry.get('pid') in valid_project_ids: yield toggl_entry if len(search_list.time_entries) < 1000: finished = True else: start_search = max_date + timedelta(seconds=1)
def setUp(self): self.list = toggl.TimeEntryList()
def find_time_entry(self, description): return toggl.TimeEntryList().reload().find_by_description(description)