INCR-126 Modernize common/djangoapps/student/management/tests (#20151)

This commit is contained in:
Jolyon Bloomfield
2019-04-04 10:08:02 -04:00
committed by Jeremy Bowman
parent c4b0a6bfcf
commit b8e1478ff0
12 changed files with 60 additions and 45 deletions

View File

@@ -1,19 +1,19 @@
"""Tests for the bulk_change_enrollment command."""
import ddt
from six import text_type
from __future__ import absolute_import
import ddt
from django.core.management import call_command
from django.core.management.base import CommandError
from mock import patch, call
from mock import call, patch
from six import text_type
from course_modes.tests.factories import CourseModeFactory
from student.tests.factories import UserFactory, CourseEnrollmentFactory
from student.models import CourseEnrollment, EVENT_NAME_ENROLLMENT_MODE_CHANGED
from openedx.core.djangoapps.content.course_overviews.models import CourseOverview
from student.models import EVENT_NAME_ENROLLMENT_MODE_CHANGED, CourseEnrollment
from student.tests.factories import CourseEnrollmentFactory, UserFactory
from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory
from openedx.core.djangoapps.content.course_overviews.models import CourseOverview
@ddt.ddt
class BulkChangeEnrollmentTests(SharedModuleStoreTestCase):

View File

@@ -1,17 +1,18 @@
from tempfile import NamedTemporaryFile
from __future__ import absolute_import
import unittest
from tempfile import NamedTemporaryFile
from django.conf import settings
from django.core.management import call_command
from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory
from testfixtures import LogCapture
from course_modes.tests.factories import CourseModeFactory
from course_modes.models import CourseMode
from student.tests.factories import UserFactory
from course_modes.tests.factories import CourseModeFactory
from student.models import CourseEnrollment
from student.tests.factories import UserFactory
from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory
LOGGER_NAME = 'student.management.commands.bulk_change_enrollment_csv'

View File

@@ -1,14 +1,15 @@
from __future__ import absolute_import
from tempfile import NamedTemporaryFile
from django.core.management import call_command
from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory
from testfixtures import LogCapture
from course_modes.tests.factories import CourseModeFactory
from student.tests.factories import UserFactory
from student.models import CourseEnrollment
from student.tests.factories import UserFactory
from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory
LOGGER_NAME = 'student.management.commands.bulk_unenroll'

View File

@@ -1,19 +1,21 @@
""" Test the change_eligibility_deadline command line script."""
from __future__ import absolute_import
from datetime import datetime, timedelta
from course_modes.tests.factories import CourseMode
from django.core.management import call_command
from opaque_keys import InvalidKeyError
from six import text_type
from testfixtures import LogCapture
from course_modes.tests.factories import CourseMode
from openedx.core.djangoapps.credit.models import CreditCourse, CreditEligibility
from student.models import CourseEnrollment, User
from student.tests.factories import UserFactory
from testfixtures import LogCapture
from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory
from openedx.core.djangoapps.credit.models import CreditCourse, CreditEligibility
LOGGER_NAME = 'student.management.commands.change_eligibility_deadline'
command_args = '--username {username} --course {course} --date {date}'

View File

@@ -1,16 +1,17 @@
""" Test the change_enrollment command line script."""
from __future__ import absolute_import
import ddt
from django.core.management import call_command
from mock import patch
from six import text_type
from django.core.management import call_command
from xmodule.modulestore.tests.factories import CourseFactory
from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase
from course_modes.tests.factories import CourseModeFactory
from student.tests.factories import UserFactory
from student.models import CourseEnrollment
from student.tests.factories import UserFactory
from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory
@ddt.ddt

View File

@@ -5,15 +5,13 @@ Tests for the django management command `change_enterprise_user_username`.
from __future__ import absolute_import, unicode_literals
import mock
from pytest import mark
from django.contrib.auth.models import User
from django.contrib.sites.models import Site
from django.core.management import call_command
from django.db.models.signals import post_save
from django.test import TestCase
from enterprise.models import EnterpriseCustomer, EnterpriseCustomerUser
from pytest import mark
@mark.django_db

View File

@@ -2,16 +2,17 @@
Test the create_random_users command line script
"""
from six import text_type
from __future__ import absolute_import
import pytest
from django.contrib.auth import get_user_model
from django.core.management import call_command
from opaque_keys import InvalidKeyError
from xmodule.modulestore.tests.factories import CourseFactory
from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase
from six import text_type
from student.models import CourseEnrollment
from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory
class CreateRandomUserTests(SharedModuleStoreTestCase):

View File

@@ -2,15 +2,16 @@
Test the create_user command line script
"""
from six import text_type
from __future__ import absolute_import
from django.contrib.auth import get_user_model
from django.core.management import call_command
from xmodule.modulestore.tests.factories import CourseFactory
from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase
from six import text_type
from course_modes.models import CourseMode
from student.models import CourseEnrollment, UserProfile
from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory
class CreateUserMgmtTests(SharedModuleStoreTestCase):

View File

@@ -1,12 +1,14 @@
"""
Unit tests for user_management management commands.
"""
from __future__ import absolute_import
import sys
import ddt
from django.contrib.auth.models import Group, Permission
from django.contrib.contenttypes.models import ContentType
from django.core.management import call_command, CommandError
from django.core.management import CommandError, call_command
from django.test import TestCase
TEST_EMAIL = 'test@example.com'
@@ -48,7 +50,7 @@ class TestManageGroupCommand(TestCase):
Checks that the current state of the database matches the specified groups and
permissions.
"""
self.check_groups(group_permissions.keys())
self.check_groups(list(group_permissions.keys()))
for group_name, permission_codenames in group_permissions.items():
self.check_permissions(group_name, permission_codenames)

View File

@@ -1,12 +1,14 @@
"""
Unit tests for user_management management commands.
"""
from __future__ import absolute_import
import itertools
import ddt
from django.contrib.auth.hashers import make_password
from django.contrib.auth.models import Group, User
from django.core.management import call_command, CommandError
from django.core.management import CommandError, call_command
from django.test import TestCase
from openedx.core.djangoapps.user_api.accounts.utils import generate_password

View File

@@ -1,15 +1,19 @@
"""
Unittests for populate_created_on_site_user_attribute management command.
"""
from __future__ import absolute_import
import ddt
import mock
from django.test import TestCase
from django.contrib.auth.models import User
from django.core.management import call_command, CommandError
from django.core.management import CommandError, call_command
from django.test import TestCase
from six.moves import range
from openedx.core.djangoapps.site_configuration.tests.mixins import SiteMixin
from student.models import Registration, UserAttribute
from student.tests.factories import UserFactory
from openedx.core.djangoapps.site_configuration.tests.mixins import SiteMixin
CREATED_ON_SITE = 'created_on_site'

View File

@@ -1,16 +1,18 @@
"""
Tests the transfer student management command
"""
from __future__ import absolute_import
import unittest
from mock import call, patch
from six import text_type
import ddt
from course_modes.models import CourseMode
from django.conf import settings
from django.core.management import call_command
from mock import call, patch
from opaque_keys.edx import locator
from six import text_type
from course_modes.models import CourseMode
from shoppingcart.models import CertificateItem, Order # pylint: disable=import-error
from student.models import (
EVENT_NAME_ENROLLMENT_ACTIVATED,