Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Apr 8, 2024
1 parent 3596bdd commit 2ceba32
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 29 deletions.
6 changes: 3 additions & 3 deletions platform_disk_api/kube_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ def from_primitive(cls, payload: dict[str, Any]) -> "PersistentVolumeClaimRead":
payload["spec"]["resources"]["requests"]["storage"]
),
storage_real=storage_real,
labels=payload["metadata"].get("labels", dict()),
annotations=payload["metadata"].get("annotations", dict()),
labels=payload["metadata"].get("labels", {}),
annotations=payload["metadata"].get("annotations", {}),
)


Expand Down Expand Up @@ -494,7 +494,7 @@ async def list_pods(self) -> PodListResult:
async def watch_pods(
self, resource_version: Optional[str] = None
) -> AsyncIterator[PodWatchEvent]:
params = dict(watch="true", allowWatchBookmarks="true")
params = {"watch": "true", "allowWatchBookmarks": "true"}
if resource_version:
params["resourceVersion"] = resource_version
url = self._pod_url
Expand Down
8 changes: 5 additions & 3 deletions platform_disk_api/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,11 @@ def _get_if_present(

return Disk(
id=pvc.name,
storage=pvc.storage_real
if pvc.storage_real is not None
else pvc.storage_requested,
storage=(
pvc.storage_real
if pvc.storage_real is not None
else pvc.storage_requested
),
status=status_map[pvc.phase],
owner=username,
project_name=pvc.labels.get(PROJECT_LABEL, username),
Expand Down
16 changes: 8 additions & 8 deletions tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,17 @@ def config_factory(
kube_client: None, # Force cleanup
) -> Callable[..., Config]:
def _f(**kwargs: Any) -> Config:
defaults = dict(
server=ServerConfig(host="0.0.0.0", port=8080),
platform_auth=auth_config,
kube=kube_config,
cluster_name=cluster_name,
disk=DiskConfig(
defaults = {
"server": ServerConfig(host="0.0.0.0", port=8080),
"platform_auth": auth_config,
"kube": kube_config,
"cluster_name": cluster_name,
"disk": DiskConfig(
k8s_storage_class=k8s_storage_class,
storage_limit_per_user=1024 * 1024 * 20, # 20mb
),
cors=CORSConfig(allowed_origins=["https://neu.ro"]),
)
"cors": CORSConfig(allowed_origins=["https://neu.ro"]),
}
kwargs = {**defaults, **kwargs}
return Config(**kwargs)

Expand Down
6 changes: 2 additions & 4 deletions tests/integration/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ async def disk_api(config: Config) -> AsyncIterator[DiskApiEndpoints]:


class DiskGranter(Protocol):
async def __call__(self, user: _User, disk: Disk, action: str = "read") -> None:
...
async def __call__(self, user: _User, disk: Disk, action: str = "read") -> None: ...


@pytest.fixture
Expand All @@ -94,8 +93,7 @@ async def _grant(user: _User, disk: Disk, action: str = "read") -> None:
class ProjectGranter(Protocol):
async def __call__(
self, user: _User, project_name: str, action: str = "read"
) -> None:
...
) -> None: ...


@pytest.fixture
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/test_kube_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ async def test_create_with_labels(
name=str(uuid4()),
storage_class_name=k8s_storage_class,
storage=10 * 1024 * 1024, # 10 mb
labels=dict(foo="bar"),
labels={"foo": "bar"},
)
await kube_client.create_pvc(pvc)
pvcs = await kube_client.list_pvc()
Expand All @@ -245,7 +245,7 @@ async def test_create_with_annotations(
name=str(uuid4()),
storage_class_name=k8s_storage_class,
storage=10 * 1024 * 1024, # 10 mb
annotations=dict(foo="bar"),
annotations={"foo": "bar"},
)
await kube_client.create_pvc(pvc)
pvcs = await kube_client.list_pvc()
Expand Down
18 changes: 9 additions & 9 deletions tests/unit/test_pvc.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def test_pvc_with_labels_to_primitive(
name=name,
storage_class_name=storage_class,
storage=storage,
labels=dict(foo="bar"),
labels={"foo": "bar"},
)
assert pvc.to_primitive() == {
"apiVersion": "v1",
Expand Down Expand Up @@ -90,8 +90,8 @@ def test_pvc_from_primitive_pending(
phase=PersistentVolumeClaimRead.Phase.PENDING,
storage_requested=storage,
storage_real=None,
labels=dict(),
annotations=dict(),
labels={},
annotations={},
)

@pytest.mark.parametrize(
Expand Down Expand Up @@ -157,8 +157,8 @@ def test_pvc_from_primitive_bound(
phase=PersistentVolumeClaimRead.Phase.BOUND,
storage_requested=storage,
storage_real=2 * storage,
labels=dict(),
annotations=dict(),
labels={},
annotations={},
)

@pytest.mark.parametrize("name,storage_class,storage", [("test", "test-stor", 100)])
Expand All @@ -185,8 +185,8 @@ def test_pvc_from_primitive_with_labels(
phase=PersistentVolumeClaimRead.Phase.BOUND,
storage_requested=storage,
storage_real=2 * storage,
labels=dict(foo="bar"),
annotations=dict(),
labels={"foo": "bar"},
annotations={},
)

@pytest.mark.parametrize("name,storage_class,storage", [("test", "test-stor", 100)])
Expand All @@ -213,6 +213,6 @@ def test_pvc_from_primitive_with_annotations(
phase=PersistentVolumeClaimRead.Phase.BOUND,
storage_requested=storage,
storage_real=2 * storage,
labels=dict(),
annotations=dict(foo="bar"),
labels={},
annotations={"foo": "bar"},
)

0 comments on commit 2ceba32

Please sign in to comment.