Skip to content

Commit 3a833f3

Browse files
Fix lint and format
1 parent 06ecbec commit 3a833f3

7 files changed

Lines changed: 39 additions & 32 deletions

File tree

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
"""add_assignment_due_date
1+
"""Add assignment due date.
22
33
Revision ID: 2a45f5cb8e25
44
Revises: af090ca7e73f
55
"""
6-
from alembic import op
7-
import sqlalchemy as sa
86

7+
import sqlalchemy as sa
8+
from alembic import op
99

10-
revision = '2a45f5cb8e25'
11-
down_revision = 'af090ca7e73f'
10+
revision = "2a45f5cb8e25"
11+
down_revision = "af090ca7e73f"
1212

1313

1414
def upgrade() -> None:
15-
op.add_column('assignment', sa.Column('due_date', sa.DateTime(), nullable=True))
15+
op.add_column("assignment", sa.Column("due_date", sa.DateTime(), nullable=True))
1616

1717

1818
def downgrade() -> None:
19-
op.drop_column('assignment', 'due_date')
19+
op.drop_column("assignment", "due_date")

lms/product/canvas/product.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class Canvas(Product):
2525

2626
settings_key = "canvas"
2727

28-
use_toolbar_grading = False
28+
use_toolbar_grading = False
2929
"""We use SpeedGrader in canvas instead"""
3030
use_toolbar_editing = False
3131
"""Canvas allows re-deeplinking assignments. We don't support editing in our side."""

lms/resources/_js_config/__init__.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -480,10 +480,12 @@ def enable_toolbar_checkpoint(self, assignment):
480480
# reveal_date is stored as UTC without timezone info. Adding
481481
# UTC here so the ISO string includes +00:00 and the browser
482482
# can convert it to the user's local timezone.
483-
"revealDate": assignment.checkpoint.reveal_date.replace(tzinfo=UTC).isoformat()
483+
"revealDate": assignment.checkpoint.reveal_date.replace(
484+
tzinfo=UTC
485+
).isoformat()
484486
if assignment.checkpoint.reveal_date
485487
else None,
486-
# TODO: use actual due date once available; for now reuse reveal_date.
488+
# Use actual due date once available; for now reuse reveal_date.
487489
"dueDate": assignment.checkpoint.reveal_date.replace(tzinfo=UTC).isoformat()
488490
if assignment.checkpoint.reveal_date
489491
else None,
@@ -497,7 +499,7 @@ def enable_student_checkpoint(self, assignment):
497499
revealed = assignment.checkpoint.reveal_date is not None
498500
self._config["studentCheckpoint"] = {
499501
"hidden": not revealed,
500-
# TODO: use actual due date once available; for now reuse reveal_date.
502+
# Use actual due date once available; for now reuse reveal_date.
501503
# reveal_date is stored as UTC without timezone info. Adding
502504
# UTC here so the ISO string includes +00:00 and the browser
503505
# can convert it to the user's local timezone.

lms/views/api/checkpoint.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,12 @@ def reveal_checkpoint(request):
2626
return {"error": "Assignment or checkpoint not found"}
2727

2828
if assignment.checkpoint.reveal_date:
29-
return {"revealed": True, "reveal_date": assignment.checkpoint.reveal_date.replace(tzinfo=UTC).isoformat()}
29+
return {
30+
"revealed": True,
31+
"reveal_date": assignment.checkpoint.reveal_date.replace(
32+
tzinfo=UTC
33+
).isoformat(),
34+
}
3035

3136
# Set the reveal date on the LMS side (source of truth)
3237
assignment.checkpoint.reveal_date = datetime.utcnow() # noqa: DTZ003

tests/unit/lms/resources/_js_config/__init___test.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from datetime import timedelta
1+
from datetime import datetime, timedelta
22
from unittest.mock import MagicMock, create_autospec, patch, sentinel
33

44
import pytest
@@ -619,8 +619,6 @@ def test_enable_toolbar_checkpoint_unrevealed(self, js_config):
619619
assert "revealUrl" in checkpoint
620620

621621
def test_enable_toolbar_checkpoint_revealed(self, js_config):
622-
from datetime import datetime
623-
624622
assignment = MagicMock()
625623
assignment.checkpoint.reveal_date = datetime(2026, 7, 1, 12, 0, 0) # noqa: DTZ001
626624
assignment.id = 42
@@ -644,8 +642,6 @@ def test_enable_student_checkpoint_hidden(self, js_config):
644642
assert config["studentCheckpoint"]["dueDate"] is None
645643

646644
def test_enable_student_checkpoint_revealed(self, js_config):
647-
from datetime import datetime
648-
649645
assignment = MagicMock()
650646
assignment.checkpoint.reveal_date = datetime(2026, 7, 1, 12, 0, 0) # noqa: DTZ001
651647

tests/unit/lms/views/api/checkpoint_test.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
from datetime import datetime
2-
from unittest.mock import MagicMock, create_autospec, sentinel
2+
from unittest.mock import MagicMock
33

44
import pytest
55

6-
from lms.models.assignment import Assignment
7-
from lms.models.assignment_checkpoint import AssignmentCheckpoint
6+
from lms.services import HAPI
87
from lms.views.api.checkpoint import reveal_checkpoint
98

109

11-
@pytest.mark.usefixtures("assignment_service", "h_api", "user_is_instructor")
10+
@pytest.mark.usefixtures("assignment_service", "h_api")
1211
class TestRevealCheckpoint:
13-
def test_it_rejects_non_instructors(self, pyramid_request, user_is_learner):
12+
def test_it_rejects_non_instructors(self, pyramid_request):
1413
pyramid_request.matchdict = {"assignment_id": "1"}
1514

1615
result = reveal_checkpoint(pyramid_request)
1716

1817
assert pyramid_request.response.status_code == 403
1918
assert "error" in result
2019

20+
@pytest.mark.usefixtures("user_is_instructor")
2121
def test_it_reveals_an_unrevealed_checkpoint(
2222
self, pyramid_request, assignment_service, h_api
2323
):
@@ -32,6 +32,7 @@ def test_it_reveals_an_unrevealed_checkpoint(
3232
assert "reveal_date" in result
3333
h_api.sync_checkpoints.assert_called_once()
3434

35+
@pytest.mark.usefixtures("user_is_instructor")
3536
def test_it_returns_already_revealed(
3637
self, pyramid_request, assignment_service, h_api
3738
):
@@ -47,6 +48,7 @@ def test_it_returns_already_revealed(
4748
assert "reveal_date" in result
4849
h_api.sync_checkpoints.assert_not_called()
4950

51+
@pytest.mark.usefixtures("user_is_instructor")
5052
def test_it_returns_404_when_assignment_not_found(
5153
self, pyramid_request, assignment_service
5254
):
@@ -58,6 +60,7 @@ def test_it_returns_404_when_assignment_not_found(
5860
assert pyramid_request.response.status_code == 404
5961
assert "error" in result
6062

63+
@pytest.mark.usefixtures("user_is_instructor")
6164
def test_it_returns_404_when_no_checkpoint(
6265
self, pyramid_request, assignment_service
6366
):
@@ -71,6 +74,7 @@ def test_it_returns_404_when_no_checkpoint(
7174
assert pyramid_request.response.status_code == 404
7275
assert "error" in result
7376

77+
@pytest.mark.usefixtures("user_is_instructor")
7478
def test_it_syncs_checkpoints_to_h(
7579
self, pyramid_request, assignment_service, h_api
7680
):
@@ -89,8 +93,11 @@ def test_it_syncs_checkpoints_to_h(
8993
assert call_kwargs["authority"] == "lms.hypothes.is"
9094
assert len(call_kwargs["checkpoints"]) == 1
9195
assert call_kwargs["checkpoints"][0]["group_authority_provided_id"] == "group1"
92-
assert call_kwargs["checkpoints"][0]["document_uri"] == "https://example.com/doc"
96+
assert (
97+
call_kwargs["checkpoints"][0]["document_uri"] == "https://example.com/doc"
98+
)
9399

100+
@pytest.mark.usefixtures("user_is_instructor")
94101
def test_it_does_not_sync_when_no_groupings(
95102
self, pyramid_request, assignment_service, h_api
96103
):
@@ -116,8 +123,6 @@ def _assignment_with_checkpoint(self, reveal_date):
116123

117124
@pytest.fixture
118125
def h_api(self, mock_service):
119-
from lms.services import HAPI
120-
121126
return mock_service(HAPI)
122127

123128
@pytest.fixture

tests/unit/lms/views/lti/basic_launch_test.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -399,8 +399,9 @@ def test__show_document_configures_toolbar(
399399

400400
assert result == {}
401401

402+
@pytest.mark.usefixtures("pyramid_request")
402403
def test__show_document_enables_checkpoint_toolbar_for_instructor(
403-
self, svc, request, context, pyramid_request
404+
self, svc, request, context
404405
):
405406
request.getfixturevalue("user_is_instructor")
406407
assignment = factories.Assignment()
@@ -413,9 +414,8 @@ def test__show_document_enables_checkpoint_toolbar_for_instructor(
413414
context.js_config.enable_toolbar_checkpoint.assert_called_once_with(assignment)
414415
context.js_config.enable_student_checkpoint.assert_not_called()
415416

416-
def test__show_document_enables_student_checkpoint_for_student(
417-
self, svc, context, pyramid_request
418-
):
417+
@pytest.mark.usefixtures("pyramid_request")
418+
def test__show_document_enables_student_checkpoint_for_student(self, svc, context):
419419
assignment = factories.Assignment()
420420
with mock.patch.object(
421421
type(assignment), "checkpoint", new_callable=mock.PropertyMock
@@ -426,9 +426,8 @@ def test__show_document_enables_student_checkpoint_for_student(
426426
context.js_config.enable_student_checkpoint.assert_called_once_with(assignment)
427427
context.js_config.enable_toolbar_checkpoint.assert_not_called()
428428

429-
def test__show_document_no_checkpoint_config_without_checkpoint(
430-
self, svc, context, pyramid_request
431-
):
429+
@pytest.mark.usefixtures("pyramid_request")
430+
def test__show_document_no_checkpoint_config_without_checkpoint(self, svc, context):
432431
assignment = factories.Assignment()
433432

434433
svc._show_document(assignment) # noqa: SLF001

0 commit comments

Comments
 (0)