Skip to content

Commit 7e01a2d

Browse files
committed
Remove redundant comments from mirror active field code
1 parent ada78f0 commit 7e01a2d

File tree

3 files changed

+0
-20
lines changed

3 files changed

+0
-20
lines changed

apollo/rpmworker/rh_matcher_activities.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,6 @@ async def match_rh_repos(params) -> None:
790790
all_advisories = {}
791791

792792
for mirror in supported_product.rh_mirrors:
793-
# Skip inactive mirrors
794793
if not mirror.active:
795794
logger.debug(f"Skipping inactive mirror {mirror.name}")
796795
continue

apollo/server/routes/admin_supported_products.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -273,15 +273,12 @@ async def _import_configuration(import_data: List[Dict[str, Any]], replace_exist
273273
continue
274274

275275
if existing_mirror and replace_existing:
276-
# Delete existing repositories
277276
await SupportedProductsRpmRepomd.filter(supported_products_rh_mirror=existing_mirror).delete()
278277
mirror = existing_mirror
279-
# Update active field if provided
280278
mirror.active = mirror_data.get("active", True)
281279
await mirror.save()
282280
updated_count += 1
283281
else:
284-
# Create new mirror
285282
mirror = SupportedProductsRhMirror(
286283
supported_product=product,
287284
name=mirror_data["name"],
@@ -383,12 +380,10 @@ async def admin_supported_product(request: Request, product_id: int):
383380
if isinstance(product, Response):
384381
return product
385382

386-
# Fetch mirrors with explicit ordering: active first, then by version (desc), then by name
387383
mirrors = await SupportedProductsRhMirror.filter(
388384
supported_product=product
389385
).order_by("-active", "-match_major_version", "name").prefetch_related("rpm_repomds").all()
390386

391-
# Get detailed statistics for each mirror
392387
for mirror in mirrors:
393388
repomds_count = await SupportedProductsRpmRepomd.filter(
394389
supported_products_rh_mirror=mirror
@@ -495,12 +490,10 @@ async def admin_supported_product_mirror_new_post(
495490
if isinstance(product, Response):
496491
return product
497492

498-
# Parse form data to get the active field
499493
form_data_raw = await request.form()
500494
# Checkbox sends "true" when checked, nothing when unchecked
501495
active_value = "true" if "true" in form_data_raw.getlist("active") else "false"
502496

503-
# Validation using centralized validation utility
504497
form_data = {
505498
"name": name,
506499
"match_variant": match_variant,
@@ -598,12 +591,10 @@ async def admin_supported_product_mirror_post(
598591
if isinstance(mirror, Response):
599592
return mirror
600593

601-
# Parse form data to get the active field
602594
form_data = await request.form()
603595
# Checkbox sends "true" when checked, nothing when unchecked
604596
active_value = "true" if "true" in form_data.getlist("active") else "false"
605597

606-
# Validation using centralized validation utility
607598
try:
608599
validated_name = FieldValidator.validate_name(
609600
name,
@@ -810,7 +801,6 @@ async def admin_supported_product_mirror_repomd_new_post(
810801
if isinstance(mirror, Response):
811802
return mirror
812803

813-
# Validation using centralized validation utility
814804
form_data = {
815805
"production": production,
816806
"arch": arch,
@@ -902,7 +892,6 @@ async def admin_supported_product_mirror_repomd_post(
902892
if isinstance(repomd, Response):
903893
return repomd
904894

905-
# Validation using centralized validation utility
906895
form_data = {
907896
"production": production,
908897
"arch": arch,

apollo/tests/test_admin_routes_supported_products.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -446,31 +446,26 @@ class TestActiveFieldCheckboxParsing(unittest.TestCase):
446446

447447
def test_checkbox_checked_returns_true(self):
448448
"""Test that checked checkbox results in active_value='true'."""
449-
# Simulate form data when checkbox is checked
450449
from unittest.mock import Mock
451450
form_data = Mock()
452451
form_data.getlist.return_value = ["true"]
453452

454-
# Apply the parsing logic from admin_supported_products.py
455453
active_value = "true" if "true" in form_data.getlist("active") else "false"
456454

457455
self.assertEqual(active_value, "true")
458456

459457
def test_checkbox_unchecked_returns_false(self):
460458
"""Test that unchecked checkbox results in active_value='false'."""
461-
# Simulate form data when checkbox is unchecked (empty list)
462459
from unittest.mock import Mock
463460
form_data = Mock()
464461
form_data.getlist.return_value = []
465462

466-
# Apply the parsing logic from admin_supported_products.py
467463
active_value = "true" if "true" in form_data.getlist("active") else "false"
468464

469465
self.assertEqual(active_value, "false")
470466

471467
def test_checkbox_missing_field_defaults_to_false(self):
472468
"""Test that missing active field defaults to false."""
473-
# Simulate form data without active field at all
474469
from unittest.mock import Mock
475470
form_data = Mock()
476471
form_data.getlist.return_value = []
@@ -481,7 +476,6 @@ def test_checkbox_missing_field_defaults_to_false(self):
481476

482477
def test_checkbox_boolean_conversion(self):
483478
"""Test that string active_value converts correctly to boolean."""
484-
# Test conversion to boolean for database storage
485479
active_value_true = "true"
486480
active_value_false = "false"
487481

@@ -490,14 +484,12 @@ def test_checkbox_boolean_conversion(self):
490484

491485
def test_checkbox_with_unexpected_value(self):
492486
"""Test that unexpected values default to false."""
493-
# Edge case: unexpected value
494487
from unittest.mock import Mock
495488
form_data = Mock()
496489
form_data.getlist.return_value = ["yes", "1", "on"]
497490

498491
active_value = "true" if "true" in form_data.getlist("active") else "false"
499492

500-
# Should default to false since "true" is not in the list
501493
self.assertEqual(active_value, "false")
502494

503495

0 commit comments

Comments
 (0)