diff --git a/README.md b/README.md index f4d2dad..8372551 100644 --- a/README.md +++ b/README.md @@ -94,6 +94,10 @@ with ZoomClient('CLIENT_ID', 'CLIENT_SECRET', 'ACCOUNT_ID') as client: * client.user.get_by_email(...) * client.user.get_settings(...) * client.user.update_settings(...) +* client.user.add_assistants(...) +* client.user.delete_all_assistants(...) +* client.user.delete_assistant(...) +* client.user.list_assistants(...) * client.meeting.get(...) * client.meeting.end(...) diff --git a/tests/zoomus/components/user/test_add_assistants.py b/tests/zoomus/components/user/test_add_assistants.py new file mode 100644 index 0000000..e10fcc4 --- /dev/null +++ b/tests/zoomus/components/user/test_add_assistants.py @@ -0,0 +1,45 @@ +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(AddAssistantsV2TestCase)) + return suite + + +class AddAssistantsV2TestCase(unittest.TestCase): + def setUp(self): + self.component = components.user.UserComponentV2( + base_uri="http://foo.com", + config={ + "api_key": "KEY", + "api_secret": "SECRET", + "version": util.API_VERSION_2, + }, + ) + + @responses.activate + def test_can_add_assistants(self): + responses.add(responses.POST, "http://foo.com/users/ID/assistants") + response = self.component.add_assistants( + id="ID", assistants=[{"email": "foo@bar.com"}] + ) + self.assertEqual( + response.request.body, '{"assistants": [{"email": "foo@bar.com"}]}' + ) + + def test_requires_id(self): + with self.assertRaisesRegexp(ValueError, "'id' must be set"): + self.component.add_assistants(assistants=[{"email": "foo@bar.com"}]) + + def test_requires_assistants(self): + with self.assertRaisesRegexp(ValueError, "'assistants' must be set"): + self.component.add_assistants(id="ID") + + +if __name__ == "__main__": + unittest.main() diff --git a/tests/zoomus/components/user/test_delete_all_assistants.py b/tests/zoomus/components/user/test_delete_all_assistants.py new file mode 100644 index 0000000..fee08b6 --- /dev/null +++ b/tests/zoomus/components/user/test_delete_all_assistants.py @@ -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(DeleteAllAssistantsV2TestCase)) + return suite + + +class DeleteAllAssistantsV2TestCase(unittest.TestCase): + def setUp(self): + self.component = components.user.UserComponentV2( + base_uri="http://foo.com", + config={ + "api_key": "KEY", + "api_secret": "SECRET", + "version": util.API_VERSION_2, + }, + ) + + @responses.activate + def test_can_delete_all_assistants(self): + responses.add(responses.DELETE, "http://foo.com/users/ID/assistants") + response = self.component.delete_all_assistants(id="ID") + + def test_requires_id(self): + with self.assertRaisesRegexp(ValueError, "'id' must be set"): + self.component.delete_all_assistants() + + +if __name__ == "__main__": + unittest.main() diff --git a/tests/zoomus/components/user/test_delete_assistant.py b/tests/zoomus/components/user/test_delete_assistant.py new file mode 100644 index 0000000..3e664a3 --- /dev/null +++ b/tests/zoomus/components/user/test_delete_assistant.py @@ -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(DeleteAssistantV2TestCase)) + return suite + + +class DeleteAssistantV2TestCase(unittest.TestCase): + def setUp(self): + self.component = components.user.UserComponentV2( + base_uri="http://foo.com", + config={ + "api_key": "KEY", + "api_secret": "SECRET", + "version": util.API_VERSION_2, + }, + ) + + @responses.activate + def test_can_add_assistants(self): + responses.add(responses.DELETE, "http://foo.com/users/ID/assistants/ASSISTID") + response = self.component.delete_assistant(id="ID", assistant_id="ASSISTID") + + def test_requires_id(self): + with self.assertRaisesRegexp(ValueError, "'id' must be set"): + self.component.delete_assistant(assistant_id="ASSISTID") + + def test_requires_assistant_id(self): + with self.assertRaisesRegexp(ValueError, "'assistant_id' must be set"): + self.component.delete_assistant(id="ID") + + +if __name__ == "__main__": + unittest.main() diff --git a/tests/zoomus/components/user/test_list_assistants.py b/tests/zoomus/components/user/test_list_assistants.py new file mode 100644 index 0000000..cfb1f1d --- /dev/null +++ b/tests/zoomus/components/user/test_list_assistants.py @@ -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(ListAssistantV2TestCase)) + return suite + + +class ListAssistantV2TestCase(unittest.TestCase): + def setUp(self): + self.component = components.user.UserComponentV2( + base_uri="http://foo.com", + config={ + "api_key": "KEY", + "api_secret": "SECRET", + "version": util.API_VERSION_2, + }, + ) + + @responses.activate + def test_can_list_assistants(self): + responses.add(responses.GET, "http://foo.com/users/ID/assistants") + response = self.component.list_assistants(id="ID") + + def test_requires_id(self): + with self.assertRaisesRegexp(ValueError, "'id' must be set"): + self.component.list_assistants(assistant_id="ASSISTID") + + +if __name__ == "__main__": + unittest.main() diff --git a/tests/zoomus/test_util.py b/tests/zoomus/test_util.py index e8628ef..38561d5 100644 --- a/tests/zoomus/test_util.py +++ b/tests/zoomus/test_util.py @@ -706,7 +706,6 @@ def test_can_convert_datetime_to_str(self): class IsStrTypeTestCase(unittest.TestCase): - from sys import version_info def test_str_is_str_type(self): diff --git a/zoomus/components/user.py b/zoomus/components/user.py index 75f18c6..faf57ab 100644 --- a/zoomus/components/user.py +++ b/zoomus/components/user.py @@ -112,3 +112,30 @@ def get_settings(self, **kwargs): return self.get_request( "/users/{}/settings".format(kwargs.pop("id")), params=kwargs ) + + def add_assistants(self, **kwargs): + util.require_keys(kwargs, ["id", "assistants"]) + body = {"assistants": kwargs["assistants"]} + + return self.post_request( + "/users/{}/assistants".format(kwargs.pop("id")), data=kwargs + ) + + def list_assistants(self, **kwargs): + util.require_keys(kwargs, "id") + + return self.get_request("/users/{}/assistants".format(kwargs.pop("id"))) + + def delete_assistant(self, **kwargs): + util.require_keys(kwargs, ["id", "assistant_id"]) + + return self.delete_request( + "/users/{id}/assistants/{assistant_id}".format( + id=kwargs.pop("id"), assistant_id=kwargs["assistant_id"] + ) + ) + + def delete_all_assistants(self, **kwargs): + util.require_keys(kwargs, "id") + + return self.delete_request("/users/{}/assistants".format(kwargs.pop("id")))