Skip to content

Commit 034bef2

Browse files
committed
Black/isort formatting
1 parent be3b71d commit 034bef2

File tree

3 files changed

+37
-18
lines changed

3 files changed

+37
-18
lines changed

tests/fixtures/package_info.py

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import datetime
2-
from typing import List, Dict, Any
2+
from typing import Any, Dict, List
33

44
import pytest
55

6-
from alws.errors import PlatformNotFoundError, RepositoriesNotFoundError
6+
from alws.errors import PlatformNotFoundError, RepositoriesNotFoundError
7+
78

89
@pytest.fixture
910
def package_info() -> List[Dict[str, Any]]:
@@ -27,29 +28,34 @@ def package_info() -> List[Dict[str, Any]]:
2728
def mock_get_package_info_success(monkeypatch, package_info):
2829
async def mock_func(*args, **kwargs):
2930
return package_info
31+
3032
monkeypatch.setattr("alws.crud.package_info.get_package_info", mock_func)
3133

3234

3335
@pytest.fixture
3436
def mock_get_package_info_platform_not_found(monkeypatch):
3537
async def mock_func(*args, **kwargs):
3638
raise PlatformNotFoundError("Invalid distribution: AlmaLinux-999")
39+
3740
monkeypatch.setattr("alws.crud.package_info.get_package_info", mock_func)
3841

3942

4043
@pytest.fixture
4144
def mock_get_package_info_repos_not_found(monkeypatch):
4245
async def mock_func(*args, **kwargs):
4346
raise RepositoriesNotFoundError("No repositories found")
47+
4448
monkeypatch.setattr("alws.crud.package_info.get_package_info", mock_func)
4549

4650

4751
@pytest.fixture
4852
def mock_get_package_info_empty(monkeypatch):
4953
async def mock_func(*args, **kwargs):
5054
return []
55+
5156
monkeypatch.setattr("alws.crud.package_info.get_package_info", mock_func)
5257

58+
5359
@pytest.fixture
5460
def mock_get_package_info_with_date_filter(monkeypatch):
5561
async def mock_func(*args, **kwargs):
@@ -72,16 +78,22 @@ async def mock_func(*args, **kwargs):
7278
]
7379

7480
if updated_after:
75-
cutoff = datetime.datetime.strptime(updated_after, "%Y-%m-%d %H:%M:%S")
81+
cutoff = datetime.datetime.strptime(
82+
updated_after, "%Y-%m-%d %H:%M:%S"
83+
)
7684
filtered = [
77-
{
78-
k: v for k, v in pkg.items() if k != "pulp_last_updated"
79-
}
85+
{k: v for k, v in pkg.items() if k != "pulp_last_updated"}
8086
for pkg in packages
81-
if datetime.datetime.strptime(pkg["pulp_last_updated"], "%Y-%m-%d %H:%M:%S") >= cutoff
87+
if datetime.datetime.strptime(
88+
pkg["pulp_last_updated"], "%Y-%m-%d %H:%M:%S"
89+
)
90+
>= cutoff
8291
]
8392
else:
84-
filtered = [ {k: v for k, v in pkg.items() if k != "pulp_last_updated"} for pkg in packages ]
93+
filtered = [
94+
{k: v for k, v in pkg.items() if k != "pulp_last_updated"}
95+
for pkg in packages
96+
]
8597

8698
return filtered
8799

tests/fixtures/pulp.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,15 +263,19 @@ async def func(*args, **kwargs):
263263
def create_rpm_publication(monkeypatch):
264264
async def func(*args, **kwargs):
265265
return {
266-
"pulp_href": ("/pulp/api/v3/tasks/fd754c2e-3b6c-4d69-9417-6d7f5bdf1e28/"),
266+
"pulp_href": (
267+
"/pulp/api/v3/tasks/fd754c2e-3b6c-4d69-9417-6d7f5bdf1e28/"
268+
),
267269
"pulp_created": "2023-02-16T15:06:52.836410Z",
268270
"state": "completed",
269271
"name": "pulp_file.app.tasks.publishing.publish",
270272
"logging_cid": "873348c8682944ad9cf2cc50745d5ba4",
271273
"started_at": "2023-02-16T15:06:53.072299Z",
272274
"finished_at": "2023-02-16T15:06:53.229928Z",
273275
"error": None,
274-
"worker": ("/pulp/api/v3/workers/19ae1f30-d1cb-414c-9d42-29bda565e00d/"),
276+
"worker": (
277+
"/pulp/api/v3/workers/19ae1f30-d1cb-414c-9d42-29bda565e00d/"
278+
),
275279
"parent_task": None,
276280
"child_tasks": [],
277281
"task_group": None,
@@ -488,6 +492,7 @@ def get_removed_rpm_packages_from_latest_repo_version(monkeypatch):
488492
def func(*args, **kwargs):
489493
class RpmPackage:
490494
pulp_href = uuid.uuid4()
495+
491496
return [RpmPackage() for i in range(10)]
492497

493498
monkeypatch.setattr(

tests/test_api/test_package_info.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
import pytest
2-
32
from fastapi import status
43

54
from alws.app import app
65
from tests.mock_classes import BaseAsyncTestCase
76

87

9-
@pytest.mark.usefixtures(
10-
"patch_limiter"
11-
)
8+
@pytest.mark.usefixtures("patch_limiter")
129
class TestPackageInfoEndpoints(BaseAsyncTestCase):
13-
async def test_get_package_info_success(self, mock_get_package_info_success, package_info):
10+
async def test_get_package_info_success(
11+
self, mock_get_package_info_success, package_info
12+
):
1413
response = await self.make_request(
1514
"get",
1615
"/api/v1/package_info/?name=example_package&almalinux_version=9",
@@ -20,7 +19,9 @@ async def test_get_package_info_success(self, mock_get_package_info_success, pac
2019
data = response.json()
2120
assert data == package_info
2221

23-
async def test_platform_not_found(self, mock_get_package_info_platform_not_found):
22+
async def test_platform_not_found(
23+
self, mock_get_package_info_platform_not_found
24+
):
2425
response = await self.make_request(
2526
"get",
2627
"/api/v1/package_info/?name=bash&almalinux_version=999",
@@ -29,7 +30,9 @@ async def test_platform_not_found(self, mock_get_package_info_platform_not_found
2930
assert response.status_code == status.HTTP_400_BAD_REQUEST
3031
assert "Invalid distribution" in response.text
3132

32-
async def test_repositories_not_found(self, mock_get_package_info_repos_not_found):
33+
async def test_repositories_not_found(
34+
self, mock_get_package_info_repos_not_found
35+
):
3336
response = await self.make_request(
3437
"get",
3538
"/api/v1/package_info/?name=bash&almalinux_version=9&arch=x86_64",
@@ -38,7 +41,6 @@ async def test_repositories_not_found(self, mock_get_package_info_repos_not_foun
3841
assert response.status_code == status.HTTP_400_BAD_REQUEST
3942
assert "No repositories found" in response.text
4043

41-
4244
async def test_empty_package_list(self, mock_get_package_info_empty):
4345
response = await self.make_request(
4446
"get",

0 commit comments

Comments
 (0)