Skip to content

Commit

Permalink
Merge pull request #645 from edx/BOM-1068
Browse files Browse the repository at this point in the history
Replaced jsonfield with jsonfield2 BOM-1068
  • Loading branch information
iamsobanjaved authored Jan 29, 2020
2 parents 874b9a1 + baaf8c0 commit 591709b
Show file tree
Hide file tree
Showing 23 changed files with 168 additions and 228 deletions.
53 changes: 4 additions & 49 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,75 +1,30 @@
language: python
cache: pip
python:
- 2.7
- 3.5

services:
- xvfb

env:
- TOXENV=django111-drf37
- TOXENV=django111-drf38
- TOXENV=django111-drf39
- TOXENV=django111-drf310
- TOXENV=django111-drflatest
- TOXENV=django20-drf37
- TOXENV=django20-drf38
- TOXENV=django20-drf39
- TOXENV=django20-drf310
- TOXENV=django20-drflatest
- TOXENV=django21-drf37
- TOXENV=django21-drf38
- TOXENV=django21-drf39
- TOXENV=django21-drf310
- TOXENV=django21-drflatest
- TOXENV=django22-drf37
- TOXENV=django22-drf38
- TOXENV=django22-drf39
- TOXENV=django22-drf310
- TOXENV=django22-drflatest
# DRF 3.9.x is the latest that still supports python 2,
# and we run DRF 3.7 in edx-platform
# TODO: enable these in future, disable old ones above
# https://openedx.atlassian.net/browse/EDUCATOR-4774
- TOXENV=quality
- TOXENV=pii_check
- TOXENV=version_check
- TOXENV=translations
- TOXENV=js_tests
- TOXENV=js_lint


matrix:
exclude:
- python: 2.7
env: TOXENV=django20-drf37
- python: 2.7
env: TOXENV=django20-drf38
- python: 2.7
env: TOXENV=django20-drf39
- python: 2.7
env: TOXENV=django20-drflatest
- python: 2.7
env: TOXENV=django21-drf37
- python: 2.7
env: TOXENV=django21-drf38
- python: 2.7
env: TOXENV=django21-drf39
- python: 2.7
env: TOXENV=django21-drflatest
- python: 2.7
env: TOXENV=django22-drf37
- python: 2.7
env: TOXENV=django22-drf38
- python: 2.7
env: TOXENV=django22-drf39
- python: 2.7
env: TOXENV=django22-drflatest
- python: 2.7
env: TOXENV=version_check
- python: 2.7
env: TOXENV=js_lint
- python: 2.7
env: TOXENV=js_tests


before_install:
- export DISPLAY=:99.0

Expand Down
2 changes: 1 addition & 1 deletion edx_proctoring/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
from __future__ import absolute_import

# Be sure to update the version number in edx_proctoring/package.json
__version__ = '2.2.4'
__version__ = '2.2.5'

default_app_config = 'edx_proctoring.apps.EdxProctoringConfig' # pylint: disable=invalid-name
6 changes: 3 additions & 3 deletions edx_proctoring/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def save_model(self, request, obj, form, change):

class ProctoredExamSoftwareSecureReviewForm(forms.ModelForm):
"""Admin Form to display for reading/updating a Review"""
class Meta(object):
class Meta:
"""Meta class"""
model = ProctoredExamSoftwareSecureReview
fields = '__all__'
Expand Down Expand Up @@ -104,7 +104,7 @@ def queryset(self, request, queryset):

if self.value() == 'all_unreviewed':
return queryset.filter(reviewed_by__isnull=True)
elif self.value() == 'all_unreviewed_failures':
if self.value() == 'all_unreviewed_failures':
return queryset.filter(reviewed_by__isnull=True, review_status='Suspicious')
return queryset

Expand Down Expand Up @@ -365,7 +365,7 @@ class ProctoredExamAttemptForm(forms.ModelForm):
Admin Form to display for reading/updating a Proctored Exam Attempt
"""

class Meta(object):
class Meta:
""" Meta class """
model = ProctoredExamStudentAttempt
fields = '__all__'
Expand Down
7 changes: 3 additions & 4 deletions edx_proctoring/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -817,8 +817,7 @@ def update_attempt_status(exam_id, user_id, to_status,
if exam_attempt_obj is None:
if raise_if_not_found:
raise StudentExamAttemptDoesNotExistsException('Error. Trying to look up an exam that does not exist.')
else:
return
return

from_status = exam_attempt_obj.status

Expand Down Expand Up @@ -1650,7 +1649,7 @@ def _get_timed_exam_view(exam, context, exam_id, user_id, course_id):
has_time_expired = False

attempt_status = attempt['status'] if attempt else None
has_due_date = True if exam['due_date'] is not None else False
has_due_date = exam['due_date'] is not None
if not attempt_status:
if is_exam_passed_due(exam, user=user_id):
student_view_template = 'timed_exam/expired.html'
Expand Down Expand Up @@ -1749,7 +1748,7 @@ def _get_proctored_exam_context(exam, attempt, user_id, course_id, is_practice_e
"""
Common context variables for the Proctored and Practice exams' templates.
"""
has_due_date = True if exam['due_date'] is not None else False
has_due_date = exam['due_date'] is not None
attempt_time = attempt.get('allowed_time_limit_mins', None) if attempt else None

if not attempt_time:
Expand Down
2 changes: 1 addition & 1 deletion edx_proctoring/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def ready(self):
"""
Loads the available proctoring backends
"""
from edx_proctoring import signals # pylint: disable=unused-variable
from edx_proctoring import signals # pylint: disable=unused-import
config = settings.PROCTORING_BACKENDS

self.backends = {} # pylint: disable=W0201
Expand Down
2 changes: 1 addition & 1 deletion edx_proctoring/backends/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ def get_backend_provider(exam=None, name=None):
if 'is_proctored' in exam and not exam['is_proctored']:
# timed exams don't have a backend
return None
elif exam['backend']:
if exam['backend']:
name = exam['backend']
return apps.get_app_config('edx_proctoring').get_backend(name=name)
7 changes: 3 additions & 4 deletions edx_proctoring/backends/tests/test_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def register_exam_attempt(self, exam, context):
"""
if self.attempt_error:
raise BackendProviderOnboardingException(self.attempt_error)
elif self.no_attempt_id_error:
if self.no_attempt_id_error:
raise BackendProviderSentNoAttemptID(self.no_attempt_id_error, http_status=200)
return 'testexternalid'

Expand Down Expand Up @@ -107,9 +107,8 @@ def get_instructor_url(self, course_id, user, exam_id=None, attempt_id=None, sho
def retire_user(self, user_id):
if self.last_retire_user:
raise BackendProviderCannotRetireUser(user_id)
else:
self.last_retire_user = user_id
return True
self.last_retire_user = user_id
return True


class PassthroughBackendProvider(ProctoringBackendProvider):
Expand Down
8 changes: 4 additions & 4 deletions edx_proctoring/backends/tests/test_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def test_get_attempt(self):
)
external_attempt = self.provider.get_attempt(attempt)
self.assertEqual(external_attempt, attempt)
self.assertEqual(responses.calls[1].request.headers['Accept-Language'], 'en-us')
self.assertEqual(responses.calls[-1].request.headers['Accept-Language'], 'en-us')

@responses.activate
def test_get_attempt_i18n(self):
Expand All @@ -127,7 +127,7 @@ def test_get_attempt_i18n(self):
with translation.override('es'):
external_attempt = self.provider.get_attempt(attempt)
self.assertEqual(external_attempt, attempt)
self.assertEqual(responses.calls[1].request.headers['Accept-Language'], 'es;en-us')
self.assertEqual(responses.calls[-1].request.headers['Accept-Language'], 'es;en-us')

@responses.activate
def test_on_exam_saved(self):
Expand All @@ -150,7 +150,7 @@ def test_create_exam_with_defaults(self):
)
self.backend_exam.pop('external_id')
external_id = provider.on_exam_saved(self.backend_exam)
request = json.loads(responses.calls[1].request.body.decode('utf-8'))
request = json.loads(responses.calls[-1].request.body.decode('utf-8'))
self.assertEqual(external_id, 'abcdefg')
self.assertTrue(request['rules']['allow_grok'])

Expand Down Expand Up @@ -189,7 +189,7 @@ def test_register_exam_attempt(self):
status=200
)
attempt_external_id = self.provider.register_exam_attempt(self.backend_exam, self.register_exam_context)
request = json.loads(responses.calls[1].request.body.decode('utf-8'))
request = json.loads(responses.calls[-1].request.body.decode('utf-8'))
self.assertEqual(attempt_external_id, 2)
self.assertEqual(request['status'], 'created')
self.assertIn('lms_host', request)
Expand Down
2 changes: 1 addition & 1 deletion edx_proctoring/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import types


class ProctoringService(object):
class ProctoringService:
"""
An xBlock service for xBlocks to talk to the Proctoring subsystem. This class basically introspects
and exposes all functions in the api libraries, so it is a direct pass through.
Expand Down
6 changes: 3 additions & 3 deletions edx_proctoring/statuses.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from edx_proctoring.exceptions import ProctoredExamBadReviewStatus


class ProctoredExamStudentAttemptStatus(object):
class ProctoredExamStudentAttemptStatus:
"""
A class to enumerate the various status that an attempt can have
Expand Down Expand Up @@ -154,7 +154,7 @@ def is_in_progress_status(cls, status):
]


class ReviewStatus(object):
class ReviewStatus:
"""
Standard review statuses
"""
Expand All @@ -173,7 +173,7 @@ def validate(cls, status):
return True


class SoftwareSecureReviewStatus(object):
class SoftwareSecureReviewStatus:
"""
These are the valid review statuses from
SoftwareSecure
Expand Down
14 changes: 7 additions & 7 deletions edx_proctoring/tests/test_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from edx_proctoring.services import ProctoringService


class MockCreditService(object):
class MockCreditService:
"""
Simple mock of the Credit Service
"""
Expand Down Expand Up @@ -117,7 +117,7 @@ def get_credit_state(self, user_id, course_key, return_course_info=False): # py
return None


class MockInstructorService(object):
class MockInstructorService:
"""
Simple mock of the Instructor Service
"""
Expand Down Expand Up @@ -176,21 +176,21 @@ def test_singleton(self):
self.assertIs(service1, service2)


class MockGrade(object):
class MockGrade:
"""Fake PersistentSubsectionGrade instance."""
def __init__(self, earned_all=0.0, earned_graded=0.0):
self.earned_all = earned_all
self.earned_graded = earned_graded


class MockGradeOverride(object):
class MockGradeOverride:
"""Fake PersistentSubsectionGradeOverride instance."""
def __init__(self, earned_all=0.0, earned_graded=0.0):
self.earned_all_override = earned_all
self.earned_graded_override = earned_graded


class MockGeneratedCertificate(object):
class MockGeneratedCertificate:
"""Fake GeneratedCertificate instance."""
def __init__(self):
self.verify_uuid = 'test_verify_uuid'
Expand All @@ -210,7 +210,7 @@ def mock_invalidate(self):
self.status = 'unavailable'


class MockGradesService(object):
class MockGradesService:
"""
Simple mock of the Grades Service
"""
Expand Down Expand Up @@ -264,7 +264,7 @@ def should_override_grade_on_rejected_exam(self, course_key):
return self.rejected_exam_overrides_grade


class MockCertificateService(object):
class MockCertificateService:
"""
mock Certificate Service
"""
Expand Down
1 change: 0 additions & 1 deletion edx_proctoring/tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ def emit(self, name=None, data=None):
"""
Overload this method to do nothing
"""
pass


class ProctoredExamTestCase(LoggedInTestCase):
Expand Down
Loading

0 comments on commit 591709b

Please sign in to comment.