11from datetime import datetime
2- from unittest .mock import MagicMock , create_autospec , sentinel
2+ from unittest .mock import MagicMock
33
44import pytest
55
6- from lms .models .assignment import Assignment
7- from lms .models .assignment_checkpoint import AssignmentCheckpoint
6+ from lms .services import HAPI
87from 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" )
1211class 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
0 commit comments