-
Notifications
You must be signed in to change notification settings - Fork 129
Polls #179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Polls #179
Changes from all commits
5d7db6f
d4584ee
410994a
935e9f5
e46bf54
fa5805f
ac412e4
920448a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| import datetime | ||
| import unittest | ||
|
|
||
| from zoomus import components, util | ||
| import responses | ||
|
|
||
|
|
||
| def suite(): | ||
| """Define all the tests of the module.""" | ||
| suite = unittest.TestSuite() | ||
| suite.addTest(unittest.makeSuite(AddRegistrantV2TestCase)) | ||
| return suite | ||
|
|
||
|
|
||
| class AddRegistrantV2TestCase(unittest.TestCase): | ||
| def setUp(self): | ||
| self.component = components.meeting.MeetingComponentV2( | ||
| base_uri="http://foo.com", | ||
| config={ | ||
| "api_key": "KEY", | ||
| "api_secret": "SECRET", | ||
| "version": util.API_VERSION_2, | ||
| }, | ||
| ) | ||
|
|
||
| @responses.activate | ||
| def test_can_add_registrant(self): | ||
| responses.add( | ||
| responses.POST, "http://foo.com/meetings/ID/registrants", | ||
| ) | ||
| response = self.component.add_registrant(id="ID", email="EMAIL", last_name="LAST_NAME", first_name="FIRST_NAME") | ||
| self.assertEqual( | ||
| response.request.body, '{"id": "ID", "email": "TOPIC", "last_name": "LAST_NAME", "first_name": "FIRST_NAME"}' | ||
| ) | ||
|
|
||
| def test_requires_meeting_id(self): | ||
| with self.assertRaisesRegexp(ValueError, "'id' must be set"): | ||
| self.component.add_registrant() | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| unittest.main() |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| import unittest | ||
|
|
||
| from zoomus import components, util | ||
| import responses | ||
|
|
||
|
|
||
| def suite(): | ||
| """Define all the tests of the module.""" | ||
| suite = unittest.TestSuite() | ||
| suite.addTest(unittest.makeSuite(ListRegistrantsV2TestCase)) | ||
| return suite | ||
|
|
||
|
|
||
| class ListRegistrantsV2TestCase(unittest.TestCase): | ||
| def setUp(self): | ||
| self.component = components.meeting.MeetingComponentV2( | ||
| base_uri="http://foo.com", | ||
| config={ | ||
| "api_key": "KEY", | ||
| "api_secret": "SECRET", | ||
| "version": util.API_VERSION_2, | ||
| }, | ||
| ) | ||
|
|
||
| @responses.activate | ||
| def test_can_list_registrants(self): | ||
| responses.add(responses.GET, "http://foo.com/meetings/ID") | ||
| self.component.list_registrants(id="ID") | ||
|
|
||
| def test_requires_id(self): | ||
| with self.assertRaisesRegexp(ValueError, "'id' must be set"): | ||
| self.component.list_registrants() | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| unittest.main() | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| from datetime import datetime | ||
| import unittest | ||
|
|
||
| from zoomus import components | ||
| import responses | ||
|
|
||
|
|
||
| def suite(): | ||
| """Define all the tests of the module.""" | ||
| suite = unittest.TestSuite() | ||
| suite.addTest(unittest.makeSuite(AddPanelistsV2TestCase)) | ||
| return suite | ||
|
|
||
|
|
||
| class AddPanelistsV2TestCase(unittest.TestCase): | ||
| def setUp(self): | ||
| self.component = components.webinar.WebinarComponentV2( | ||
| base_uri="http://foo.com", | ||
| config={ | ||
| "api_key": "KEY", | ||
| "api_secret": "SECRET", | ||
| "version": util.API_VERSION_2, | ||
| }, | ||
| ) | ||
|
|
||
| @responses.activate | ||
| def test_can_add_panelists(self): | ||
| responses.add( | ||
| responses.POST, "http://foo.com/webinar/ID/panelists", | ||
| ) | ||
| response = self.component.add_panelists(panelists=[{"name": "Mary", "email": "maryjkdfdsgfshdgf@jdfdkjdglfk.jkfgdj"}]) | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you make this a more human readable email? Maybe |
||
| self.assertEqual( | ||
| response.request.body, '{panelists: [{"name": "Mary", "email": "maryjkdfdsgfshdgf@jdfdkjdglfk.jkfgdj"}]}' | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See above |
||
| ) | ||
|
|
||
| def test_requires_panelists(self): | ||
| with self.assertRaisesRegexp(ValueError, "'panelists' must be set"): | ||
| self.component.add_panelists() | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| unittest.main() | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| import unittest | ||
|
|
||
| from zoomus import components, util | ||
| import responses | ||
|
|
||
| def suite(): | ||
| """Define all the tests of the module.""" | ||
| suite = unittest.TestSuite() | ||
| suite.addTest(unittest.makeSuite(DeleteV2TestCase)) | ||
| return suite | ||
|
|
||
|
|
||
| class DeleteV2TestCase(unittest.TestCase): | ||
| def setUp(self): | ||
| self.component = components.meeting.MeetingComponentV2( | ||
| base_uri="http://foo.com", | ||
| config={ | ||
| "api_key": "KEY", | ||
| "api_secret": "SECRET", | ||
| "version": util.API_VERSION_2, | ||
| }, | ||
| ) | ||
|
|
||
| @responses.activate | ||
| def test_can_delete_panelists(self): | ||
| responses.add( | ||
| responses.POST, "http://foo.com/webinar/ID/panelists", | ||
| ) | ||
| response = self.component.delete_panelists(panelists=[{"name": "Mary", "email": "maryjkdfdsgfshdgf@jdfdkjdglfk.jkfgdj"}]) | ||
| self.assertEqual( | ||
| response.request.body, '{panelists: [{"name": "Mary", "email": "maryjkdfdsgfshdgf@jdfdkjdglfk.jkfgdj"}]}' | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See previous comment regarding email |
||
| ) | ||
|
|
||
| def test_requires_panelists(self): | ||
| with self.assertRaisesRegexp(ValueError, "'panelists' must be set"): | ||
| self.component.delete_panelists() | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| unittest.main() | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| from datetime import datetime | ||
| import unittest | ||
|
|
||
| from zoomus import components | ||
| import responses | ||
|
|
||
|
|
||
| def suite(): | ||
| """Define all the tests of the module.""" | ||
| suite = unittest.TestSuite() | ||
| suite.addTest(unittest.makeSuite(ListPanelistsV2TestCase)) | ||
| return suite | ||
|
|
||
|
|
||
| class ListPanelistsV2TestCase(unittest.TestCase): | ||
| def setUp(self): | ||
| self.component = components.webinar.WebinarComponentV2( | ||
| base_uri="http://foo.com", config={"api_key": "KEY", "api_secret": "SECRET"} | ||
| ) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| unittest.main() |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| """Zoom.us REST API Python Client -- Recording component""" | ||
| from zoomus import util | ||
| from zoomus.components import base | ||
|
|
||
|
|
||
| class PollComponentV2(base.BaseComponent): | ||
| def __init__(self, *args, **kwargs): | ||
| util.require_keys(kwargs, "type") | ||
| self.type = kwargs.get('type') | ||
| super().__init__(*args, **kwargs) | ||
|
|
||
| def list(self, **kwargs): | ||
| util.require_keys(kwargs, "id") | ||
| return self.get_request( | ||
| "/{}/{}/polls".format( | ||
| self.type, kwargs.get("id") | ||
| ) | ||
| ) | ||
|
|
||
| def create(self, **kwargs): | ||
| util.require_keys(kwargs, "id") | ||
| util.require_keys(kwargs, "data") | ||
| return self.post_request( | ||
| "/{}/{}/polls".format( | ||
| self.type, kwargs.get('id') | ||
| ), | ||
| data=kwargs.get('data') | ||
| ) | ||
|
|
||
| def get(self, **kwargs): | ||
| util.require_keys(kwargs, "id") | ||
| util.require_keys(kwargs, "poll_id") | ||
| return self.get_request( | ||
| "/{}/{kwargs.get('id')}/polls/{}".format( | ||
| self.type, kwargs.get('poll_id') | ||
| ) | ||
| ) | ||
|
|
||
| def update(self, **kwargs): | ||
| util.require_keys(kwargs, "id") | ||
| util.require_keys(kwargs, "poll_id") | ||
| util.require_keys(kwargs, "data") | ||
| return self.patch_request( | ||
| "/{}/{kwargs.get('id')}/polls/{}".format( | ||
| self.type, kwargs.get('poll_id') | ||
| ), | ||
| data=kwargs.get('data') | ||
| ) | ||
|
|
||
| def delete(self, **kwargs): | ||
| util.require_keys(kwargs, "id") | ||
| util.require_keys(kwargs, "poll_id") | ||
| return self.delete_request( | ||
| "/{}/{kwargs.get('id')}/polls/{}".format( | ||
| self.type, kwargs.get('poll_id') | ||
| ) | ||
| ) | ||
|
|
||
| class Meta: | ||
| abstract = True | ||
|
|
||
|
|
||
| class WebinarPollComponentV2(PollComponentV2): | ||
| def __init__(self, *args, **kwargs): | ||
| kwargs['type'] = 'webinars' | ||
| super().__init__(*args, **kwargs) | ||
|
|
||
|
|
||
| class MeetingsPollComponentV2(PollComponentV2): | ||
| def __init__(self, *args, **kwargs): | ||
| kwargs['type'] = 'meetings' | ||
| super().__init__(*args, **kwargs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you run
blackto check for formatting? Looks like some files are missing a newline at the end.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vishnuku