-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from cern-vc/develop
🚀 RELEASE: Bump to v0.2.3
- Loading branch information
Showing
11 changed files
with
247 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,55 @@ | ||
{ | ||
"terminal.integrated.env.osx": { | ||
"PYTHONPATH": "${workspaceFolder}" | ||
}, | ||
"terminal.integrated.env.linux": { | ||
"PYTHONPATH": "${workspaceFolder}" | ||
}, | ||
"python.analysis.autoSearchPaths": true, | ||
"python.analysis.autoImportCompletions": true, | ||
"python.analysis.indexing": true, | ||
"python.analysis.packageIndexDepths": [ | ||
{ | ||
"name": "pytest", | ||
"depth": 2 | ||
}, | ||
{ | ||
"name": "unittest", | ||
"depth": 2 | ||
} | ||
], | ||
"python.analysis.typeCheckingMode": "basic", | ||
"python.analysis.inlayHints.callArgumentNames": true, | ||
"python.analysis.inlayHints.variableTypes": true, | ||
"python.analysis.inlayHints.functionReturnTypes": true, | ||
"editor.formatOnSave": true, | ||
"python.linting.enabled": true, | ||
"python.linting.pylintEnabled": true, | ||
"python.linting.pylintPath": "venv/bin/pylint", | ||
"terminal.integrated.env.osx": { | ||
"PYTHONPATH": "${workspaceFolder}" | ||
"isort.check": true, | ||
"isort.args": [ | ||
"--profile", | ||
"black" | ||
], | ||
"python.testing.pytestEnabled": true, | ||
"python.testing.pytestArgs": [ | ||
"tests", | ||
"-vv", | ||
"--cov=app", | ||
"--cov-report=term-missing", | ||
"--cov-report=html" | ||
], | ||
"[python]": { | ||
"editor.codeActionsOnSave": { | ||
"source.organizeImports": true | ||
}, | ||
"editor.defaultFormatter": "ms-python.black-formatter", | ||
"editor.codeLens": true | ||
}, | ||
"search.exclude": { | ||
"**/dist": true, | ||
"**/venv": true | ||
"**/.venv": true | ||
}, | ||
"[python]": { | ||
"editor.defaultFormatter": "ms-python.black-formatter" | ||
} | ||
} | ||
"files.exclude": { | ||
"**/__pycache__": true, | ||
"**/.pytest_cache": true, | ||
"**/.mypy*": true, | ||
}, | ||
} |
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import logging | ||
|
||
from zoom_python_client.client_components.rooms.rooms_component import ( | ||
RoomsListDict, | ||
RoomType, | ||
) | ||
from zoom_python_client.utils.logger import setup_logs | ||
from zoom_python_client.zoom_api_client import ZoomApiClient | ||
|
||
logger = setup_logs(log_level=logging.INFO) | ||
|
||
zoom_client = ZoomApiClient.init_from_dotenv(use_path=".") | ||
|
||
parameters = RoomsListDict( | ||
type=RoomType.ZOOM_ROOM, | ||
) | ||
|
||
rooms = zoom_client.rooms.get_rooms(parameters) | ||
|
||
logger.info("Found %d rooms:", len(rooms["rooms"])) | ||
for room in rooms["rooms"]: | ||
room_profile = zoom_client.rooms.get_room(room["id"]) | ||
|
||
calendar_ressource = zoom_client.calendars.get_calendar_resource_by_ressource_id( | ||
room_profile["basic"]["calendar_resource_id"] | ||
) | ||
|
||
logger.info( | ||
"\t- Microsoft user id for room %s is %s", | ||
room["name"], | ||
calendar_ressource["calendar_resource_email"], | ||
) |
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import logging | ||
|
||
from zoom_python_client.utils.logger import setup_logs | ||
from zoom_python_client.zoom_api_client import ZoomApiClient | ||
|
||
logger = setup_logs(log_level=logging.DEBUG) | ||
|
||
zoom_client = ZoomApiClient.init_from_dotenv(use_path=".") | ||
|
||
|
||
result = zoom_client.calendars.list_calendar_resources() | ||
|
||
logger.info("Found %d calendars:", len(result)) | ||
|
||
for calendar_ressources in result: | ||
logger.info( | ||
"\t- %s - %s - %s", | ||
calendar_ressources["calendar_resource_name"], | ||
calendar_ressources["calendar_resource_id"], | ||
calendar_ressources["calendar_resource_email"], | ||
) |
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
Empty file.
92 changes: 92 additions & 0 deletions
92
tests/zoom_python_client/client_components/calendars/test_calendars_component.py
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 |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import pytest | ||
import responses | ||
|
||
from tests.zoom_python_client.base_test_case import TestCaseWithAuth | ||
from zoom_python_client.client_components.calendars.calendars_component import ( | ||
CalendarsComponent, | ||
) | ||
from zoom_python_client.zoom_api_client import ZoomApiClient | ||
|
||
|
||
class TestCalendarsComponent(TestCaseWithAuth): | ||
def setUp(self): | ||
super().setUp() | ||
zoom_client = ZoomApiClient("aaa", "bbb", "ccc", "http://localhost") | ||
self.calendars_component = CalendarsComponent(zoom_client) | ||
|
||
@responses.activate | ||
def test_list_calendar_services(self): | ||
responses.add( | ||
responses.GET, | ||
"http://localhost/rooms/calendar/services", | ||
json={"response": "ok"}, | ||
status=200, | ||
) | ||
calendar_services = self.calendars_component.list_calendar_services() | ||
assert calendar_services == {"response": "ok"} | ||
|
||
@responses.activate | ||
def test_list_calendar_resources(self): | ||
responses.add( | ||
responses.GET, | ||
"http://localhost/rooms/calendar/services", | ||
json={"calendar_services": [{"calendar_service_id": "12345"}]}, | ||
status=200, | ||
) | ||
responses.add( | ||
responses.GET, | ||
"http://localhost/rooms/calendar/services/12345/resources", | ||
json={"calendar_resources": [{"calendar_resource_id": "12345"}]}, | ||
status=200, | ||
) | ||
calendar_resources = self.calendars_component.list_calendar_resources() | ||
assert calendar_resources == [{"calendar_resource_id": "12345"}] | ||
|
||
@responses.activate | ||
def test_list_calendar_resources_by_service_id(self): | ||
responses.add( | ||
responses.GET, | ||
"http://localhost/rooms/calendar/services/12345/resources", | ||
json={"response": "ok"}, | ||
status=200, | ||
) | ||
calendar_resources = ( | ||
self.calendars_component.list_calendar_resources_by_service_id("12345") | ||
) | ||
assert calendar_resources == {"response": "ok"} | ||
|
||
@responses.activate | ||
def test_get_calendar_resource_by_ressource_id(self): | ||
responses.add( | ||
responses.GET, | ||
"http://localhost/rooms/calendar/services", | ||
json={"calendar_services": [{"calendar_service_id": "12345"}]}, | ||
status=200, | ||
) | ||
responses.add( | ||
responses.GET, | ||
"http://localhost/rooms/calendar/services/12345/resources", | ||
json={"calendar_resources": [{"calendar_resource_id": "12345"}]}, | ||
status=200, | ||
) | ||
calendar_resource = ( | ||
self.calendars_component.get_calendar_resource_by_ressource_id("12345") | ||
) | ||
assert calendar_resource == {"calendar_resource_id": "12345"} | ||
|
||
@responses.activate | ||
def test_get_calendar_resource_by_ressource_id_not_found(self): | ||
responses.add( | ||
responses.GET, | ||
"http://localhost/rooms/calendar/services", | ||
json={"calendar_services": [{"calendar_service_id": "12345"}]}, | ||
status=200, | ||
) | ||
responses.add( | ||
responses.GET, | ||
"http://localhost/rooms/calendar/services/12345/resources", | ||
json={"calendar_resources": [{"calendar_resource_id": "12345"}]}, | ||
status=200, | ||
) | ||
with pytest.raises(ValueError): | ||
self.calendars_component.get_calendar_resource_by_ressource_id("123456") |
Empty file.
42 changes: 42 additions & 0 deletions
42
zoom_python_client/client_components/calendars/calendars_component.py
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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from typing import Any | ||
|
||
from zoom_python_client.zoom_client_interface import ZoomClientInterface | ||
|
||
|
||
class CalendarsComponent: | ||
def __init__(self, client: ZoomClientInterface) -> None: | ||
self.client = client | ||
|
||
def list_calendar_services(self) -> dict: | ||
api_path = "/rooms/calendar/services" | ||
response = self.client.make_get_request(api_path) | ||
result = response.json() | ||
return result | ||
|
||
def list_calendar_resources(self) -> list[Any]: | ||
calendar_services = self.list_calendar_services() | ||
calendar_service_ids = [ | ||
calendar_service["calendar_service_id"] | ||
for calendar_service in calendar_services["calendar_services"] | ||
] | ||
calendar_resources = [] | ||
for calendar_service_id in calendar_service_ids: | ||
res = self.list_calendar_resources_by_service_id(calendar_service_id) | ||
for resource in res["calendar_resources"]: | ||
calendar_resources.append(resource) | ||
|
||
return calendar_resources | ||
|
||
def list_calendar_resources_by_service_id(self, calendar_service_id: str) -> dict: | ||
api_path = f"/rooms/calendar/services/{calendar_service_id}/resources" | ||
response = self.client.make_get_request(api_path) | ||
result = response.json() | ||
return result | ||
|
||
def get_calendar_resource_by_ressource_id(self, resource_id: str) -> dict: | ||
all_ressources = self.list_calendar_resources() | ||
for resource in all_ressources: | ||
if resource["calendar_resource_id"] == resource_id: | ||
return resource | ||
|
||
raise ValueError(f"Resource with id {resource_id} not found") |
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