Skip to content
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

Fix code style and linting errors #223

Merged
merged 7 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/admin/webapp-config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Full configuration
"locale": "en", // DEPRECTATED, alias of defaultLocale
"defaultLocale": "en",
"locales": ["en", "de", "pt_BR"], // keep this empty to disable user-choosable locale. Order of this array is dropdown order
"dateLocale": "en-ie",
"date_locale": "en-ie",
"timetravelTo": "2020-08-26T06:49:28.975Z", // forces local time to always be this (for schedule demo purposes ONLY)
// if no token is found in URL hash redirect to given authentication URL.
// used together with an external server which generates JW tokens based e.g. on user login and password
Expand Down
3 changes: 2 additions & 1 deletion server/tests/api/test_rooms.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
@pytest.mark.django_db
def test_room_list(client, world):
r = client.get(
"/api/v1/worlds/sample/rooms/", HTTP_AUTHORIZATION=get_token_header(world)
"/api/v1/worlds/sample/rooms/",
HTTP_AUTHORIZATION=get_token_header(world),
)
assert r.status_code == 200
assert r.data["count"] == 8
Expand Down
4 changes: 3 additions & 1 deletion server/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ async def clear_redis():
@pytest.fixture(autouse=True)
async def bbb_server():
await database_sync_to_async(BBBServer.objects.create)(
url="https://video1.pretix.eu/bigbluebutton/", secret="bogussecret", active=True
url="https://video1.pretix.eu/bigbluebutton/",
secret="bogussecret",
active=True,
)


Expand Down
10 changes: 8 additions & 2 deletions server/tests/consumers/test_connection_drop.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ async def test_remote_reload():
try:
await sync_to_async(call_command)("connections", "force_reload", "*")

assert ["connection.reload", {}] == await communicator.receive_json_from()
assert [
"connection.reload",
{},
] == await communicator.receive_json_from()
finally:
await communicator.disconnect()

Expand All @@ -52,6 +55,9 @@ async def test_remote_reload_staggered():
"connections", "force_reload", "--interval", "20", "*"
)

assert ["connection.reload", {}] == await communicator.receive_json_from()
assert [
"connection.reload",
{},
] == await communicator.receive_json_from()
finally:
await communicator.disconnect()
4 changes: 3 additions & 1 deletion server/tests/core/test_user_deletion.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ def test_delete_user(world, chat_room):
should_be_deleted_after_u1_is_deleted = []

bbb_server = BBBServer.objects.create(
url="https://video1.pretix.eu/bigbluebutton/", secret="bogussecret", active=True
url="https://video1.pretix.eu/bigbluebutton/",
secret="bogussecret",
active=True,
)
bbbcall = BBBCall.objects.create(server=bbb_server, world=world)
bbbcall.invited_members.add(u1)
Expand Down
13 changes: 9 additions & 4 deletions server/tests/live/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,6 @@ async def test_update_user():
@pytest.mark.asyncio
@pytest.mark.django_db
async def test_wrong_user_command():

async with world_communicator() as c:
await c.send_json_to(["authenticate", {"client_id": 4}])
response = await c.receive_json_from()
Expand Down Expand Up @@ -658,7 +657,10 @@ async def test_delete_user(world):
response = await c_admin.receive_json_from()
assert response[0] == "error"

assert ["connection.reload", {}] == await c_user.receive_json_from()
assert [
"connection.reload",
{},
] == await c_user.receive_json_from()
assert {"type": "websocket.close"} == await c_user.receive_output(timeout=3)

# New connect will be an entirely new user
Expand Down Expand Up @@ -690,7 +692,10 @@ async def test_ban_user(world):
response = await c_admin.receive_json_from()
assert response[0] == "error"

assert ["connection.reload", {}] == await c_user.receive_json_from()
assert [
"connection.reload",
{},
] == await c_user.receive_json_from()
assert {"type": "websocket.close"} == await c_user.receive_output(timeout=3)

async with world_communicator() as c_user:
Expand Down Expand Up @@ -1072,4 +1077,4 @@ async def test_anonymous_invite(client, world, stream_room, bbb_room):
"room:question.ask",
"room:poll.vote",
"room:poll.read",
}
}
5 changes: 4 additions & 1 deletion server/tests/live/test_bigbluebutton.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,10 @@ async def test_bbb_down(bbb_room):
async with world_communicator(named=True) as c:
await c.send_json_to(["bbb.room_url", 123, {"room": str(bbb_room.id)}])

m.get(re.compile(r"^https://video1.pretix.eu/bigbluebutton.*$"), status=500)
m.get(
re.compile(r"^https://video1.pretix.eu/bigbluebutton.*$"),
status=500,
)

response = await c.receive_json_from()
assert response[0] == "error"
Expand Down
60 changes: 45 additions & 15 deletions server/tests/live/test_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,7 @@ async def test_join_volatile_based_on_room_config(volatile_chat_room, chat_room,
response = await c2.receive_json_from()
assert response == [
"chat.channels",
{
"channels": [
{"id": str(chat_room.channel.id), "unread_pointer": 0}
]
},
{"channels": [{"id": str(chat_room.channel.id), "unread_pointer": 0}]},
]


Expand All @@ -176,7 +172,10 @@ async def test_join_convert_volatile_to_persistent(volatile_chat_room, world):
[
"chat.join",
123,
{"channel": str(volatile_chat_room.channel.id), "volatile": False},
{
"channel": str(volatile_chat_room.channel.id),
"volatile": False,
},
]
)
response = await c.receive_json_from()
Expand Down Expand Up @@ -208,7 +207,10 @@ async def test_join_convert_volatile_to_persistent_require_moderator(
[
"chat.join",
123,
{"channel": str(volatile_chat_room.channel.id), "volatile": False},
{
"channel": str(volatile_chat_room.channel.id),
"volatile": False,
},
]
)
response = await c.receive_json_from()
Expand All @@ -225,7 +227,11 @@ async def test_join_without_name(chat_room):
async with world_communicator(named=False) as c:
await c.send_json_to(["chat.join", 123, {"channel": str(chat_room.channel.id)}])
response = await c.receive_json_from()
assert response == ["error", 123, {"code": "channel.join.missing_profile"}]
assert response == [
"error",
123,
{"code": "channel.join.missing_profile"},
]


@pytest.mark.asyncio
Expand Down Expand Up @@ -378,7 +384,11 @@ async def test_unsupported_event_type(chat_room):
]
)
response = await c1.receive_json_from()
assert response == ["error", 123, {"code": "chat.unsupported_event_type"}]
assert response == [
"error",
123,
{"code": "chat.unsupported_event_type"},
]


@pytest.mark.asyncio
Expand All @@ -402,7 +412,11 @@ async def test_unsupported_content_type(chat_room):
]
)
response = await c1.receive_json_from()
assert response == ["error", 123, {"code": "chat.unsupported_content_type"}]
assert response == [
"error",
123,
{"code": "chat.unsupported_content_type"},
]


@pytest.mark.asyncio
Expand Down Expand Up @@ -444,7 +458,11 @@ async def test_send_empty(chat_room):
},
]
)
assert await c1.receive_json_from() == ["error", 123, {"code": "chat.empty"}]
assert await c1.receive_json_from() == [
"error",
123,
{"code": "chat.empty"},
]


@pytest.mark.asyncio
Expand Down Expand Up @@ -972,7 +990,11 @@ async def test_last_disconnect_is_leave_in_volatile_channel(world, volatile_chat
async with world_communicator(client_id=client_id) as c2:
async with world_communicator(client_id=client_id, named=False) as c3:
await c1.send_json_to(
["chat.join", 123, {"channel": str(volatile_chat_room.channel.id)}]
[
"chat.join",
123,
{"channel": str(volatile_chat_room.channel.id)},
]
)
response = await c1.receive_json_from()
assert response == [
Expand All @@ -987,7 +1009,11 @@ async def test_last_disconnect_is_leave_in_volatile_channel(world, volatile_chat
]

await c2.send_json_to(
["chat.join", 124, {"channel": str(volatile_chat_room.channel.id)}]
[
"chat.join",
124,
{"channel": str(volatile_chat_room.channel.id)},
]
)
response = await c2.receive_json_from()
assert response[0] == "success"
Expand All @@ -1000,7 +1026,11 @@ async def test_last_disconnect_is_leave_in_volatile_channel(world, volatile_chat
assert response == ["chat.channels", {"channels": []}]

await c3.send_json_to(
["chat.join", 125, {"channel": str(volatile_chat_room.channel.id)}]
[
"chat.join",
125,
{"channel": str(volatile_chat_room.channel.id)},
]
)
response = await c3.receive_json_from()
assert response[0] == "success"
Expand Down Expand Up @@ -1323,4 +1353,4 @@ async def test_force_join_after_login(world, chat_room):
# Some asyncio test weirdness, I don't get why
r = await c2.receive_json_from()
assert r[0] == "chat.channels"
assert channel_id in [c["id"] for c in r[1]["channels"]]
assert channel_id in [c["id"] for c in r[1]["channels"]]
1 change: 0 additions & 1 deletion server/tests/live/test_chat_direct.py
Original file line number Diff line number Diff line change
Expand Up @@ -995,4 +995,3 @@ async def test_notification_sync_read_state_across_clients(world):
response = await c2.receive_json_from()
assert response[0] == "authenticated"
assert response[1]["chat.notification_counts"] == {}

5 changes: 4 additions & 1 deletion server/tests/live/test_exhibition.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,10 @@ async def test_get(world, exhibition_room):
"highlighted_room_id": None,
"links": [],
"social_media_links": [
{"display_text": "linkedin", "url": "https://www.linkedin.com/"}
{
"display_text": "linkedin",
"url": "https://www.linkedin.com/",
}
],
"staff": [],
"room_id": str(exhibition_room.pk),
Expand Down
36 changes: 30 additions & 6 deletions server/tests/live/test_polls.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,16 @@ async def test_poll_lifecycle(questions_room, world):
"timestamp": poll["timestamp"],
"is_pinned": False,
"options": [
{"content": "blue", "order": 1, "id": poll["options"][0]["id"]},
{"content": "red", "order": 2, "id": poll["options"][1]["id"]},
{
"content": "blue",
"order": 1,
"id": poll["options"][0]["id"],
},
{
"content": "red",
"order": 2,
"id": poll["options"][1]["id"],
},
],
"results": {
poll["options"][0]["id"]: 0,
Expand Down Expand Up @@ -286,8 +294,16 @@ async def test_poll_lifecycle(questions_room, world):
"timestamp": poll["timestamp"],
"is_pinned": False,
"options": [
{"content": "blue", "order": 1, "id": poll["options"][0]["id"]},
{"content": "red", "order": 2, "id": poll["options"][1]["id"]},
{
"content": "blue",
"order": 1,
"id": poll["options"][0]["id"],
},
{
"content": "red",
"order": 2,
"id": poll["options"][1]["id"],
},
],
"results": {
poll["options"][0]["id"]: 1,
Expand Down Expand Up @@ -316,8 +332,16 @@ async def test_poll_lifecycle(questions_room, world):
"timestamp": poll["timestamp"],
"is_pinned": False,
"options": [
{"content": "blue", "order": 1, "id": poll["options"][0]["id"]},
{"content": "red", "order": 2, "id": poll["options"][1]["id"]},
{
"content": "blue",
"order": 1,
"id": poll["options"][0]["id"],
},
{
"content": "red",
"order": 2,
"id": poll["options"][1]["id"],
},
],
"results": {
poll["options"][0]["id"]: 1,
Expand Down
4 changes: 3 additions & 1 deletion server/tests/live/test_questions.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ async def test_ask_question_when_not_active(inactive_questions_room):
async def test_ask_question(questions_room, world):
async with world_communicator(room=questions_room) as c:
async with world_communicator(
room=questions_room, token=get_token(world, ["moderator"]), first=False
room=questions_room,
token=get_token(world, ["moderator"]),
first=False,
) as c_mod:
await c.send_json_to(
[
Expand Down
Loading
Loading