Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore any non-token related API errors while fetching rosters #6955

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lms/services/roster.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,12 @@ def _get_canvas_sections(
lms_course,
with_refresh_token=False,
)
except CanvasAPIError:
LOG.info(
"Failed to fetch sections for course %s, API error",
lms_course.id,
)
return []

def _refresh_canvas_token(
self, canvas_service: CanvasAPIClient, oauth2_token_service
Expand Down
13 changes: 13 additions & 0 deletions tests/unit/lms/services/roster_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,19 @@ def test_fetch_canvas_sections_roster_failed_refresh(

assert "error refreshing token" in caplog.records[0].message

@pytest.mark.usefixtures("instructor_in_course", "canvas_section")
def test_fetch_canvas_sections_roster_failed_canvas_api_error(
self, svc, lms_course, canvas_api_client, db_session, caplog
):
db_session.flush()

canvas_api_client.course_sections.side_effect = CanvasAPIError(refreshable=True)
canvas_api_client.get_refreshed_token.side_effect = CanvasAPIError

svc.fetch_canvas_sections_roster(lms_course)

assert "API error" in caplog.records[0].message

@pytest.mark.usefixtures("instructor_in_course", "canvas_section")
def test_fetch_canvas_sections_roster_with_invalid_token(
self, svc, lms_course, canvas_api_client, db_session, caplog
Expand Down
Loading