Skip to content

Commit

Permalink
Merging Main Before Release (#880)
Browse files Browse the repository at this point in the history
* Add multiple python versions to CI tests (#858)

* Add multiple python versions to CI tests

* Remove duplicate key

* Combine CI jobs

* Update ubuntu image and actually install Python versions

* Replace pyenv with apt-get to install python versions

* Remove sudo

* Remove get from 'apt-get'

* Update apt before attempting to install

* Add ppa/deadsnakes repository

* Add prereq

* Fix typo

* Add -y to install command

* Move -y to correct spot

* Add more -ys

* Add some echoes to debug

* Switch back to pyenv approach

* Remove tests from circleci config and move to new github actions config

Note: no caching yet, this is more of a proof of concept

* Split out Mac tests into seaparate file

* Set testing environmental variable separately

* First attempt to add depdendency cache

* Remove windows tests for now

* Fix circleci config

* Fix circleci for real this time

* Add tests on merging of PRs and update readme to show we do not support for Python 3.7

* Enable passing `identifiers` to ActionNetwork `upsert_person()` (#861)

* Enable passing `identifiers` to ActionNetwork upsert_person

* Remove unused arguments from method

self.get_page method doesn't exist and that method call doesn't return
anything. The return statement works fine as-is to return all tags and
handles pagination on its own.

* Include deprecated per_page argument for backwards compatibility

Emit a deprecation warning if this argument is used

* Include examples in docstring for `identifiers` argument

* Expand documentation on ActionNetwork identifiers

* Add pre-commit hook config to run flake8 and black on commit (#864)

Notes added to README on how to install and set up

* Add Events Helpers to PDI Connector (#865)

* add helpers to Events object

* stage docstring

* add docs

* linting

* fix typo + enforce validation

* add return docs

* add events tests

* use mock pdi

* jk

* mark live tests

* add alias

* drop unused imports

* change release number (#872)

* add release notes yml (#878)

---------

Co-authored-by: Shauna <[email protected]>
Co-authored-by: Austin Weisgrau <[email protected]>
Co-authored-by: sharinetmc <[email protected]>
  • Loading branch information
4 people authored Aug 29, 2023
1 parent f78297c commit 7ad3036
Show file tree
Hide file tree
Showing 4 changed files with 165 additions and 2 deletions.
22 changes: 22 additions & 0 deletions .github/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
changelog:
categories:
- title: New Features
labels:
- connector-update
- new-connector
- parsons-core
- title: Automated Testing
labels:
- testing
- title: Bug Fixes
labels:
- bug-fix
- title: Documentation
labels:
- documentation
# - title: New Contributors
# labels:
# -🎉-first-PR
- title: Other Changes
labels:
- "*"
81 changes: 80 additions & 1 deletion parsons/pdi/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def __init__(self):
self.calendars_url = self.base_url + "/calendars"
self.eventactivities_url = self.base_url + "/eventActivities"
self.activites_url = self.base_url + "/activities"
self.activityassignment_url = self.base_url + "/eventActivityAssignements"
self.activityassignment_url = self.base_url + "/eventActivityAssignments"

super().__init__()

Expand Down Expand Up @@ -506,3 +506,82 @@ def update_activity_assignment(
)

return response

def get_event_activity_assignments(self, start_date, end_date, expand, limit=None):
"""
Get a list of event activity assignments.
Relevant API docs:
https://api.bluevote.com/docs/index#/EventActivityAssignments
`Args`:
start_date: str
Earliest records to be returned in the API response
Per the API docs, use "YYYY-MM-DD" format
end_date: str
Latest records to be returned in the API response.
Per the API docs, use "YYYY-MM-DD" format
expand: bool
Parameter to determine if we return the list of shift assigments
expanded or not
limit: int
Specify limit to return (max=2000)
`Returns`:
Parsons Table with event activity assignment responses
"""

if limit and limit > 2000:
raise ValueError("Maximum allowed limit is 2000")

params = {"startDate": start_date, "endDate": end_date, "expand": expand}
return self._request(self.activityassignment_url, args=params, limit=limit)

def get_event_activities(self, start_date, end_date, limit=None):
"""
Get a list of event activities.
Relevant API docs:
https://api.bluevote.com/docs/index#!/EventActivities/EventActivities_GetAll
`Args`:
start_date: str
Earliest records to be returned in the API response
Per the API docs, use "YYYY-MM-DD" format
end_date: str
Latest records to be returned in the API response.
Per the API docs, use "YYYY-MM-DD" format
limit: int
Specify limit to return (max=2000)
`Returns`:
Parsons Table with event activity responses
"""

if limit and limit > 2000:
raise ValueError("Maximum allowed limit is 2000")

params = {"startDate": start_date, "endDate": end_date}
return self._request(self.eventactivities_url, args=params, limit=limit)

def get_calendars(self, limit=None):
"""
Gets a list of calendars.
Relevant API docs:
https://api.bluevote.com/docs/index#!/Calendars/Calendars_GetAll
`Args`:
limit: int
Specify limit to return (max=2000)
`Returns`:
Parsons Table object with id, name, description, and timeZone records
"""

if limit and limit > 2000:
raise ValueError("Maximum allowed limit is 2000")

return self._request(self.calendars_url, limit=limit)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def main():

setup(
name="parsons",
version="1.1.0",
version="1.2.0",
author="The Movement Cooperative",
author_email="[email protected]",
url="https://github.com/move-coop/parsons",
Expand Down
62 changes: 62 additions & 0 deletions test/test_pdi/test_events.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
from test.utils import mark_live_test
from parsons import Table


#####

START_DATE = "2020-01-01"
END_DATE = "2022-12-31"
EXPAND = True
LOWER_LIMIT = 1

# TODO: Invoke this, it should fail as 2000 is the max limit for
# all of the relevant events functions
UPPER_LIMIT = 2001


@mark_live_test
def test_get_calendars(live_pdi):
response = live_pdi.get_calendars()

assert type(response) == Table


@mark_live_test
def test_get_calendars_with_limit(live_pdi):
response = live_pdi.get_calendars(limit=LOWER_LIMIT)

assert response.num_rows == 1


@mark_live_test
def test_get_event_activities(live_pdi):
response = live_pdi.get_event_activities(start_date=START_DATE, end_date=END_DATE)

assert type(response) == Table


@mark_live_test
def test_get_event_activities_with_limit(live_pdi):
response = live_pdi.get_event_activities(
start_date=START_DATE, end_date=END_DATE, limit=LOWER_LIMIT
)

assert response.num_rows == 1


@mark_live_test
def test_get_event_activity_assignments(live_pdi):
response = live_pdi.get_event_activity_assignments(
start_date=START_DATE, end_date=END_DATE, expand=EXPAND
)

assert type(response) == Table


@mark_live_test
def test_get_event_activity_assignments_with_limit(live_pdi):
response = live_pdi.get_event_activity_assignments(
start_date=START_DATE, end_date=END_DATE, expand=EXPAND
)

assert response.num_rows == 1

0 comments on commit 7ad3036

Please sign in to comment.