Skip to content

Commit

Permalink
chore: fix lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
navinkarkera committed Jan 15, 2025
1 parent 1295028 commit e06f148
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
10 changes: 8 additions & 2 deletions openedx_learning/apps/authoring/linking/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@

@admin.register(PublishableEntityLink)
class PublishableEntityLinkAdmin(ReadOnlyModelAdmin):
fields = [
"""
PublishableEntityLink admin.
"""
fields = (
"uuid",
"upstream_block",
"upstream_usage_key",
Expand All @@ -23,7 +26,7 @@ class PublishableEntityLinkAdmin(ReadOnlyModelAdmin):
"version_declined",
"created",
"updated",
]
)
readonly_fields = fields
list_display = [
"upstream_block",
Expand All @@ -44,6 +47,9 @@ class PublishableEntityLinkAdmin(ReadOnlyModelAdmin):

@admin.register(CourseLinksStatus)
class CourseLinksStatusAdmin(admin.ModelAdmin):
"""
CourseLinksStatus admin.
"""
fields = (
"context_key",
"status",
Expand Down
4 changes: 4 additions & 0 deletions openedx_learning/apps/authoring/linking/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
)
Expand Down
14 changes: 5 additions & 9 deletions tests/openedx_learning/apps/authoring/linking/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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
Expand All @@ -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()

0 comments on commit e06f148

Please sign in to comment.