Skip to content

Commit 7f2fba0

Browse files
Add room_type to RoomOptions and fix tests (#23)
* Add room_type to RoomOptions and add test * Fix linting errors * Update test * Fix tests * Pull openapi again
1 parent bbd2a7d commit 7f2fba0

14 files changed

+521
-35
lines changed

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
**/.venv

docker-compose-test.yaml

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,14 @@ services:
55
restart: on-failure
66
healthcheck:
77
test: >
8-
curl --fail -H "authorization: Bearer development" http://fishjam:5002/room || exit 1
8+
curl --fail-with-body -H "Authorization: Bearer 12345" http://fishjam:5002/admin/health
99
interval: 3s
1010
retries: 2
1111
timeout: 2s
1212
start_period: 30s
1313
environment:
1414
FJ_HOST: "fishjam:5002"
15-
FJ_INTEGRATED_TURN_IP: "${INTEGRATED_TURN_IP:-127.0.0.1}"
16-
FJ_INTEGRATED_TURN_LISTEN_IP: "0.0.0.0"
17-
FJ_INTEGRATED_TURN_PORT_RANGE: "50000-50050"
18-
FJ_INTEGRATED_TCP_TURN_PORT: "49999"
19-
FJ_SERVER_API_TOKEN: "development"
15+
FJ_ADMIN_TOKEN: "12345"
2016
FJ_PORT: 5002
2117
FJ_SECRET_KEY_BASE: "super-secret-key"
2218
FJ_SIP_IP: "127.0.0.1"
@@ -28,29 +24,24 @@ services:
2824
volumes:
2925
- ./tests/fixtures:/app/fishjam_resources/file_component_sources
3026

31-
test:
32-
container_name: test
33-
image: "cimg/python:${PYTHON_VERSION:-3.10}"
34-
command: sh -c "cd /app && \ poetry config virtualenvs.in-project false && \ poetry install --no-ansi && \ poetry run pytest -s"
35-
environment:
36-
DOCKER_TEST: "TRUE"
37-
ports:
38-
- "5000:5000"
39-
volumes:
40-
- .:/app
27+
fishjam-prep:
28+
image: curlimages/curl:8.12.1
29+
command: >
30+
curl --fail-with-body -H "Authorization: Bearer 12345" -XPOST http://fishjam:5002/admin/user --json '{"id": "testuser", "token": "development"}'
4131
depends_on:
4232
fishjam:
4333
condition: service_healthy
4434

45-
examples:
46-
container_name: examples
47-
image: "cimg/python:${PYTHON_VERSION:-3.10}"
48-
command: sh -c "cd /app && \ poetry config virtualenvs.in-project false && \ poetry cache clear pypi --all && \ poetry install --no-ansi && \ poetry run examples"
35+
test:
36+
container_name: test
37+
build:
38+
context: .
39+
dockerfile: tests/Dockerfile
40+
args:
41+
PYTHON_VERSION: ${PYTHON_VERSION:-3.10}
42+
command: poetry run pytest
4943
environment:
5044
DOCKER_TEST: "TRUE"
51-
CI_LIMIT: "10"
52-
volumes:
53-
- .:/app
5445
depends_on:
55-
fishjam:
56-
condition: service_healthy
46+
fishjam-prep:
47+
condition: service_completed_successfully

fishjam/_openapi_client/api/broadcaster/__init__.py

Whitespace-only changes.
Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
from http import HTTPStatus
2+
from typing import Any, Dict, Optional, Union
3+
4+
import httpx
5+
6+
from ... import errors
7+
from ...client import AuthenticatedClient, Client
8+
from ...models.broadcaster_verify_token_response import BroadcasterVerifyTokenResponse
9+
from ...models.error import Error
10+
from ...types import Response
11+
12+
13+
def _get_kwargs(
14+
token: str,
15+
) -> Dict[str, Any]:
16+
return {
17+
"method": "get",
18+
"url": "/broadcaster/verify/{token}".format(
19+
token=token,
20+
),
21+
}
22+
23+
24+
def _parse_response(
25+
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
26+
) -> Optional[Union[BroadcasterVerifyTokenResponse, Error]]:
27+
if response.status_code == HTTPStatus.CREATED:
28+
response_201 = BroadcasterVerifyTokenResponse.from_dict(response.json())
29+
30+
return response_201
31+
if response.status_code == HTTPStatus.UNAUTHORIZED:
32+
response_401 = Error.from_dict(response.json())
33+
34+
return response_401
35+
if client.raise_on_unexpected_status:
36+
raise errors.UnexpectedStatus(response.status_code, response.content)
37+
else:
38+
return None
39+
40+
41+
def _build_response(
42+
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
43+
) -> Response[Union[BroadcasterVerifyTokenResponse, Error]]:
44+
return Response(
45+
status_code=HTTPStatus(response.status_code),
46+
content=response.content,
47+
headers=response.headers,
48+
parsed=_parse_response(client=client, response=response),
49+
)
50+
51+
52+
def sync_detailed(
53+
token: str,
54+
*,
55+
client: Union[AuthenticatedClient, Client],
56+
) -> Response[Union[BroadcasterVerifyTokenResponse, Error]]:
57+
"""Verify token provided by broadcaster
58+
59+
Args:
60+
token (str):
61+
62+
Raises:
63+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
64+
httpx.TimeoutException: If the request takes longer than Client.timeout.
65+
66+
Returns:
67+
Response[Union[BroadcasterVerifyTokenResponse, Error]]
68+
"""
69+
70+
kwargs = _get_kwargs(
71+
token=token,
72+
)
73+
74+
response = client.get_httpx_client().request(
75+
**kwargs,
76+
)
77+
78+
return _build_response(client=client, response=response)
79+
80+
81+
def sync(
82+
token: str,
83+
*,
84+
client: Union[AuthenticatedClient, Client],
85+
) -> Optional[Union[BroadcasterVerifyTokenResponse, Error]]:
86+
"""Verify token provided by broadcaster
87+
88+
Args:
89+
token (str):
90+
91+
Raises:
92+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
93+
httpx.TimeoutException: If the request takes longer than Client.timeout.
94+
95+
Returns:
96+
Union[BroadcasterVerifyTokenResponse, Error]
97+
"""
98+
99+
return sync_detailed(
100+
token=token,
101+
client=client,
102+
).parsed
103+
104+
105+
async def asyncio_detailed(
106+
token: str,
107+
*,
108+
client: Union[AuthenticatedClient, Client],
109+
) -> Response[Union[BroadcasterVerifyTokenResponse, Error]]:
110+
"""Verify token provided by broadcaster
111+
112+
Args:
113+
token (str):
114+
115+
Raises:
116+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
117+
httpx.TimeoutException: If the request takes longer than Client.timeout.
118+
119+
Returns:
120+
Response[Union[BroadcasterVerifyTokenResponse, Error]]
121+
"""
122+
123+
kwargs = _get_kwargs(
124+
token=token,
125+
)
126+
127+
response = await client.get_async_httpx_client().request(**kwargs)
128+
129+
return _build_response(client=client, response=response)
130+
131+
132+
async def asyncio(
133+
token: str,
134+
*,
135+
client: Union[AuthenticatedClient, Client],
136+
) -> Optional[Union[BroadcasterVerifyTokenResponse, Error]]:
137+
"""Verify token provided by broadcaster
138+
139+
Args:
140+
token (str):
141+
142+
Raises:
143+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
144+
httpx.TimeoutException: If the request takes longer than Client.timeout.
145+
146+
Returns:
147+
Union[BroadcasterVerifyTokenResponse, Error]
148+
"""
149+
150+
return (
151+
await asyncio_detailed(
152+
token=token,
153+
client=client,
154+
)
155+
).parsed

fishjam/_openapi_client/api/viewer/__init__.py

Whitespace-only changes.
Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
from http import HTTPStatus
2+
from typing import Any, Dict, Optional, Union, cast
3+
4+
import httpx
5+
6+
from ... import errors
7+
from ...client import AuthenticatedClient, Client
8+
from ...models.error import Error
9+
from ...types import Response
10+
11+
12+
def _get_kwargs(
13+
room_id: str,
14+
) -> Dict[str, Any]:
15+
return {
16+
"method": "post",
17+
"url": "/room/{room_id}/viewer".format(
18+
room_id=room_id,
19+
),
20+
}
21+
22+
23+
def _parse_response(
24+
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
25+
) -> Optional[Union[Error, str]]:
26+
if response.status_code == HTTPStatus.CREATED:
27+
response_201 = cast(str, response.json())
28+
return response_201
29+
if response.status_code == HTTPStatus.BAD_REQUEST:
30+
response_400 = Error.from_dict(response.json())
31+
32+
return response_400
33+
if response.status_code == HTTPStatus.UNAUTHORIZED:
34+
response_401 = Error.from_dict(response.json())
35+
36+
return response_401
37+
if response.status_code == HTTPStatus.NOT_FOUND:
38+
response_404 = Error.from_dict(response.json())
39+
40+
return response_404
41+
if response.status_code == HTTPStatus.SERVICE_UNAVAILABLE:
42+
response_503 = Error.from_dict(response.json())
43+
44+
return response_503
45+
if client.raise_on_unexpected_status:
46+
raise errors.UnexpectedStatus(response.status_code, response.content)
47+
else:
48+
return None
49+
50+
51+
def _build_response(
52+
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
53+
) -> Response[Union[Error, str]]:
54+
return Response(
55+
status_code=HTTPStatus(response.status_code),
56+
content=response.content,
57+
headers=response.headers,
58+
parsed=_parse_response(client=client, response=response),
59+
)
60+
61+
62+
def sync_detailed(
63+
room_id: str,
64+
*,
65+
client: Union[AuthenticatedClient, Client],
66+
) -> Response[Union[Error, str]]:
67+
"""Generate token for single viewer
68+
69+
Args:
70+
room_id (str):
71+
72+
Raises:
73+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
74+
httpx.TimeoutException: If the request takes longer than Client.timeout.
75+
76+
Returns:
77+
Response[Union[Error, str]]
78+
"""
79+
80+
kwargs = _get_kwargs(
81+
room_id=room_id,
82+
)
83+
84+
response = client.get_httpx_client().request(
85+
**kwargs,
86+
)
87+
88+
return _build_response(client=client, response=response)
89+
90+
91+
def sync(
92+
room_id: str,
93+
*,
94+
client: Union[AuthenticatedClient, Client],
95+
) -> Optional[Union[Error, str]]:
96+
"""Generate token for single viewer
97+
98+
Args:
99+
room_id (str):
100+
101+
Raises:
102+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
103+
httpx.TimeoutException: If the request takes longer than Client.timeout.
104+
105+
Returns:
106+
Union[Error, str]
107+
"""
108+
109+
return sync_detailed(
110+
room_id=room_id,
111+
client=client,
112+
).parsed
113+
114+
115+
async def asyncio_detailed(
116+
room_id: str,
117+
*,
118+
client: Union[AuthenticatedClient, Client],
119+
) -> Response[Union[Error, str]]:
120+
"""Generate token for single viewer
121+
122+
Args:
123+
room_id (str):
124+
125+
Raises:
126+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
127+
httpx.TimeoutException: If the request takes longer than Client.timeout.
128+
129+
Returns:
130+
Response[Union[Error, str]]
131+
"""
132+
133+
kwargs = _get_kwargs(
134+
room_id=room_id,
135+
)
136+
137+
response = await client.get_async_httpx_client().request(**kwargs)
138+
139+
return _build_response(client=client, response=response)
140+
141+
142+
async def asyncio(
143+
room_id: str,
144+
*,
145+
client: Union[AuthenticatedClient, Client],
146+
) -> Optional[Union[Error, str]]:
147+
"""Generate token for single viewer
148+
149+
Args:
150+
room_id (str):
151+
152+
Raises:
153+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
154+
httpx.TimeoutException: If the request takes longer than Client.timeout.
155+
156+
Returns:
157+
Union[Error, str]
158+
"""
159+
160+
return (
161+
await asyncio_detailed(
162+
room_id=room_id,
163+
client=client,
164+
)
165+
).parsed

0 commit comments

Comments
 (0)