-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extend specs to cover target_calendars
- Loading branch information
Showing
2 changed files
with
150 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,6 +67,124 @@ def request_callback(request): | |
assert payload['callback_url'] == 'http://www.example.com/callback' | ||
assert payload['redirect_urls']['completed_url'] == 'http://www.example.com/completed' | ||
|
||
assert request.headers['Authorization'] == "Bearer %s" % client.auth.client_secret | ||
|
||
return (200, {}, json.dumps(REAL_TIME_SCHEDULING_RESPONSE)) | ||
|
||
responses.add_callback( | ||
responses.POST, | ||
url='%s/%s/real_time_scheduling' % (settings.API_BASE_URL, settings.API_VERSION), | ||
callback=request_callback, | ||
content_type='application/json', | ||
) | ||
|
||
periods = ( | ||
{'start': "2017-01-03T09:00:00Z", 'end': "2017-01-03T18:00:00Z"}, | ||
{'start': "2017-01-04T09:00:00Z", 'end': "2017-01-04T18:00:00Z"} | ||
) | ||
example_participants = ({ | ||
'members': [ | ||
"acc_567236000909002", | ||
"acc_678347111010113", | ||
], | ||
}) | ||
|
||
availability = { | ||
'participants': example_participants, | ||
'available_periods': periods, | ||
'required_duration': 30, | ||
'start_interval': 30, | ||
'buffer': { | ||
'before': 30, | ||
'after': 45, | ||
}, | ||
} | ||
|
||
oauth = { | ||
'scope': 'foo', | ||
'redirect_uri': 'http://www.example.com', | ||
'state': 'bar' | ||
} | ||
|
||
minimum_notice = { | ||
'hours': 4 | ||
} | ||
|
||
callback_url = 'http://www.example.com/callback' | ||
|
||
redirect_urls = { | ||
'completed_url': 'http://www.example.com/completed' | ||
} | ||
|
||
result = client.real_time_scheduling(availability, oauth, TEST_EVENT, [], minimum_notice, callback_url=callback_url, redirect_urls=redirect_urls) | ||
assert result == REAL_TIME_SCHEDULING_RESPONSE | ||
|
||
|
||
@responses.activate | ||
def test_real_time_scheduling_with_target_calendars(client): | ||
"""Test Client.availability(). | ||
:param Client client: Client instance with test data. | ||
""" | ||
|
||
def request_callback(request): | ||
payload = json.loads(request.body) | ||
|
||
availability = payload['availability'] | ||
assert availability['required_duration'] == {'minutes': 30} | ||
assert availability['start_interval'] == {'minutes': 30} | ||
assert availability['buffer']['before'] == {'minutes': 30} | ||
assert availability['buffer']['after'] == {'minutes': 45} | ||
assert availability['available_periods'] == [ | ||
{'start': '2017-01-03T09:00:00Z', 'end': '2017-01-03T18:00:00Z'}, | ||
{'start': '2017-01-04T09:00:00Z', 'end': '2017-01-04T18:00:00Z'} | ||
] | ||
assert availability['participants'] == [ | ||
{ | ||
'required': 1, | ||
'members': [ | ||
{'sub': 'acc_567236000909002'}, | ||
{'sub': 'acc_678347111010113'} | ||
] | ||
} | ||
] | ||
|
||
assert payload['target_calendars'] == [ | ||
{ | ||
'sub': "acc_567236000909002", | ||
'calendar_id': "cal_ABCDEF2ubSrL4a7x_aBCDE@f7mZzc2ufdgAciZvA", | ||
'event': { | ||
'conferencing': { | ||
'profile_id': "integrated" | ||
} | ||
}, | ||
'attendee': { | ||
'email': "[email protected]", | ||
'display_name': "Marty McFly" | ||
} | ||
}, | ||
{ | ||
'sub': "acc_678347111010113", | ||
'calendar_id': "cal_HIJKLM2ubSrL0a2e_lFGHI@f5mZzc6ufdgBciYvZ", | ||
'event': { | ||
'conferencing': { | ||
'profile_id': "pro_ZYwjVpYOFWgx6eYl" | ||
} | ||
}, | ||
'attendee': { | ||
'email': "[email protected]", | ||
'display_name': "Doc Brown" | ||
} | ||
} | ||
] | ||
|
||
assert payload['event'] == TEST_EVENT | ||
assert payload['oauth'] == oauth | ||
assert payload['minimum_notice'] == {'hours': 4} | ||
|
||
assert payload['callback_url'] == 'http://www.example.com/callback' | ||
assert payload['redirect_urls']['completed_url'] == 'http://www.example.com/completed' | ||
|
||
assert payload['event_creation'] == "single" | ||
|
||
assert request.headers['Authorization'] == "Bearer %s" % client.auth.client_secret | ||
|
@@ -89,6 +207,7 @@ def request_callback(request): | |
"acc_567236000909002", | ||
"acc_678347111010113", | ||
], | ||
'required': 1 | ||
}) | ||
|
||
availability = { | ||
|
@@ -108,6 +227,35 @@ def request_callback(request): | |
'state': 'bar' | ||
} | ||
|
||
target_calendars = ( | ||
{ | ||
'sub': "acc_567236000909002", | ||
'calendar_id': "cal_ABCDEF2ubSrL4a7x_aBCDE@f7mZzc2ufdgAciZvA", | ||
'event': { | ||
'conferencing': { | ||
'profile_id': "integrated" | ||
} | ||
}, | ||
'attendee': { | ||
'email': "[email protected]", | ||
'display_name': "Marty McFly" | ||
} | ||
}, | ||
{ | ||
'sub': "acc_678347111010113", | ||
'calendar_id': "cal_HIJKLM2ubSrL0a2e_lFGHI@f5mZzc6ufdgBciYvZ", | ||
'event': { | ||
'conferencing': { | ||
'profile_id': "pro_ZYwjVpYOFWgx6eYl" | ||
} | ||
}, | ||
'attendee': { | ||
'email': "[email protected]", | ||
'display_name': "Doc Brown" | ||
} | ||
} | ||
) | ||
|
||
minimum_notice = { | ||
'hours': 4 | ||
} | ||
|
@@ -120,7 +268,7 @@ def request_callback(request): | |
|
||
event_creation = "single" | ||
|
||
result = client.real_time_scheduling(availability, oauth, TEST_EVENT, [], minimum_notice, callback_url=callback_url, redirect_urls=redirect_urls, event_creation=event_creation) | ||
result = client.real_time_scheduling(availability, oauth, TEST_EVENT, target_calendars, minimum_notice, callback_url=callback_url, redirect_urls=redirect_urls, event_creation=event_creation) | ||
assert result == REAL_TIME_SCHEDULING_RESPONSE | ||
|
||
|
||
|