Skip to content

Commit 2d8d4fe

Browse files
committed
ruffed
1 parent c7f86f8 commit 2d8d4fe

File tree

45 files changed

+107
-131
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+107
-131
lines changed

services/web/server/tests/integration/02/notifications/test_rabbitmq_consumers.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,6 @@ async def test_log_workflow(
220220
# project
221221
random_node_id_in_user_project: NodeID,
222222
user_project_id: ProjectID,
223-
#
224223
faker: Faker,
225224
mocker: MockerFixture,
226225
):
@@ -264,7 +263,6 @@ async def test_log_workflow_only_receives_messages_if_subscribed(
264263
# project
265264
random_node_id_in_user_project: NodeID,
266265
user_project_id: ProjectID,
267-
#
268266
faker: Faker,
269267
mocker: MockerFixture,
270268
):
@@ -333,7 +331,6 @@ async def test_progress_non_computational_workflow(
333331
# project
334332
random_node_id_in_user_project: NodeID,
335333
user_project_id: ProjectID,
336-
#
337334
mocker: MockerFixture,
338335
):
339336
"""

services/web/server/tests/integration/02/scicrunch/test_scicrunch__rest.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
"""
1515

1616
import os
17-
from pprint import pprint
1817
from typing import Any
1918

2019
import pytest
@@ -48,7 +47,6 @@ async def test_scicrunch_openapi_specs(settings: SciCrunchSettings):
4847
async with ClientSession() as client:
4948
resp = await client.get(f"{SCICRUNCH_DEFAULT_URL}/swagger-docs/swagger.json")
5049
openapi_specs = await resp.json()
51-
pprint(openapi_specs["info"])
5250

5351
expected_api_version = 1
5452
assert openapi_specs["info"]["version"] == expected_api_version
@@ -65,7 +63,6 @@ async def test_scicrunch_get_all_versions(
6563
):
6664
async with ClientSession() as client:
6765
versions = await get_all_versions(rrid, client, settings)
68-
pprint(versions)
6966

7067
assert versions
7168

@@ -85,7 +82,6 @@ async def test_scicrunch_get_all_versions_with_invalid_rrids(
8582
):
8683
async with ClientSession() as client:
8784
versions = await get_all_versions(rrid, client, settings)
88-
pprint(versions)
8985

9086
# invalid keys return success but an empty list of versions!
9187
assert isinstance(versions, list)

services/web/server/tests/integration/02/test_computation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ def _assert_db_contents(
199199

200200
for task_db in tasks_db:
201201
assert task_db.project_id == project_id
202-
assert task_db.node_id in mock_pipeline.keys()
202+
assert task_db.node_id in mock_pipeline
203203

204204
assert task_db.inputs == mock_pipeline[task_db.node_id].get("inputs")
205205

services/web/server/tests/unit/isolated/exporter/test_exporter_formatter_archive.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# pylint:disable=redefined-outer-name
22

33
import tempfile
4+
from collections.abc import Iterator
45
from pathlib import Path
5-
from typing import Iterator
66

77
import pytest
88
from faker import Faker

services/web/server/tests/unit/isolated/test__configs.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616

1717
@pytest.fixture(scope="session")
1818
def app_config_schema():
19-
raise RuntimeError("DEPRECATED. MUST NOT BE USED")
19+
msg = "DEPRECATED. MUST NOT BE USED"
20+
raise RuntimeError(msg)
2021

2122

2223
@pytest.fixture(scope="session")
@@ -33,16 +34,14 @@ def service_webserver_environ(
3334
), # defined if pip install --edit (but not in travis!)
3435
}
3536

36-
webserver_environ = eval_service_environ(
37+
return eval_service_environ(
3738
services_docker_compose_file,
3839
"webserver",
3940
host_environ,
4041
image_environ,
4142
use_env_devel=True,
4243
)
4344

44-
return webserver_environ
45-
4645

4746
@pytest.fixture(scope="session")
4847
def app_submodules_with_setup_funs(package_dir: Path) -> set[ModuleType]:

services/web/server/tests/unit/isolated/test__redirections.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55

66
import asyncio
77
import textwrap
8-
from collections.abc import Callable
8+
from collections.abc import Awaitable, Callable
99
from pathlib import Path
10-
from typing import Awaitable
1110

1211
import pytest
1312
from aiohttp import web
@@ -47,30 +46,32 @@ def client(
4746

4847
@routes.get("/")
4948
async def get_root(_request):
50-
raise web.HTTPOk()
49+
raise web.HTTPOk
5150

5251
@routes.get("/other")
5352
async def get_other(_request):
54-
raise web.HTTPOk()
53+
raise web.HTTPOk
5554

5655
@routes.get("/redirect-to-other")
5756
async def get_redirect_to_other(request):
58-
raise web.HTTPFound("/other")
57+
msg = "/other"
58+
raise web.HTTPFound(msg)
5959

6060
@routes.get("/redirect-to-static")
6161
async def get_redirect_to_static(_request):
62-
raise web.HTTPFound("/statics/index.html")
62+
msg = "/statics/index.html"
63+
raise web.HTTPFound(msg)
6364

6465
@routes.get("/redirect-to-root")
6566
async def get_redirect_to_root(_request):
66-
raise web.HTTPFound("/")
67+
msg = "/"
68+
raise web.HTTPFound(msg)
6769

6870
routes.static("/statics", index_static_path)
6971

7072
app = web.Application()
7173
app.add_routes(routes)
72-
cli = event_loop.run_until_complete(aiohttp_client(app))
73-
return cli
74+
return event_loop.run_until_complete(aiohttp_client(app))
7475

7576

7677
@pytest.mark.parametrize("test_path", ["/", "/other"])
@@ -80,7 +81,7 @@ async def test_preserves_fragments(client, test_path):
8081
assert resp.real_url.fragment == "this/is/a/fragment"
8182

8283

83-
@pytest.mark.xfail
84+
@pytest.mark.xfail()
8485
@pytest.mark.parametrize(
8586
"test_path,expected_redirected_path",
8687
[

services/web/server/tests/unit/isolated/test_login_settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def twilio_config(monkeypatch: pytest.MonkeyPatch) -> dict[str, str]:
3434
"TWILIO_MESSAGING_SID": "x" * 34,
3535
}
3636
# NOTE: enforces DELETE-ENV since apparently some session-based fixtures are settings these envs
37-
for key in TWILO_CONFIG.keys():
37+
for key in TWILO_CONFIG:
3838
monkeypatch.delenv(key, raising=False)
3939
return TWILO_CONFIG
4040

services/web/server/tests/unit/isolated/test_projects__db_utils.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
import datetime
66
import json
77
import re
8+
from collections.abc import Callable
89
from copy import deepcopy
910
from dataclasses import dataclass
10-
from typing import Any, Callable
11+
from typing import Any
1112

1213
import pytest
1314
from faker import Faker
@@ -95,7 +96,7 @@ def test_convert_to_schema_names(fake_project: dict[str, Any]):
9596
assert col is not None
9697

9798
# test date time conversion
98-
date = datetime.datetime.now(datetime.timezone.utc)
99+
date = datetime.datetime.now(datetime.UTC)
99100
db_entries["creation_date"] = date
100101
schema_entries = convert_to_schema_names(db_entries, fake_project["prjOwner"])
101102
assert "creationDate" in schema_entries
@@ -110,7 +111,7 @@ def test_convert_to_schema_names_camel_casing(fake_db_dict):
110111
assert "anEntryThatUsesSnakeCase" in db_entries
111112
assert "anotherEntryThatUsesSnakeCase" in db_entries
112113
# test date time conversion
113-
date = datetime.datetime.now(datetime.timezone.utc)
114+
date = datetime.datetime.now(datetime.UTC)
114115
fake_db_dict["time_entry"] = date
115116
db_entries = convert_to_schema_names(fake_db_dict, fake_email)
116117
assert "timeEntry" in db_entries

services/web/server/tests/unit/isolated/test_rest.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,9 @@ async def slow_handler(request: web.Request):
4848

4949
app.router.add_get("/slow", slow_handler)
5050

51-
cli = event_loop.run_until_complete(
51+
return event_loop.run_until_complete(
5252
aiohttp_client(app, server_kwargs=server_kwargs)
5353
)
54-
return cli
5554

5655

5756
async def test_frontend_config(

services/web/server/tests/unit/isolated/test_security__authz.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,7 @@ def test_unique_permissions():
9797
for permission in can:
9898
assert (
9999
permission not in used
100-
), "'{}' in {} is repeated in security_roles.ROLES_PERMISSIONS".format(
101-
permission,
102-
role,
103-
)
100+
), f"'{permission}' in {role} is repeated in security_roles.ROLES_PERMISSIONS"
104101
used.append(permission)
105102

106103

@@ -263,7 +260,7 @@ async def _fake_db(engine, email):
263260
raise DatabaseError
264261

265262
# inactive user or not found
266-
return copy.deepcopy(users_db.get(email, None))
263+
return copy.deepcopy(users_db.get(email))
267264

268265
mock_db_fun = mocker.patch(
269266
"simcore_service_webserver.security._authz_policy.get_active_user_or_none",

0 commit comments

Comments
 (0)