Skip to content

Commit 9e5d640

Browse files
AndriiNiedielnitsevIvan
authored andcommitted
style: fix lint errors
1 parent 66f8475 commit 9e5d640

2 files changed

Lines changed: 21 additions & 21 deletions

File tree

openedx_learning/apps/authoring/subsections/migrations/0001_initial.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Generated by Django 4.2.19 on 2025-04-09 12:59
22

3-
from django.db import migrations, models
43
import django.db.models.deletion
4+
from django.db import migrations, models
55

66

77
class Migration(migrations.Migration):

tests/openedx_learning/apps/authoring/subsections/test_api.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818

1919
@ddt.ddt
20-
class SubSectionTestCase(UnitTestCase):
20+
class SubSectionTestCase(UnitTestCase): # pylint: disable=test-inherits-tests
2121
""" Test cases for Subsections (containers of units) """
2222

2323
def setUp(self) -> None:
@@ -246,7 +246,7 @@ def test_adding_external_units(self):
246246
)
247247

248248
@patch('openedx_learning.apps.authoring.subsections.api._pub_entities_for_units')
249-
def test_adding_mismatched_versions(self, mock_entities_for_units):
249+
def test_adding_mismatched_versions(self, mock_entities_for_units): # pylint: disable=arguments-renamed
250250
"""
251251
Test that versioned units must match their entities.
252252
"""
@@ -268,7 +268,7 @@ def test_adding_mismatched_versions(self, mock_entities_for_units):
268268
)
269269

270270
@ddt.data(True, False)
271-
@pytest.mark.skip(reason="FIXME: This test is failing because the publishable_entity is not deleted from the database with the unit.")
271+
@pytest.mark.skip(reason="FIXME: publishable_entity is not deleted from the database with the unit.")
272272
# FIXME: Also, exception is Container.DoesNotExist, not Unit.DoesNotExist
273273
def test_cannot_add_invalid_ids(self, pin_version):
274274
"""
@@ -438,7 +438,7 @@ def test_add_unit_after_publish(self):
438438
# Publish the empty subsection:
439439
authoring_api.publish_all_drafts(self.learning_package.id)
440440
subsection.refresh_from_db() # Reloading the subsection is necessary
441-
assert subsection.versioning.has_unpublished_changes is False # Shallow check for just the subsection itself, not children
441+
assert subsection.versioning.has_unpublished_changes is False # Shallow check for subsection only, not children
442442
assert authoring_api.contains_unpublished_changes(subsection.pk) is False # Deeper check
443443

444444
# Add a published unit (unpinned):
@@ -453,7 +453,7 @@ def test_add_unit_after_publish(self):
453453
)
454454
# Now the subsection should have unpublished changes:
455455
subsection.refresh_from_db() # Reloading the subsection is necessary
456-
assert subsection.versioning.has_unpublished_changes # Shallow check - adding a child is a change to the subsection
456+
assert subsection.versioning.has_unpublished_changes # Shallow check: adding a child changes the subsection
457457
assert authoring_api.contains_unpublished_changes(subsection.pk) # Deeper check
458458
assert subsection.versioning.draft == subsection_version_v2
459459
assert subsection.versioning.published == subsection_version
@@ -482,9 +482,9 @@ def test_modify_unpinned_unit_after_publish(self):
482482
unit_1_v2 = self.modify_unit(self.unit_1, title="Modified Counting Problem with new title")
483483

484484
# The unit now has unpublished changes; the subsection doesn't directly but does contain
485-
subsection.refresh_from_db() # Reloading the subsection is necessary, or 'subsection.versioning' will be outdated
485+
subsection.refresh_from_db() # Refresh to avoid stale 'versioning' cache
486486
self.unit_1.refresh_from_db()
487-
assert subsection.versioning.has_unpublished_changes is False # Shallow check should be false - subsection is unchanged
487+
assert subsection.versioning.has_unpublished_changes is False # Shallow check: subsection unchanged
488488
assert authoring_api.contains_unpublished_changes(subsection.pk) # But subsection DOES contain changes
489489
assert self.unit_1.versioning.has_unpublished_changes
490490

@@ -504,7 +504,7 @@ def test_modify_unpinned_unit_after_publish(self):
504504
assert authoring_api.get_units_in_subsection(subsection, published=True) == [
505505
Entry(unit_1_v2), # new version
506506
]
507-
assert authoring_api.contains_unpublished_changes(subsection.pk) is False # No longer contains unpublished changes
507+
assert authoring_api.contains_unpublished_changes(subsection.pk) is False # No more unpublished changes
508508

509509
def test_modify_pinned_unit(self):
510510
"""
@@ -526,7 +526,7 @@ def test_modify_pinned_unit(self):
526526
self.modify_unit(self.unit_1, title="Modified Counting Problem with new title")
527527

528528
# The unit now has unpublished changes; the subsection is entirely unaffected
529-
subsection.refresh_from_db() # Reloading the subsection is necessary, or 'subsection.versioning' will be outdated
529+
subsection.refresh_from_db() # Refresh to avoid stale 'versioning' cache
530530
self.unit_1.refresh_from_db()
531531
assert subsection.versioning.has_unpublished_changes is False # Shallow check
532532
assert authoring_api.contains_unpublished_changes(subsection.pk) is False # Deep check
@@ -610,7 +610,7 @@ def test_publishing_shared_unit(self):
610610

611611
# 2️⃣ Then the author edits U2 inside of Subsection 1 making U2v2.
612612
u2_v2 = self.modify_unit(u2, title="U2 version 2")
613-
# This makes S1 and S2 both show up as Subsections that CONTAIN unpublished changes, because they share the unit.
613+
# Both S1 and S2 now contain unpublished changes since they share the unit.
614614
assert authoring_api.contains_unpublished_changes(subsection1.pk)
615615
assert authoring_api.contains_unpublished_changes(subsection2.pk)
616616
# (But the subsections themselves are unchanged:)
@@ -647,7 +647,7 @@ def test_publishing_shared_unit(self):
647647
Entry(u5_v1), # still original version of U5 (it hasn't been published)
648648
]
649649

650-
# Result: Subsection 2 CONTAINS unpublished changes because of the modified U5. Subsection 1 doesn't contain unpub changes.
650+
# Result: Subsection 2 contains unpublished changes due to modified U5; Subsection 1 does not.
651651
assert authoring_api.contains_unpublished_changes(subsection1.pk) is False
652652
assert authoring_api.contains_unpublished_changes(subsection2.pk)
653653

@@ -781,8 +781,8 @@ def test_soft_deleting_unit(self):
781781
# subsection's unit list but has been soft deleted, and will be fully deleted when published, or restored if
782782
# reverted?
783783
]
784-
assert subsection.versioning.has_unpublished_changes is False # The subsection itself and its unit list is not changed
785-
assert authoring_api.contains_unpublished_changes(subsection.pk) # But it CONTAINS an unpublished change (a deletion)
784+
assert subsection.versioning.has_unpublished_changes is False # Subsection and unit list unchanged
785+
assert authoring_api.contains_unpublished_changes(subsection.pk) # It still contains an unpublished deletion
786786
# The published version of the subsection is not yet affected:
787787
assert authoring_api.get_units_in_subsection(subsection, published=True) == [
788788
Entry(self.unit_1_v1),
@@ -844,7 +844,7 @@ def test_soft_deleting_pinned_unit(self):
844844
Entry(self.unit_1_v1, pinned=True),
845845
Entry(self.unit_2_v1, pinned=True),
846846
]
847-
assert subsection.versioning.has_unpublished_changes is False # The subsection itself and its unit list is not changed
847+
assert subsection.versioning.has_unpublished_changes is False # Subsection and unit list unchanged
848848
assert authoring_api.contains_unpublished_changes(subsection.pk) is False # nor does it contain changes
849849
# The published version of the subsection is also not affected:
850850
assert authoring_api.get_units_in_subsection(subsection, published=True) == [
@@ -867,7 +867,7 @@ def test_soft_delete_subsection(self):
867867
# Delete the subsection:
868868
authoring_api.soft_delete_draft(subsection_to_delete.publishable_entity_id)
869869
subsection_to_delete.refresh_from_db()
870-
# Now the draft subsection is [soft] deleted, but the units, published subsection, and other subsection is unaffected:
870+
# Now the draft subsection is soft deleted; units, published subsection, and other subsection are unaffected:
871871
assert subsection_to_delete.versioning.draft is None # Subsection is soft deleted.
872872
assert subsection_to_delete.versioning.published is not None
873873
self.unit_1.refresh_from_db()
@@ -1096,8 +1096,8 @@ def test_get_container_children_count(self):
10961096
assert authoring_api.get_container_children_count(subsection.container, published=True) == 1
10971097

10981098
# Tests TODO:
1099-
# Test that I can get a [PublishLog] history of a given subsection and all its children, including children that aren't
1100-
# currently in the subsection and excluding children that are only in other subsections.
1101-
# Test that I can get a [PublishLog] history of a given subsection and its children, that includes changes made to the
1102-
# child units while they were part of the subsection but excludes changes made to those children while they were
1103-
# not part of the subsection. 🫣
1099+
# Test that I can get a [PublishLog] history of a given subsection and all its children, including children
1100+
# that aren't currently in the subsection and excluding children that are only in other subsections.
1101+
# Test that I can get a [PublishLog] history of a given subsection and its children, that includes changes
1102+
# made to the child units while they were part of the subsection but excludes changes
1103+
# made to those children while they were not part of the subsection. 🫣

0 commit comments

Comments
 (0)