Commit deda4868 by Tyler Hallada

Fix tests on Django 1.11

parent bf8c3672
......@@ -14,7 +14,7 @@ import pytz
from django.utils.translation import ugettext as _, ugettext_noop
from django.conf import settings
from django.contrib.auth.models import User
from django.template import Context, loader
from django.template import loader
from django.core.urlresolvers import reverse, NoReverseMatch
from django.core.mail.message import EmailMessage
......@@ -979,18 +979,16 @@ def create_proctoring_attempt_status_email(user_id, exam_attempt_obj, course_nam
username=user.username,
)
body = email_template.render(
Context({
'username': user.username,
'course_url': course_url,
'course_name': course_name,
'exam_name': exam_name,
'status': status,
'platform': constants.PLATFORM_NAME,
'contact_email': constants.CONTACT_EMAIL,
'support_email_subject': support_email_subject,
})
)
body = email_template.render({
'username': user.username,
'course_url': course_url,
'course_name': course_name,
'exam_name': exam_name,
'status': status,
'platform': constants.PLATFORM_NAME,
'contact_email': constants.CONTACT_EMAIL,
'support_email_subject': support_email_subject,
})
email = EmailMessage(
body=body,
......@@ -1513,7 +1511,6 @@ def _get_timed_exam_view(exam, context, exam_id, user_id, course_id):
if student_view_template:
template = loader.get_template(student_view_template)
django_context = Context(context)
allowed_time_limit_mins = attempt['allowed_time_limit_mins'] if attempt else None
......@@ -1547,7 +1544,7 @@ def _get_timed_exam_view(exam, context, exam_id, user_id, course_id):
except NoReverseMatch:
log.exception("Can't find progress url for course %s", course_id)
django_context.update({
context.update({
'total_time': total_time,
'hide_extra_time_footer': hide_extra_time_footer,
'will_be_revealed': has_due_date and not exam['hide_after_due'],
......@@ -1562,7 +1559,7 @@ def _get_timed_exam_view(exam, context, exam_id, user_id, course_id):
args=[attempt['id']]
) if attempt else '',
})
return template.render(django_context)
return template.render(context)
def _calculate_allowed_mins(due_datetime, allowed_mins):
......@@ -1663,9 +1660,8 @@ def _get_practice_exam_view(exam, context, exam_id, user_id, course_id):
if student_view_template:
template = loader.get_template(student_view_template)
django_context = Context(context)
django_context.update(_get_proctored_exam_context(exam, attempt, course_id, is_practice_exam=True))
return template.render(django_context)
context.update(_get_proctored_exam_context(exam, attempt, course_id, is_practice_exam=True))
return template.render(context)
def _get_proctored_exam_view(exam, context, exam_id, user_id, course_id):
......@@ -1807,9 +1803,8 @@ def _get_proctored_exam_view(exam, context, exam_id, user_id, course_id):
if student_view_template:
template = loader.get_template(student_view_template)
django_context = Context(context)
django_context.update(_get_proctored_exam_context(exam, attempt, course_id))
return template.render(django_context)
context.update(_get_proctored_exam_context(exam, attempt, course_id))
return template.render(context)
def get_student_view(user_id, course_id, content_id,
......
......@@ -8,7 +8,7 @@ from __future__ import absolute_import
import json
import ddt
from mock import patch
from mock import MagicMock, patch
from httmock import all_requests, HTTMock
from django.test import TestCase
......@@ -87,6 +87,7 @@ def mock_response_error(url, request): # pylint: disable=unused-argument
}
}
)
@patch('django.core.urlresolvers.reverse', MagicMock)
@ddt.ddt
class SoftwareSecureTests(TestCase):
"""
......
......@@ -3,7 +3,7 @@ Various callback paths that support callbacks from SoftwareSecure
"""
import logging
from django.template import Context, loader
from django.template import loader
from django.conf import settings
from django.http import HttpResponse
......@@ -52,12 +52,10 @@ def start_exam_callback(request, attempt_code): # pylint: disable=unused-argume
template = loader.get_template('proctored_exam/proctoring_launch_callback.html')
return HttpResponse(
template.render(
Context({
'platform_name': settings.PLATFORM_NAME,
'link_urls': settings.PROCTORING_SETTINGS.get('LINK_URLS', {})
})
)
template.render({
'platform_name': settings.PLATFORM_NAME,
'link_urls': settings.PROCTORING_SETTINGS.get('LINK_URLS', {})
})
)
......
......@@ -5,6 +5,7 @@ Tests for the set_attempt_status management command
from __future__ import absolute_import
from datetime import datetime
from mock import MagicMock, patch
import pytz
from edx_proctoring.tests.utils import LoggedInTestCase
......@@ -18,6 +19,7 @@ from edx_proctoring.tests.test_services import (
from edx_proctoring.runtime import set_runtime_service
@patch('django.core.urlresolvers.reverse', MagicMock)
class SetAttemptStatusTests(LoggedInTestCase):
"""
Coverage of the set_attempt_status.py file
......
......@@ -10,7 +10,7 @@ from __future__ import absolute_import
from datetime import datetime, timedelta
import ddt
from freezegun import freeze_time
from mock import patch
from mock import MagicMock, patch
import pytz
from edx_proctoring.api import (
......@@ -75,6 +75,7 @@ from .test_services import (
from .utils import ProctoredExamTestCase
@patch('django.core.urlresolvers.reverse', MagicMock)
@ddt.ddt
class ProctoredExamApiTests(ProctoredExamTestCase):
"""
......
......@@ -7,7 +7,7 @@ from __future__ import absolute_import
import ddt
from django.core import mail
from mock import patch
from mock import MagicMock, patch
from edx_proctoring.api import (
update_attempt_status,
......@@ -25,6 +25,7 @@ from .utils import (
)
@patch('django.core.urlresolvers.reverse', MagicMock)
@ddt.ddt
class ProctoredExamEmailTests(ProctoredExamTestCase):
"""
......
......@@ -10,7 +10,7 @@ from __future__ import absolute_import
from datetime import datetime, timedelta
import ddt
from freezegun import freeze_time
from mock import patch
from mock import MagicMock, patch
import pytz
from edx_proctoring.api import (
......@@ -33,6 +33,7 @@ from .test_services import MockCreditServiceWithCourseEndDate
from .utils import ProctoredExamTestCase
@patch('django.core.urlresolvers.reverse', MagicMock)
@ddt.ddt
class ProctoredExamStudentViewTests(ProctoredExamTestCase):
"""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment