Skip to content

Commit aae4e0a

Browse files
committed
Reformat files after bumping Python to 3.10
Code formatter: https://github.com/psf/black Signed-off-by: Ihor Solodrai <[email protected]>
1 parent e9cbb42 commit aae4e0a

File tree

2 files changed

+65
-43
lines changed

2 files changed

+65
-43
lines changed

tests/test_branch_worker.py

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,10 @@ class TestCase:
227227
with self.subTest(msg=case.name):
228228
self._bw.repo.get_pulls.reset_mock()
229229
self._bw.repo.get_pulls.return_value = case.prs
230-
with patch.object(BranchWorker, "add_pr") as ap, patch.object(
231-
BranchWorker, "_is_relevant_pr"
232-
) as rp:
230+
with (
231+
patch.object(BranchWorker, "add_pr") as ap,
232+
patch.object(BranchWorker, "_is_relevant_pr") as rp,
233+
):
233234
# set is_relevant return values
234235
rp.side_effect = [pr.relevant for pr in case.prs]
235236

@@ -328,9 +329,10 @@ class R:
328329
lr.remote.assert_called_with(UPSTREAM_REMOTE_NAME)
329330

330331
def test_do_sync_reset_repo(self) -> None:
331-
with patch.object(self._bw, "repo_local") as lr, patch(
332-
"kernel_patches_daemon.branch_worker._reset_repo"
333-
) as rr:
332+
with (
333+
patch.object(self._bw, "repo_local") as lr,
334+
patch("kernel_patches_daemon.branch_worker._reset_repo") as rr,
335+
):
334336
# Create a mock suitable to mock a git.RemoteReference
335337
remote_ref = "a/b/c/d"
336338
m = MagicMock()
@@ -426,9 +428,10 @@ class TestCase:
426428
def test_fetch_repo_path_doesnt_exist_full_sync(self) -> None:
427429
"""When the repo does not exist yet, a full sync is performed."""
428430
fetch_params = ["somepath", "giturl", "branch"]
429-
with patch.object(self._bw, "full_sync") as fr, patch(
430-
"kernel_patches_daemon.branch_worker.os.path.exists"
431-
) as exists:
431+
with (
432+
patch.object(self._bw, "full_sync") as fr,
433+
patch("kernel_patches_daemon.branch_worker.os.path.exists") as exists,
434+
):
432435
# path does not exists
433436
exists.return_value = False
434437
self._bw.fetch_repo(*fetch_params)
@@ -437,9 +440,10 @@ def test_fetch_repo_path_doesnt_exist_full_sync(self) -> None:
437440
def test_fetch_repo_path_exists_no_full_sync(self) -> None:
438441
"""If the repo already exist, we don't perform a full sync."""
439442
fetch_params = ["somepath", "giturl", "branch"]
440-
with patch.object(self._bw, "full_sync") as fr, patch(
441-
"kernel_patches_daemon.branch_worker.os.path.exists"
442-
) as exists:
443+
with (
444+
patch.object(self._bw, "full_sync") as fr,
445+
patch("kernel_patches_daemon.branch_worker.os.path.exists") as exists,
446+
):
443447
# path does exists
444448
exists.return_value = True
445449
self._bw.fetch_repo(*fetch_params)
@@ -448,9 +452,10 @@ def test_fetch_repo_path_exists_no_full_sync(self) -> None:
448452
def test_fetch_repo_path_exists_git_exception(self) -> None:
449453
"""When the repo exists but we hit a git command exception, we fallback on full sync."""
450454
fetch_params = ["somepath", "giturl", "branch"]
451-
with patch.object(self._bw, "full_sync") as fr, patch(
452-
"kernel_patches_daemon.branch_worker.os.path.exists"
453-
) as exists:
455+
with (
456+
patch.object(self._bw, "full_sync") as fr,
457+
patch("kernel_patches_daemon.branch_worker.os.path.exists") as exists,
458+
):
454459
# path does exists
455460
exists.return_value = True
456461
self._git_repo_mock.init.return_value.git.fetch.side_effect = (
@@ -520,9 +525,11 @@ class TestCase:
520525
with self.subTest(msg=case.name):
521526
self._bw.branches = case.branches
522527
self._bw.all_prs = {p: {} for p in case.all_prs}
523-
with patch.object(self._bw, "filter_closed_pr") as fcp, patch.object(
524-
self._bw, "delete_branch"
525-
) as db, freeze_time(not_expired_time):
528+
with (
529+
patch.object(self._bw, "filter_closed_pr") as fcp,
530+
patch.object(self._bw, "delete_branch") as db,
531+
freeze_time(not_expired_time),
532+
):
526533
fcp.side_effect = case.fcp_return_prs
527534
self._bw.expire_branches()
528535
# check fcp and db are called with proper counts

tests/test_github_connector.py

Lines changed: 40 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -254,11 +254,14 @@ def test_renew_expired_token(self) -> None:
254254
munch.munchify({"token": "token1", "expires_at": expired_at_date}),
255255
munch.munchify({"token": "token2", "expires_at": expired_at_next}),
256256
]
257-
with patch.object(
258-
AppInstallationAuth,
259-
"_get_installation_authorization",
260-
side_effect=side_effect,
261-
) as p, freeze_time(DEFAULT_FREEZE_DATE) as frozen_datetime:
257+
with (
258+
patch.object(
259+
AppInstallationAuth,
260+
"_get_installation_authorization",
261+
side_effect=side_effect,
262+
) as p,
263+
freeze_time(DEFAULT_FREEZE_DATE) as frozen_datetime,
264+
):
262265
gc = get_default_gc_app_auth_client()
263266
# Force generating a first token
264267
# pyre-fixme[16]: `github.MainClass.Github` has no attribute `__requester`.
@@ -286,11 +289,14 @@ def test_donot_renew_non_expired_token(self) -> None:
286289
munch.munchify({"token": "token1", "expires_at": expired_at_date}),
287290
munch.munchify({"token": "token2", "expires_at": expired_at_next}),
288291
]
289-
with patch.object(
290-
AppInstallationAuth,
291-
"_get_installation_authorization",
292-
side_effect=side_effect,
293-
) as p, freeze_time(DEFAULT_FREEZE_DATE) as frozen_datetime:
292+
with (
293+
patch.object(
294+
AppInstallationAuth,
295+
"_get_installation_authorization",
296+
side_effect=side_effect,
297+
) as p,
298+
freeze_time(DEFAULT_FREEZE_DATE) as frozen_datetime,
299+
):
294300
gc = get_default_gc_app_auth_client()
295301
# Force generating a first token
296302
# pyre-fixme[16]: `github.MainClass.Github` has no attribute `__requester`.
@@ -319,11 +325,14 @@ def test_repo_url(self) -> None:
319325
munch.munchify({"token": "token1", "expires_at": expired_at_date}),
320326
munch.munchify({"token": "token2", "expires_at": expired_at_next}),
321327
]
322-
with patch.object(
323-
AppInstallationAuth,
324-
"_get_installation_authorization",
325-
side_effect=side_effect,
326-
) as p, freeze_time(DEFAULT_FREEZE_DATE) as frozen_datetime:
328+
with (
329+
patch.object(
330+
AppInstallationAuth,
331+
"_get_installation_authorization",
332+
side_effect=side_effect,
333+
) as p,
334+
freeze_time(DEFAULT_FREEZE_DATE) as frozen_datetime,
335+
):
327336
gc_app_auth = get_default_gc_app_auth_client()
328337
gc_oauth = get_default_gc_oauth_client()
329338
# Force generating a first token
@@ -366,11 +375,14 @@ def test_set_user_token_in_url_when_not_present(self) -> None:
366375
munch.munchify({"token": "token1", "expires_at": expired_at_date}),
367376
]
368377

369-
with patch.object(
370-
AppInstallationAuth,
371-
"_get_installation_authorization",
372-
side_effect=side_effect,
373-
) as p, freeze_time(DEFAULT_FREEZE_DATE):
378+
with (
379+
patch.object(
380+
AppInstallationAuth,
381+
"_get_installation_authorization",
382+
side_effect=side_effect,
383+
) as p,
384+
freeze_time(DEFAULT_FREEZE_DATE),
385+
):
374386
gc_app_auth = get_default_gc_app_auth_client(
375387
repo_url=f"https://127.0.0.1/{TEST_ORG}/{TEST_REPO}"
376388
)
@@ -417,11 +429,14 @@ class TestCase:
417429
munch.munchify({"token": "token1", "expires_at": expired_at_date}),
418430
]
419431

420-
with patch.object(
421-
AppInstallationAuth,
422-
"_get_installation_authorization",
423-
side_effect=side_effect,
424-
) as p, freeze_time(DEFAULT_FREEZE_DATE):
432+
with (
433+
patch.object(
434+
AppInstallationAuth,
435+
"_get_installation_authorization",
436+
side_effect=side_effect,
437+
) as p,
438+
freeze_time(DEFAULT_FREEZE_DATE),
439+
):
425440
gc_app_auth = get_default_gc_app_auth_client(
426441
repo_url=case.initial_url
427442
)

0 commit comments

Comments
 (0)