From 740d0403e908d32d656b1b8c8631db759d4b4c7b Mon Sep 17 00:00:00 2001 From: Brian Wilson Date: Tue, 22 Jan 2013 11:32:39 -0500 Subject: [PATCH] change name of function back to get_testcenter_registration, and disable its use as a test --- .../management/commands/pearson_make_tc_registration.py | 6 +++--- .../student/management/commands/tests/test_pearson.py | 4 ++-- common/djangoapps/student/models.py | 8 ++++++-- common/djangoapps/student/views.py | 6 +++--- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/common/djangoapps/student/management/commands/pearson_make_tc_registration.py b/common/djangoapps/student/management/commands/pearson_make_tc_registration.py index 545c8cd8a8..81a478d19d 100644 --- a/common/djangoapps/student/management/commands/pearson_make_tc_registration.py +++ b/common/djangoapps/student/management/commands/pearson_make_tc_registration.py @@ -4,7 +4,7 @@ from time import strftime from django.contrib.auth.models import User from django.core.management.base import BaseCommand, CommandError -from student.models import TestCenterUser, TestCenterRegistration, TestCenterRegistrationForm, get_tc_registration +from student.models import TestCenterUser, TestCenterRegistration, TestCenterRegistrationForm, get_testcenter_registration from student.views import course_from_id from xmodule.course_module import CourseDescriptor from xmodule.modulestore.exceptions import ItemNotFoundError @@ -134,7 +134,7 @@ class Command(BaseCommand): # create and save the registration: needs_updating = False - registrations = get_tc_registration(student, course_id, exam_code) + registrations = get_testcenter_registration(student, course_id, exam_code) if len(registrations) > 0: registration = registrations[0] for fieldname in UPDATE_FIELDS: @@ -181,7 +181,7 @@ class Command(BaseCommand): change_internal = False if 'exam_series_code' in our_options: exam_code = our_options['exam_series_code'] - registration = get_tc_registration(student, course_id, exam_code)[0] + registration = get_testcenter_registration(student, course_id, exam_code)[0] for internal_field in [ 'upload_error_message', 'upload_status', 'authorization_id']: if internal_field in our_options: registration.__setattr__(internal_field, our_options[internal_field]) diff --git a/common/djangoapps/student/management/commands/tests/test_pearson.py b/common/djangoapps/student/management/commands/tests/test_pearson.py index fd9eb31631..538cd2812a 100644 --- a/common/djangoapps/student/management/commands/tests/test_pearson.py +++ b/common/djangoapps/student/management/commands/tests/test_pearson.py @@ -12,7 +12,7 @@ import sys from django.test import TestCase from django.core import management -from student.models import User, TestCenterRegistration, TestCenterUser, get_tc_registration +from student.models import User, TestCenterRegistration, TestCenterUser, get_testcenter_registration log = logging.getLogger(__name__) @@ -44,7 +44,7 @@ def create_tc_registration(username, course_id, exam_code, accommodation_code): management.call_command('pearson_make_tc_registration', username, course_id, **options) user = User.objects.get(username=username) - registrations = get_tc_registration(user, course_id, exam_code) + registrations = get_testcenter_registration(user, course_id, exam_code) return registrations[0] class PearsonTestCase(TestCase): diff --git a/common/djangoapps/student/models.py b/common/djangoapps/student/models.py index 84bbc76a80..0d8a643ecb 100644 --- a/common/djangoapps/student/models.py +++ b/common/djangoapps/student/models.py @@ -547,13 +547,17 @@ class TestCenterRegistrationForm(ModelForm): -def get_tc_registration(user, course_id, exam_series_code): +def get_testcenter_registration(user, course_id, exam_series_code): try: tcu = TestCenterUser.objects.get(user=user) except TestCenterUser.DoesNotExist: return [] return TestCenterRegistration.objects.filter(testcenter_user=tcu, course_id=course_id, exam_series_code=exam_series_code) - + +# nosetests thinks that anything with _test_ in the name is a test. +# Correct this (https://nose.readthedocs.org/en/latest/finding_tests.html) +get_testcenter_registration.__test__ = False + def unique_id_for_user(user): """ Return a unique id for a user, suitable for inserting into diff --git a/common/djangoapps/student/views.py b/common/djangoapps/student/views.py index 650f0a0280..61b49e6022 100644 --- a/common/djangoapps/student/views.py +++ b/common/djangoapps/student/views.py @@ -31,7 +31,7 @@ from student.models import (Registration, UserProfile, TestCenterUser, TestCente TestCenterRegistration, TestCenterRegistrationForm, PendingNameChange, PendingEmailChange, CourseEnrollment, unique_id_for_user, - get_tc_registration) + get_testcenter_registration) from certificates.models import CertificateStatuses, certificate_status_for_student @@ -612,7 +612,7 @@ def exam_registration_info(user, course): return None exam_code = exam_info.exam_series_code - registrations = get_tc_registration(user, course.id, exam_code) + registrations = get_testcenter_registration(user, course.id, exam_code) if registrations: registration = registrations[0] else: @@ -712,7 +712,7 @@ def create_exam_registration(request, post_override=None): needs_saving = False exam = course.current_test_center_exam exam_code = exam.exam_series_code - registrations = get_tc_registration(user, course_id, exam_code) + registrations = get_testcenter_registration(user, course_id, exam_code) if registrations: registration = registrations[0] # NOTE: we do not bother to check here to see if the registration has changed,