Skip to content

Commit 7ad5d0a

Browse files
committed
tests/add_from_fs(style[code-quality]): Fix formatting and style issues
why: Ensure code passes linting and follows project formatting standards what: - Fix line length violations by splitting long strings - Improve code readability with proper line breaks - Use dict() constructor for cleaner code - Remove unused loop variables with underscore prefix
1 parent 4737123 commit 7ad5d0a

File tree

1 file changed

+44
-37
lines changed

1 file changed

+44
-37
lines changed

tests/cli/test_add_from_fs.py

Lines changed: 44 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -335,8 +335,14 @@ def test_skip_existing_repos(
335335

336336
# Verify enhanced output for existing repos
337337
assert "Found 1 existing repositories in configuration:" in caplog.text
338-
assert f" - {repo_name} ({remote_url}) at {str(scan_dir)}/{repo_name} in {config_file}" in caplog.text
339-
assert "All found repositories already exist in the configuration. Nothing to do." in caplog.text
338+
assert (
339+
f" - {repo_name} ({remote_url}) at {scan_dir!s}/{repo_name} "
340+
f"in {config_file}" in caplog.text
341+
)
342+
assert (
343+
"All found repositories already exist in the configuration. Nothing to do."
344+
in caplog.text
345+
)
340346

341347
def test_user_confirmation(
342348
self,
@@ -459,35 +465,31 @@ def test_detailed_existing_repos_output(
459465
) -> None:
460466
"""Test detailed output when multiple repositories already exist."""
461467
caplog.set_level("INFO")
462-
468+
463469
# Create scan directory with multiple repos
464470
scan_dir = tmp_path / "existing_repos"
465471
scan_dir.mkdir()
466-
472+
467473
# Create multiple repositories
468474
repos_data = []
469-
for i, repo_name in enumerate(["repo1", "repo2", "repo3"]):
475+
for _i, repo_name in enumerate(["repo1", "repo2", "repo3"]):
470476
remote_path = create_git_remote_repo()
471477
remote_url = f"file://{remote_path}"
472478
local_repo_path = scan_dir / repo_name
473-
479+
474480
subprocess.run(
475481
["git", "clone", remote_url, str(local_repo_path)],
476482
check=True,
477483
capture_output=True,
478484
env=git_commit_envvars,
479485
)
480486
repos_data.append((repo_name, remote_url))
481-
487+
482488
# Pre-create config with all repos
483489
config_file = tmp_path / ".vcspull.yaml"
484-
config_data = {
485-
str(scan_dir) + "/": {
486-
repo_name: remote_url for repo_name, remote_url in repos_data
487-
}
488-
}
490+
config_data = {str(scan_dir) + "/": dict(repos_data)}
489491
save_config_yaml(config_file, config_data)
490-
492+
491493
# Run add_from_filesystem
492494
add_from_filesystem(
493495
scan_dir_str=str(scan_dir),
@@ -496,17 +498,23 @@ def test_detailed_existing_repos_output(
496498
base_dir_key_arg=None,
497499
yes=True,
498500
)
499-
501+
500502
# Verify detailed output
501503
assert "Found 3 existing repositories in configuration:" in caplog.text
502-
504+
503505
# Check each repository is listed with correct details
504506
for repo_name, remote_url in repos_data:
505-
expected_line = f" - {repo_name} ({remote_url}) at {str(scan_dir)}/{repo_name} in {config_file}"
507+
expected_line = (
508+
f" - {repo_name} ({remote_url}) at {scan_dir!s}/{repo_name} "
509+
f"in {config_file}"
510+
)
506511
assert expected_line in caplog.text
507-
512+
508513
# Verify final message
509-
assert "All found repositories already exist in the configuration. Nothing to do." in caplog.text
514+
assert (
515+
"All found repositories already exist in the configuration. Nothing to do."
516+
in caplog.text
517+
)
510518

511519
def test_mixed_existing_and_new_repos(
512520
self,
@@ -517,52 +525,48 @@ def test_mixed_existing_and_new_repos(
517525
) -> None:
518526
"""Test output when some repos exist and some are new."""
519527
caplog.set_level("INFO")
520-
528+
521529
# Create scan directory
522530
scan_dir = tmp_path / "mixed_repos"
523531
scan_dir.mkdir()
524-
532+
525533
# Create repositories
526534
existing_repo_data = []
527535
new_repo_data = []
528-
536+
529537
# Create two existing repos
530-
for i, repo_name in enumerate(["existing1", "existing2"]):
538+
for _i, repo_name in enumerate(["existing1", "existing2"]):
531539
remote_path = create_git_remote_repo()
532540
remote_url = f"file://{remote_path}"
533541
local_repo_path = scan_dir / repo_name
534-
542+
535543
subprocess.run(
536544
["git", "clone", remote_url, str(local_repo_path)],
537545
check=True,
538546
capture_output=True,
539547
env=git_commit_envvars,
540548
)
541549
existing_repo_data.append((repo_name, remote_url))
542-
550+
543551
# Create two new repos
544-
for i, repo_name in enumerate(["new1", "new2"]):
552+
for _i, repo_name in enumerate(["new1", "new2"]):
545553
remote_path = create_git_remote_repo()
546554
remote_url = f"file://{remote_path}"
547555
local_repo_path = scan_dir / repo_name
548-
556+
549557
subprocess.run(
550558
["git", "clone", remote_url, str(local_repo_path)],
551559
check=True,
552560
capture_output=True,
553561
env=git_commit_envvars,
554562
)
555563
new_repo_data.append((repo_name, remote_url))
556-
564+
557565
# Pre-create config with only existing repos
558566
config_file = tmp_path / ".vcspull.yaml"
559-
config_data = {
560-
str(scan_dir) + "/": {
561-
repo_name: remote_url for repo_name, remote_url in existing_repo_data
562-
}
563-
}
567+
config_data = {str(scan_dir) + "/": dict(existing_repo_data)}
564568
save_config_yaml(config_file, config_data)
565-
569+
566570
# Run add_from_filesystem
567571
add_from_filesystem(
568572
scan_dir_str=str(scan_dir),
@@ -571,15 +575,18 @@ def test_mixed_existing_and_new_repos(
571575
base_dir_key_arg=None,
572576
yes=True,
573577
)
574-
578+
575579
# Verify existing repos are listed
576580
assert "Found 2 existing repositories in configuration:" in caplog.text
577581
for repo_name, remote_url in existing_repo_data:
578-
expected_line = f" - {repo_name} ({remote_url}) at {str(scan_dir)}/{repo_name} in {config_file}"
582+
expected_line = (
583+
f" - {repo_name} ({remote_url}) at {scan_dir!s}/{repo_name} "
584+
f"in {config_file}"
585+
)
579586
assert expected_line in caplog.text
580-
587+
581588
# Verify new repos are added
582589
for repo_name, remote_url in new_repo_data:
583590
assert f"Adding '{repo_name}' ({remote_url})" in caplog.text
584-
591+
585592
assert "Successfully updated" in caplog.text

0 commit comments

Comments
 (0)