From e06f148f3f9c9a83e25c446ab9ae202d2f043aa6 Mon Sep 17 00:00:00 2001 From: Navin Karkera Date: Wed, 15 Jan 2025 20:22:23 +0530 Subject: [PATCH] chore: fix lint issues --- openedx_learning/apps/authoring/linking/admin.py | 10 ++++++++-- openedx_learning/apps/authoring/linking/models.py | 4 ++++ .../apps/authoring/linking/test_api.py | 14 +++++--------- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/openedx_learning/apps/authoring/linking/admin.py b/openedx_learning/apps/authoring/linking/admin.py index c7c964eb..5e2f8f9a 100644 --- a/openedx_learning/apps/authoring/linking/admin.py +++ b/openedx_learning/apps/authoring/linking/admin.py @@ -11,7 +11,10 @@ @admin.register(PublishableEntityLink) class PublishableEntityLinkAdmin(ReadOnlyModelAdmin): - fields = [ + """ + PublishableEntityLink admin. + """ + fields = ( "uuid", "upstream_block", "upstream_usage_key", @@ -23,7 +26,7 @@ class PublishableEntityLinkAdmin(ReadOnlyModelAdmin): "version_declined", "created", "updated", - ] + ) readonly_fields = fields list_display = [ "upstream_block", @@ -44,6 +47,9 @@ class PublishableEntityLinkAdmin(ReadOnlyModelAdmin): @admin.register(CourseLinksStatus) class CourseLinksStatusAdmin(admin.ModelAdmin): + """ + CourseLinksStatus admin. + """ fields = ( "context_key", "status", diff --git a/openedx_learning/apps/authoring/linking/models.py b/openedx_learning/apps/authoring/linking/models.py index 6125df50..5b3e8374 100644 --- a/openedx_learning/apps/authoring/linking/models.py +++ b/openedx_learning/apps/authoring/linking/models.py @@ -98,6 +98,10 @@ class CourseLinksStatusChoices(models.TextChoices): class CourseLinksStatus(models.Model): + """ + This table stores current processing status of upstream-downstream links in PublishableEntityLink table for a + course. + """ context_key = key_field( help_text=_("Linking status for downstream/course context key"), ) diff --git a/tests/openedx_learning/apps/authoring/linking/test_api.py b/tests/openedx_learning/apps/authoring/linking/test_api.py index 9ce1bbe4..92a50dae 100644 --- a/tests/openedx_learning/apps/authoring/linking/test_api.py +++ b/tests/openedx_learning/apps/authoring/linking/test_api.py @@ -4,17 +4,13 @@ from __future__ import annotations from datetime import datetime, timezone -from uuid import UUID - -import pytest -from django.core.exceptions import ValidationError from openedx_learning.apps.authoring.components import api as components_api +from openedx_learning.apps.authoring.components.models import Component, ComponentType from openedx_learning.apps.authoring.linking import api as linking_api from openedx_learning.apps.authoring.linking.models import CourseLinksStatus, PublishableEntityLink from openedx_learning.apps.authoring.publishing import api as publishing_api from openedx_learning.apps.authoring.publishing.models import LearningPackage -from openedx_learning.apps.authoring.components.models import Component, ComponentType from openedx_learning.lib.test_utils import TestCase @@ -71,16 +67,16 @@ def test_update_or_create_entity_link(self) -> None: "version_synced": 1, } # Should create new link - link = linking_api.update_or_create_entity_link(self.html_component, **entity_args) + link = linking_api.update_or_create_entity_link(self.html_component, **entity_args) # type: ignore[arg-type] assert PublishableEntityLink.objects.filter(downstream_usage_key=downstream_usage_key).exists() prev_updated_time = link.updated # Using the api with same arguments should not make any changes - link = linking_api.update_or_create_entity_link(self.html_component, **entity_args) + link = linking_api.update_or_create_entity_link(self.html_component, **entity_args) # type: ignore[arg-type] assert link.updated == prev_updated_time # update version_synced field link = linking_api.update_or_create_entity_link( self.html_component, - **{**entity_args, "version_synced": 2} + **{**entity_args, "version_synced": 2} # type: ignore[arg-type] ) assert link.updated != prev_updated_time assert link.version_synced == 2 @@ -98,7 +94,7 @@ def test_delete_entity_link(self) -> None: "version_synced": 1, } # Should create new link - linking_api.update_or_create_entity_link(self.html_component, **entity_args) + linking_api.update_or_create_entity_link(self.html_component, **entity_args) # type: ignore[arg-type] assert PublishableEntityLink.objects.filter(downstream_usage_key=downstream_usage_key).exists() linking_api.delete_entity_link(downstream_usage_key) assert not PublishableEntityLink.objects.filter(downstream_usage_key=downstream_usage_key).exists()