Merge pull request #18691 from edx/jmbowman/TE-2524

TE-2524 Stop using nose.plugins - LMS 1
This commit is contained in:
Jeremy Bowman
2018-08-01 12:57:29 -04:00
committed by GitHub
51 changed files with 79 additions and 114 deletions

View File

@@ -8,11 +8,11 @@ import textwrap
import unittest
from uuid import uuid4
import pytest
from django.conf import settings
from django.test.utils import override_settings
from django.utils import translation
from mock import Mock, patch
from nose.plugins.skip import SkipTest
from six import text_type
from contentstore.tests.utils import mock_requests_get
@@ -267,9 +267,9 @@ class TestDownloadYoutubeSubs(TestYoutubeSubsBase):
def test_success_downloading_chinese_transcripts(self):
# Disabled 11/14/13
# This test is flakey because it performs an HTTP request on an external service
# This test is flaky because it performs an HTTP request on an external service
# Re-enable when `requests.get` is patched using `mock.patch`
raise SkipTest
pytest.skip()
good_youtube_sub = 'j_jEn79vS3g' # Chinese, utf-8
self.clear_sub_content(good_youtube_sub)

View File

@@ -4,7 +4,6 @@ Tests for the badges API views.
from ddt import data, ddt, unpack
from django.conf import settings
from django.test.utils import override_settings
from nose.plugins.attrib import attr
from badges.tests.factories import BadgeAssertionFactory, BadgeClassFactory, RandomBadgeClassFactory
from openedx.core.lib.api.test_utils import ApiTestCase
@@ -152,12 +151,12 @@ class TestUserCourseBadgeAssertions(UserAssertionTestCase):
self.check_assertion_structure(assertion, response['results'][0])
@attr(shard=3)
@ddt
class TestUserBadgeAssertionsByClass(UserAssertionTestCase):
"""
Test the Badge Assertions view with the badge class filter.
"""
shard = 3
@unpack
@data((False, False), (True, False), (True, True))

View File

@@ -1,7 +1,6 @@
"""
Tests for the Badges app models.
"""
import pytest
from path import Path
from django.core.exceptions import ValidationError
from django.core.files.images import ImageFile
@@ -10,7 +9,6 @@ from django.db.utils import IntegrityError
from django.test import TestCase
from django.test.utils import override_settings
from mock import Mock, patch
from nose.plugins.attrib import attr
from badges.models import (
BadgeAssertion,
@@ -33,12 +31,13 @@ def get_image(name):
return ImageFile(open(TEST_DATA_ROOT / 'badges' / name + '.png'))
@attr(shard=1)
@override_settings(MEDIA_ROOT=TEST_DATA_ROOT)
class BadgeImageConfigurationTest(TestCase):
"""
Test the validation features of BadgeImageConfiguration.
"""
shard = 1
def tearDown(self):
tmp_path = Path(TEST_DATA_ROOT / 'course_complete_badges')
Path.rmtree_p(tmp_path)

View File

@@ -3,16 +3,16 @@ Tests for the Video Branding configuration.
"""
from django.core.exceptions import ValidationError
from django.test import TestCase
from nose.plugins.attrib import attr
from branding.models import BrandingInfoConfig
@attr(shard=1)
class BrandingInfoConfigTest(TestCase):
"""
Test the BrandingInfoConfig model.
"""
shard = 1
def setUp(self):
super(BrandingInfoConfigTest, self).setUp()
self.configuration_string = """{

View File

@@ -11,13 +11,13 @@ from django.test.client import RequestFactory
from django.test.utils import override_settings
from milestones.tests.utils import MilestonesTestCaseMixin
from mock import Mock, patch
from nose.plugins.attrib import attr
from pytz import UTC
from branding.views import index
from courseware.tests.helpers import LoginEnrollmentTestCase
from edxmako.shortcuts import render_to_response
from openedx.core.djangoapps.site_configuration.tests.mixins import SiteMixin
from openedx.core.lib.tests import attr
from util.milestones_helpers import set_prerequisite_courses
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory

View File

@@ -8,7 +8,6 @@ from django.core import mail
from django.core.management import call_command
from django.urls import reverse
from mock import Mock, patch
from nose.plugins.attrib import attr
from six import text_type
from bulk_email.models import BulkEmailFlag
@@ -23,12 +22,12 @@ from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory
@attr(shard=1)
@patch('bulk_email.models.html_to_text', Mock(return_value='Mocking CourseEmail.text_message', autospec=True))
class TestOptoutCourseEmails(ModuleStoreTestCase):
"""
Test that optouts are referenced in sending course email.
"""
shard = 1
def setUp(self):
super(TestOptoutCourseEmails, self).setUp()
@@ -118,12 +117,13 @@ class TestOptoutCourseEmails(ModuleStoreTestCase):
self.assertIn(self.instructor.email, sent_addresses)
@attr(shard=1)
@patch('bulk_email.models.html_to_text', Mock(return_value='Mocking CourseEmail.text_message', autospec=True))
class TestACEOptoutCourseEmails(ModuleStoreTestCase):
"""
Test that optouts are referenced in sending course email.
"""
shard = 1
def setUp(self):
super(TestACEOptoutCourseEmails, self).setUp()
course_title = u"ẗëṡẗ title イ乇丂イ ᄊ乇丂丂ムg乇 キo尺 ムレレ тэѕт мэѕѕаБэ"

View File

@@ -16,7 +16,6 @@ from django.test.utils import override_settings
from django.utils.translation import get_language
from markupsafe import escape
from mock import Mock, patch
from nose.plugins.attrib import attr
from bulk_email.models import BulkEmailFlag, Optout
from bulk_email.tasks import _get_course_email_context, _get_source_address
@@ -26,6 +25,7 @@ from enrollment.api import update_enrollment
from lms.djangoapps.instructor_task.subtasks import update_subtask_status
from openedx.core.djangoapps.course_groups.cohorts import add_user_to_cohort
from openedx.core.djangoapps.course_groups.models import CourseCohort
from openedx.core.lib.tests import attr
from student.models import CourseEnrollment
from student.roles import CourseStaffRole
from student.tests.factories import CourseEnrollmentFactory, UserFactory

View File

@@ -13,7 +13,6 @@ from django.core.management import call_command
from django.urls import reverse
from django.db import DatabaseError
from mock import Mock, patch
from nose.plugins.attrib import attr
from opaque_keys.edx.locator import CourseLocator
from six import text_type
@@ -39,12 +38,12 @@ class EmailTestException(Exception):
@ddt.ddt
@attr(shard=1)
@patch('bulk_email.models.html_to_text', Mock(return_value='Mocking CourseEmail.text_message', autospec=True))
class TestEmailErrors(ModuleStoreTestCase):
"""
Test that errors from sending email are handled properly.
"""
shard = 1
ENABLED_CACHES = ['default', 'mongo_metadata_inheritance', 'loc_cache']

View File

@@ -3,7 +3,6 @@
Unit tests for bulk-email-related forms.
"""
from nose.plugins.attrib import attr
from opaque_keys.edx.locator import CourseLocator
from six import text_type
@@ -13,9 +12,9 @@ from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory
@attr(shard=1)
class CourseAuthorizationFormTest(ModuleStoreTestCase):
"""Test the CourseAuthorizationAdminForm form for Mongo-backed courses."""
shard = 1
def setUp(self):
super(CourseAuthorizationFormTest, self).setUp()

View File

@@ -7,7 +7,6 @@ import ddt
from django.core.management import call_command
from django.test import TestCase
from mock import Mock, patch
from nose.plugins.attrib import attr
from opaque_keys.edx.keys import CourseKey
from pytz import UTC
@@ -22,6 +21,7 @@ from bulk_email.models import (
)
from course_modes.models import CourseMode
from openedx.core.djangoapps.course_groups.models import CourseCohort
from openedx.core.lib.tests import attr
from student.tests.factories import UserFactory
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory

View File

@@ -7,7 +7,6 @@ from django.core import mail
from django.core.management import call_command
from django.urls import reverse
from mock import Mock, patch
from nose.plugins.attrib import attr
from six import text_type
from bulk_email.models import BulkEmailFlag, Optout
@@ -17,12 +16,13 @@ from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory
@attr(shard=1)
@patch('bulk_email.models.html_to_text', Mock(return_value='Mocking CourseEmail.text_message', autospec=True))
class TestOptoutCourseEmailsBySignal(ModuleStoreTestCase):
"""
Tests that the force_optout_all signal receiver opts the user out of course emails
"""
shard = 1
def setUp(self):
super(TestOptoutCourseEmailsBySignal, self).setUp()
self.course = CourseFactory.create(run='testcourse1', display_name="Test Course Title")

View File

@@ -27,7 +27,6 @@ from celery.states import FAILURE, SUCCESS # pylint: disable=no-name-in-module,
from django.conf import settings
from django.core.management import call_command
from mock import Mock, patch
from nose.plugins.attrib import attr
from opaque_keys.edx.locator import CourseLocator
from bulk_email.models import SEND_TO_LEARNERS, SEND_TO_MYSELF, SEND_TO_STAFF, CourseEmail, Optout
@@ -73,10 +72,10 @@ def my_update_subtask_status(entry_id, current_task_id, new_subtask_status):
update_subtask_status(entry_id, current_task_id, new_subtask_status)
@attr(shard=5)
@patch('bulk_email.models.html_to_text', Mock(return_value='Mocking CourseEmail.text_message', autospec=True))
class TestBulkEmailInstructorTask(InstructorTaskCourseTestCase):
"""Tests instructor task that send bulk email."""
shard = 5
def setUp(self):
super(TestBulkEmailInstructorTask, self).setUp()

View File

@@ -16,7 +16,6 @@ from django.conf import settings
from django.contrib.auth.models import User
from django.urls import Resolver404, resolve, reverse
from django.utils.timezone import now
from nose.plugins.attrib import attr
from oauth2_provider import models as dot_models
from opaque_keys.edx.keys import CourseKey
from provider.constants import CONFIDENTIAL
@@ -161,13 +160,13 @@ class CcxRestApiTest(CcxTestCase, APITestCase):
self.assertEqual(expected_field_errors, resp_dict_error)
@attr(shard=9)
@ddt.ddt
class CcxListTest(CcxRestApiTest):
"""
Test for the CCX REST APIs
"""
ENABLED_SIGNALS = ['course_published']
shard = 9
@classmethod
def setUpClass(cls):
@@ -872,13 +871,13 @@ class CcxListTest(CcxRestApiTest):
self.assertEqual(course_user, ccx_user)
@attr(shard=9)
@ddt.ddt
class CcxDetailTest(CcxRestApiTest):
"""
Test for the CCX REST APIs
"""
ENABLED_SIGNALS = ['course_published']
shard = 9
def setUp(self):
"""

View File

@@ -7,6 +7,7 @@ from datetime import datetime
import ddt
import mock
import pytest
from ccx_keys.locator import CCXLocator
from courseware.field_overrides import OverrideFieldData
from courseware.testutils import FieldOverrideTestMixin
@@ -16,8 +17,6 @@ from django.core.cache import caches
from django.test.client import RequestFactory
from django.test.utils import override_settings
from lms.djangoapps.ccx.tests.factories import CcxFactory
from nose.plugins.attrib import attr
from nose.plugins.skip import SkipTest
from opaque_keys.edx.keys import CourseKey
from openedx.core.djangoapps.content.block_structure.api import get_course_in_cache
from openedx.core.djangoapps.waffle_utils.testutils import WAFFLE_TABLES
@@ -37,7 +36,6 @@ from xmodule.modulestore.tests.utils import ProceduralCourseTestMixin
QUERY_COUNT_TABLE_BLACKLIST = WAFFLE_TABLES
@attr(shard=7)
@mock.patch.dict(
'django.conf.settings.FEATURES',
{
@@ -53,6 +51,7 @@ class FieldOverridePerformanceTestCase(FieldOverrideTestMixin, ProceduralCourseT
__test__ = False
# Tell Django to clean out all databases, not just default
multi_db = True
shard = 7
# TEST_DATA must be overridden by subclasses
TEST_DATA = None
@@ -204,13 +203,13 @@ class FieldOverridePerformanceTestCase(FieldOverrideTestMixin, ProceduralCourseT
'ccx': ('ccx.overrides.CustomCoursesForEdxOverrideProvider',)
}
if overrides == 'no_overrides' and view_as_ccx:
raise SkipTest("Can't view a ccx course if field overrides are disabled.")
pytest.skip("Can't view a ccx course if field overrides are disabled.")
if not enable_ccx and view_as_ccx:
raise SkipTest("Can't view a ccx course if ccx is disabled on the course")
pytest.skip("Can't view a ccx course if ccx is disabled on the course")
if self.MODULESTORE == TEST_DATA_MONGO_MODULESTORE and view_as_ccx:
raise SkipTest("Can't use a MongoModulestore test as a CCX course")
pytest.skip("Can't use a MongoModulestore test as a CCX course")
with self.settings(
XBLOCK_FIELD_DATA_WRAPPERS=['lms.djangoapps.courseware.field_overrides:OverrideModulestoreFieldData.wrap'],

View File

@@ -5,7 +5,6 @@ import json
from datetime import datetime, timedelta
import ddt
from nose.plugins.attrib import attr
from pytz import utc
from student.roles import CourseCcxCoachRole
@@ -18,12 +17,12 @@ from .factories import CcxFactory
@ddt.ddt
@attr(shard=7)
class TestCCX(ModuleStoreTestCase):
"""Unit tests for the CustomCourseForEdX model
"""
MODULESTORE = TEST_DATA_SPLIT_MODULESTORE
shard = 7
def setUp(self):
"""common setup for all tests"""

View File

@@ -8,7 +8,6 @@ import mock
import pytz
from ccx_keys.locator import CCXLocator
from django.test.utils import override_settings
from nose.plugins.attrib import attr
from courseware.courses import get_course_by_id
from courseware.field_overrides import OverrideFieldData
@@ -23,7 +22,6 @@ from xmodule.modulestore.tests.django_utils import TEST_DATA_SPLIT_MODULESTORE,
from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory
@attr(shard=7)
@override_settings(
XBLOCK_FIELD_DATA_WRAPPERS=['lms.djangoapps.courseware.field_overrides:OverrideModulestoreFieldData.wrap'],
MODULESTORE_FIELD_OVERRIDE_PROVIDERS=['ccx.overrides.CustomCoursesForEdxOverrideProvider'],
@@ -33,6 +31,7 @@ class TestFieldOverrides(FieldOverrideTestMixin, SharedModuleStoreTestCase):
Make sure field overrides behave in the expected manner.
"""
MODULESTORE = TEST_DATA_SPLIT_MODULESTORE
shard = 7
@classmethod
def setUpClass(cls):

View File

@@ -6,10 +6,7 @@ from smtplib import SMTPException
import mock
from ccx_keys.locator import CCXLocator
from nose.plugins.attrib import attr
from opaque_keys.edx.keys import CourseKey
from lms.djangoapps.ccx import utils
from lms.djangoapps.ccx.tests.factories import CcxFactory
from lms.djangoapps.ccx.tests.utils import CcxTestCase
from lms.djangoapps.ccx.utils import add_master_course_staff_to_ccx, ccx_course, remove_master_course_staff_from_ccx
@@ -22,10 +19,10 @@ from xmodule.modulestore.tests.django_utils import TEST_DATA_SPLIT_MODULESTORE,
from xmodule.modulestore.tests.factories import CourseFactory
@attr(shard=7)
class TestGetCCXFromCCXLocator(ModuleStoreTestCase):
"""Verify that get_ccx_from_ccx_locator functions properly"""
MODULESTORE = TEST_DATA_SPLIT_MODULESTORE
shard = 7
def setUp(self):
"""Set up a course, coach, ccx and user"""

View File

@@ -15,7 +15,6 @@ from django.test.utils import override_settings
from pytz import UTC
from django.utils.translation import ugettext as _
from mock import MagicMock, patch
from nose.plugins.attrib import attr
from opaque_keys.edx.keys import CourseKey
from capa.tests.response_xml_factory import StringResponseXMLFactory
@@ -38,6 +37,7 @@ from lms.djangoapps.grades.tasks import compute_all_grades_for_course
from lms.djangoapps.instructor.access import allow_access, list_with_level
from openedx.core.djangoapps.content.course_overviews.models import CourseOverview
from openedx.core.djangoapps.request_cache.middleware import RequestCache
from openedx.core.lib.tests import attr
from student.models import CourseEnrollment, CourseEnrollmentAllowed
from student.roles import CourseCcxCoachRole, CourseInstructorRole, CourseStaffRole
from student.tests.factories import AdminFactory, CourseEnrollmentFactory, UserFactory

View File

@@ -14,7 +14,6 @@ from django.test.utils import override_settings
from django.utils import timezone
from freezegun import freeze_time
from mock import patch
from nose.plugins.attrib import attr
from opaque_keys.edx.locator import CourseLocator
import pytz
@@ -33,6 +32,7 @@ from course_modes.tests.factories import CourseModeFactory
from courseware.tests.factories import GlobalStaffFactory
from lms.djangoapps.grades.tests.utils import mock_passing_grade
from microsite_configuration import microsite
from openedx.core.lib.tests import attr
from student.models import CourseEnrollment
from student.tests.factories import UserFactory
from util.testing import EventTestMixin

View File

@@ -1,11 +1,9 @@
"""Tests for the resubmit_error_certificates management command. """
import ddt
import pytest
from django.core.management import call_command
from django.core.management.base import CommandError
from django.test.utils import override_settings
from mock import patch
from nose.plugins.attrib import attr
from opaque_keys.edx.locator import CourseLocator
from six import text_type
@@ -15,6 +13,7 @@ from badges.tests.factories import BadgeAssertionFactory, CourseCompleteImageCon
from lms.djangoapps.certificates.models import CertificateStatuses, GeneratedCertificate
from course_modes.models import CourseMode
from lms.djangoapps.grades.tests.utils import mock_passing_grade
from openedx.core.lib.tests import attr
from student.tests.factories import CourseEnrollmentFactory, UserFactory
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory, check_mongo_calls

View File

@@ -3,7 +3,6 @@
from django.core.management import call_command
from django.core.management.base import CommandError
from django.test import TestCase
from nose.plugins.attrib import attr
from opaque_keys.edx.locator import CourseLocator
from six import text_type
@@ -11,10 +10,9 @@ from lms.djangoapps.certificates.models import GeneratedCertificate
from student.tests.factories import UserFactory
@attr(shard=1)
class CreateFakeCertTest(TestCase):
"""Tests for the create_fake_certs management command. """
shard = 1
USERNAME = "test"
COURSE_KEY = CourseLocator(org='edX', course='DemoX', run='Demo_Course')

View File

@@ -7,7 +7,6 @@ from django.core.exceptions import ValidationError
from django.core.files.uploadedfile import SimpleUploadedFile
from django.test import TestCase
from django.test.utils import override_settings
from nose.plugins.attrib import attr
from opaque_keys.edx.locator import CourseLocator
from path import Path as path
@@ -23,6 +22,7 @@ from lms.djangoapps.certificates.models import (
)
from lms.djangoapps.certificates.tests.factories import CertificateInvalidationFactory, GeneratedCertificateFactory
from lms.djangoapps.instructor_task.tests.factories import InstructorTaskFactory
from openedx.core.lib.tests import attr
from student.tests.factories import AdminFactory, UserFactory
from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory

View File

@@ -10,7 +10,6 @@ import pytz
from django.test import TestCase
from django.test.utils import override_settings
from mock import Mock, patch
from nose.plugins.attrib import attr
from opaque_keys.edx.locator import CourseLocator
# It is really unfortunate that we are using the XQueue client
@@ -31,10 +30,10 @@ from xmodule.modulestore.tests.factories import CourseFactory
@ddt.ddt
@attr(shard=1)
@override_settings(CERT_QUEUE='certificates')
class XQueueCertInterfaceAddCertificateTest(ModuleStoreTestCase):
"""Test the "add to queue" operation of the XQueue interface. """
shard = 1
def setUp(self):
super(XQueueCertInterfaceAddCertificateTest, self).setUp()
@@ -279,10 +278,10 @@ class XQueueCertInterfaceAddCertificateTest(ModuleStoreTestCase):
)
@attr(shard=1)
@override_settings(CERT_QUEUE='certificates')
class XQueueCertInterfaceExampleCertificateTest(TestCase):
"""Tests for the XQueue interface for certificate generation. """
shard = 1
COURSE_KEY = CourseLocator(org='test', course='test', run='test')

View File

@@ -10,7 +10,6 @@ from django.core.cache import cache
from django.urls import reverse
from django.test.client import Client
from django.test.utils import override_settings
from nose.plugins.attrib import attr
from opaque_keys.edx.locator import CourseLocator
from lms.djangoapps.certificates.api import get_certificate_url
@@ -37,10 +36,10 @@ FEATURES_WITH_CUSTOM_CERTS_ENABLED = {
FEATURES_WITH_CUSTOM_CERTS_ENABLED.update(FEATURES_WITH_CERTS_ENABLED)
@attr(shard=1)
@ddt.ddt
class UpdateExampleCertificateViewTest(CacheIsolationTestCase):
"""Tests for the XQueue callback that updates example certificates. """
shard = 1
COURSE_KEY = CourseLocator(org='test', course='test', run='test')
@@ -181,11 +180,12 @@ class UpdateExampleCertificateViewTest(CacheIsolationTestCase):
self.assertEqual(content['return_code'], 0)
@attr(shard=1)
class MicrositeCertificatesViewsTests(ModuleStoreTestCase):
"""
Tests for the microsite certificates web/html views
"""
shard = 1
def setUp(self):
super(MicrositeCertificatesViewsTests, self).setUp()
self.client = Client()

View File

@@ -11,7 +11,6 @@ from django.conf import settings
from django.urls import reverse
from django.test.client import Client, RequestFactory
from django.test.utils import override_settings
from django.utils import translation
from mock import patch
import ddt
@@ -38,7 +37,6 @@ from lms.djangoapps.badges.tests.factories import (
CourseCompleteImageConfigurationFactory
)
from lms.djangoapps.grades.tests.utils import mock_passing_grade
from nose.plugins.attrib import attr
from openedx.core.djangoapps.certificates.config import waffle
from openedx.core.djangoapps.dark_lang.models import DarkLangConfig
from openedx.core.lib.tests.assertions.events import assert_event_matches
@@ -242,12 +240,12 @@ class CommonCertificatesTestCase(ModuleStoreTestCase):
template.save()
@attr(shard=1)
@ddt.ddt
class CertificatesViewsTests(CommonCertificatesTestCase):
"""
Tests for the certificates web/html views
"""
shard = 1
def setUp(self):
super(CertificatesViewsTests, self).setUp()
@@ -1711,11 +1709,12 @@ class CertificatesViewsTests(CommonCertificatesTestCase):
)
@attr(shard=1)
class CertificateEventTests(CommonCertificatesTestCase, EventTrackingTestCase):
"""
Test events emitted by certificate handling.
"""
shard = 1
@override_settings(FEATURES=FEATURES_WITH_CERTS_ENABLED)
def test_certificate_evidence_event_emitted(self):
self.client.logout()

View File

@@ -7,7 +7,6 @@ from pytz import UTC
from django.conf import settings
from milestones.tests.utils import MilestonesTestCaseMixin
from mock import patch
from nose.plugins.attrib import attr
from badges.tests.factories import CourseCompleteImageConfigurationFactory
from lms.djangoapps.certificates.models import (
@@ -24,12 +23,12 @@ from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory
@attr(shard=1)
@ddt
class CertificatesModelTest(ModuleStoreTestCase, MilestonesTestCaseMixin):
"""
Tests for the GeneratedCertificate model
"""
shard = 1
def setUp(self):
super(CertificatesModelTest, self).setUp()

View File

@@ -7,7 +7,6 @@ import json
from django.urls import reverse
from django.test.client import RequestFactory
from mock import patch
from nose.plugins.attrib import attr
from six import text_type
from capa.tests.response_xml_factory import StringResponseXMLFactory
@@ -32,11 +31,12 @@ from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory
USER_COUNT = 11
@attr(shard=6)
class TestGetProblemGradeDistribution(SharedModuleStoreTestCase):
"""
Tests related to class_dashboard/dashboard_data.py
"""
shard = 6
@classmethod
def setUpClass(cls):
super(TestGetProblemGradeDistribution, cls).setUpClass()

View File

@@ -5,7 +5,6 @@ import json
from django.test.client import RequestFactory
from mock import patch
from nose.plugins.attrib import attr
from six import text_type
from class_dashboard import views
@@ -14,11 +13,11 @@ from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory
@attr(shard=1)
class TestViews(ModuleStoreTestCase):
"""
Tests related to class_dashboard/views.py
"""
shard = 1
def setUp(self):
super(TestViews, self).setUp()

View File

@@ -11,8 +11,6 @@ from django.conf import settings
from django.urls import reverse, reverse_lazy
from django.test import TestCase
from django.test.utils import override_settings
from edx_rest_api_client import exceptions
from nose.plugins.attrib import attr
from course_modes.models import CourseMode
from course_modes.tests.factories import CourseModeFactory
@@ -36,12 +34,13 @@ UTM_COOKIE_CONTENTS = {
}
@attr(shard=1)
@ddt.ddt
class BasketsViewTests(EnrollmentEventTestMixin, UserMixin, ModuleStoreTestCase):
"""
Tests for the commerce Baskets view.
"""
shard = 1
def _post_to_view(self, course_id=None, marketing_email_opt_in=False, include_utm_cookie=False):
"""
POST to the view being tested.
@@ -280,12 +279,12 @@ class BasketsViewTests(EnrollmentEventTestMixin, UserMixin, ModuleStoreTestCase)
self.assertEqual(self._post_to_view().status_code, 406)
@attr(shard=1)
class BasketOrderViewTests(UserMixin, TestCase):
""" Tests for the basket order view. """
view_name = 'commerce_api:v0:baskets:retrieve_order'
MOCK_ORDER = {'number': 1}
path = reverse_lazy(view_name, kwargs={'basket_id': 1})
shard = 1
def setUp(self):
super(BasketOrderViewTests, self).setUp()

View File

@@ -10,8 +10,6 @@ from django.contrib.auth.models import Permission
from django.urls import reverse, reverse_lazy
from django.test import TestCase
from django.test.utils import override_settings
from edx_rest_api_client import exceptions
from nose.plugins.attrib import attr
from rest_framework.utils.encoders import JSONEncoder
from course_modes.models import CourseMode
@@ -103,7 +101,6 @@ class CourseListViewTests(CourseApiViewTestMixin, ModuleStoreTestCase):
self.assertListEqual(actual, expected)
@attr(shard=3)
@ddt.ddt
class CourseRetrieveUpdateViewTests(CourseApiViewTestMixin, ModuleStoreTestCase):
""" Tests for CourseRetrieveUpdateView. """
@@ -112,6 +109,7 @@ class CourseRetrieveUpdateViewTests(CourseApiViewTestMixin, ModuleStoreTestCase)
NOW: datetime.now(),
None: None,
}
shard = 3
def setUp(self):
super(CourseRetrieveUpdateViewTests, self).setUp()
@@ -394,13 +392,13 @@ class CourseRetrieveUpdateViewTests(CourseApiViewTestMixin, ModuleStoreTestCase)
self.assertDictEqual(expected_dict, json.loads(response.content))
@attr(shard=1)
class OrderViewTests(UserMixin, TestCase):
""" Tests for the basket order view. """
view_name = 'commerce_api:v1:orders:detail'
ORDER_NUMBER = 'EDX-100001'
MOCK_ORDER = {'number': ORDER_NUMBER}
path = reverse_lazy(view_name, kwargs={'number': ORDER_NUMBER})
shard = 1
def setUp(self):
super(OrderViewTests, self).setUp()

View File

@@ -5,7 +5,6 @@ import json
import ddt
import mock
from django.urls import reverse
from nose.plugins.attrib import attr
from course_modes.models import CourseMode
from openedx.core.djangoapps.theming.tests.test_util import with_comprehensive_theme
@@ -27,10 +26,10 @@ class UserMixin(object):
self.client.login(username=self.user.username, password='test')
@attr(shard=1)
@ddt.ddt
class ReceiptViewTests(UserMixin, ModuleStoreTestCase):
""" Tests for the receipt view. """
shard = 1
def setUp(self):
"""

View File

@@ -11,18 +11,17 @@ from unittest import skipUnless
from django.conf import settings
from django.test import TestCase
from mock import patch
from nose.plugins.attrib import attr
from courseware.models import BaseStudentModuleHistory, StudentModule, StudentModuleHistory
from courseware.tests.factories import StudentModuleFactory, course_id, location
@attr(shard=1)
@skipUnless(settings.FEATURES["ENABLE_CSMH_EXTENDED"], "CSMH Extended needs to be enabled")
class TestStudentModuleHistoryBackends(TestCase):
""" Tests of data in CSMH and CSMHE """
# Tell Django to clean out all databases, not just default
multi_db = True
shard = 1
def setUp(self):
super(TestStudentModuleHistoryBackends, self).setUp()

View File

@@ -11,7 +11,6 @@ import httpretty
import mock
from django.core.exceptions import ValidationError
from django.test.client import RequestFactory
from nose.plugins.attrib import attr
from opaque_keys.edx.locator import CourseLocator
from pytz import UTC
from rest_framework.exceptions import PermissionDenied
@@ -50,6 +49,7 @@ from django_comment_common.models import (
from openedx.core.djangoapps.course_groups.models import CourseUserGroupPartitionGroup
from openedx.core.djangoapps.course_groups.tests.helpers import CohortFactory
from openedx.core.lib.exceptions import CourseNotFoundError, PageNotFoundError
from openedx.core.lib.tests import attr
from student.tests.factories import CourseEnrollmentFactory, UserFactory
from util.testing import UrlResetMixin
from xmodule.modulestore import ModuleStoreEnum

View File

@@ -4,7 +4,6 @@ Tests for discussion API permission logic
import itertools
import ddt
from nose.plugins.attrib import attr
from discussion_api.permissions import (
can_delete,
@@ -15,6 +14,7 @@ from discussion_api.permissions import (
from lms.lib.comment_client.comment import Comment
from lms.lib.comment_client.thread import Thread
from lms.lib.comment_client.user import User
from openedx.core.lib.tests import attr
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory

View File

@@ -8,7 +8,6 @@ import ddt
import httpretty
import mock
from django.test.client import RequestFactory
from nose.plugins.attrib import attr
from discussion_api.serializers import CommentSerializer, ThreadSerializer, get_context
from discussion_api.tests.utils import CommentsServiceMockMixin, make_minimal_cs_comment, make_minimal_cs_thread
@@ -23,6 +22,7 @@ from django_comment_common.models import (
from lms.lib.comment_client.comment import Comment
from lms.lib.comment_client.thread import Thread
from openedx.core.djangoapps.course_groups.tests.helpers import CohortFactory
from openedx.core.lib.tests import attr
from student.tests.factories import UserFactory
from util.testing import UrlResetMixin
from xmodule.modulestore import ModuleStoreEnum

View File

@@ -11,7 +11,6 @@ import ddt
import httpretty
import mock
from django.urls import reverse
from nose.plugins.attrib import attr
from pytz import UTC
from rest_framework.parsers import JSONParser
from rest_framework.test import APIClient
@@ -29,6 +28,7 @@ from discussion_api.tests.utils import (
from django_comment_client.tests.utils import ForumsEnableMixin
from openedx.core.djangoapps.user_api.accounts.image_helpers import get_profile_image_storage
from openedx.core.djangoapps.user_api.models import RetirementState, UserRetirementStatus
from openedx.core.lib.tests import attr
from openedx.core.lib.token_utils import JwtBuilder
from student.models import get_retired_username_by_username
from student.tests.factories import CourseEnrollmentFactory, UserFactory, SuperuserFactory

View File

@@ -6,14 +6,12 @@ import mock
from contextlib import contextmanager
import ddt
import pytest
from django.contrib.auth.models import User
from django.core.management import call_command
from django.urls import reverse
from django.test.client import RequestFactory
from eventtracking.processors.exceptions import EventEmissionExit
from mock import ANY, Mock, patch
from nose.plugins.attrib import attr
from nose.tools import assert_equal, assert_true
from opaque_keys.edx.keys import CourseKey
from six import text_type
@@ -41,6 +39,7 @@ from lms.lib.comment_client import Thread
from openedx.core.djangoapps.course_groups.cohorts import set_course_cohorted
from openedx.core.djangoapps.course_groups.tests.helpers import CohortFactory
from openedx.core.djangoapps.waffle_utils.testutils import WAFFLE_TABLES
from openedx.core.lib.tests import attr
from student.roles import CourseStaffRole, UserBasedRole
from student.tests.factories import CourseAccessRoleFactory, CourseEnrollmentFactory, UserFactory
from util.testing import UrlResetMixin

View File

@@ -3,7 +3,7 @@ import threading
import unittest
import urllib2
from nose.plugins.skip import SkipTest
import pytest
from django_comment_client.tests.mock_cs_server.mock_cs_server import MockCommentServiceServer
@@ -21,7 +21,7 @@ class MockCommentServiceServerTest(unittest.TestCase):
# This is a test of the test setup,
# so it does not need to run as part of the unit test suite
# You can re-enable it by commenting out the line below
raise SkipTest
pytest.skip()
# Create the server
server_port = 4567

View File

@@ -2,15 +2,15 @@ import json
import django.http
from django.test import TestCase
from nose.plugins.attrib import attr
from six import text_type
import django_comment_client.middleware as middleware
import lms.lib.comment_client
@attr(shard=1)
class AjaxExceptionTestCase(TestCase):
shard = 1
def setUp(self):
super(AjaxExceptionTestCase, self).setUp()
self.a = middleware.AjaxExceptionMiddleware()

View File

@@ -2,7 +2,6 @@
Tests for the django comment client integration models
"""
from django.test.testcases import TestCase
from nose.plugins.attrib import attr
from opaque_keys.edx.keys import CourseKey
import django_comment_common.models as models
@@ -10,12 +9,12 @@ from xmodule.modulestore.tests.django_utils import TEST_DATA_MIXED_MODULESTORE,
from xmodule.modulestore.tests.factories import ToyCourseFactory
@attr(shard=1)
class RoleClassTestCase(ModuleStoreTestCase):
"""
Tests for roles of the comment client service integration
"""
MODULESTORE = TEST_DATA_MIXED_MODULESTORE
shard = 1
def setUp(self):
super(RoleClassTestCase, self).setUp()
@@ -52,11 +51,12 @@ class RoleClassTestCase(ModuleStoreTestCase):
self.TA_role_2.inherit_permissions(self.TA_role)
@attr(shard=1)
class PermissionClassTestCase(TestCase):
"""
Tests for permissions of the comment client service integration
"""
shard = 1
def setUp(self):
super(PermissionClassTestCase, self).setUp()
self.permission = models.Permission.objects.get_or_create(name="test")[0]

View File

@@ -4,12 +4,10 @@ import json
import ddt
import mock
import pytest
from django.urls import reverse
from django.test import RequestFactory, TestCase
from mock import Mock, patch
from nose.plugins.attrib import attr
from pytz import UTC
from six import text_type
@@ -40,6 +38,7 @@ from openedx.core.djangoapps.course_groups.cohorts import set_course_cohorted
from openedx.core.djangoapps.course_groups.tests.helpers import CohortFactory, config_course_cohorts
from openedx.core.djangoapps.request_cache.middleware import RequestCache
from openedx.core.djangoapps.util.testing import ContentGroupTestCase
from openedx.core.lib.tests import attr
from student.roles import CourseStaffRole
from student.tests.factories import AdminFactory, CourseEnrollmentFactory, UserFactory
from xmodule.modulestore import ModuleStoreEnum

View File

@@ -6,7 +6,6 @@ import urlparse
from contextlib import contextmanager
from datetime import datetime
from unittest import skipUnless
import mock
import ddt
import jwt
@@ -18,7 +17,6 @@ from django.test.client import RequestFactory
from django.test.utils import override_settings
from edx_oauth2_provider.tests.factories import ClientFactory
from mock import MagicMock, patch
from nose.plugins.attrib import attr
from provider.oauth2.models import Client
from courseware.model_data import FieldDataCache
@@ -30,6 +28,7 @@ from edxnotes.decorators import edxnotes
from edxnotes.exceptions import EdxNotesParseError, EdxNotesServiceUnavailable
from edxnotes.plugins import EdxNotesTab
from openedx.core.djangoapps.user_api.models import RetirementState, UserRetirementStatus
from openedx.core.lib.tests import attr
from openedx.core.lib.token_utils import JwtBuilder
from student.tests.factories import CourseEnrollmentFactory, SuperuserFactory, UserFactory
from xmodule.modulestore import ModuleStoreEnum

View File

@@ -5,7 +5,6 @@ from ddt import data, ddt, unpack
from milestones import api as milestones_api
from milestones.tests.utils import MilestonesTestCaseMixin
from mock import Mock, patch
from nose.plugins.attrib import attr
from courseware.tests.helpers import LoginEnrollmentTestCase
from gating.api import evaluate_prerequisite
@@ -57,12 +56,12 @@ class GatingTestCase(LoginEnrollmentTestCase, ModuleStoreTestCase):
)
@attr(shard=3)
@ddt
class TestEvaluatePrerequisite(GatingTestCase, MilestonesTestCaseMixin):
"""
Tests for the evaluate_prerequisite function
"""
shard = 3
def setUp(self):
super(TestEvaluatePrerequisite, self).setUp()

View File

@@ -5,7 +5,6 @@ import ddt
from completion import waffle as completion_waffle
from milestones import api as milestones_api
from milestones.tests.utils import MilestonesTestCaseMixin
from nose.plugins.attrib import attr
from lms.djangoapps.courseware.access import has_access
from lms.djangoapps.grades.course_grade_factory import CourseGradeFactory
@@ -19,13 +18,14 @@ from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory
@attr(shard=3)
@ddt.ddt
class TestGatedContent(MilestonesTestCaseMixin, SharedModuleStoreTestCase):
"""
Base TestCase class for setting up a basic course structure
and testing the gating feature
"""
shard = 3
@classmethod
def setUpClass(cls):
super(TestGatedContent, cls).setUpClass()

View File

@@ -1,8 +1,6 @@
import itertools
from nose.plugins.attrib import attr
import ddt
import django
from courseware.access import has_access
from django.conf import settings
from lms.djangoapps.grades.config.tests.utils import persistent_grades_feature_flags
@@ -240,13 +238,13 @@ class TestCourseGradeFactory(GradeTestBase):
self.assertEqual(expected_summary, actual_summary)
@attr(shard=1)
class TestGradeIteration(SharedModuleStoreTestCase):
"""
Test iteration through student course grades.
"""
COURSE_NUM = "1000"
COURSE_NAME = "grading_test_course"
shard = 1
@classmethod
def setUpClass(cls):

View File

@@ -11,7 +11,6 @@ from django.db.models import Q
from edx_proctoring.api import create_exam
from edx_proctoring.models import ProctoredExamStudentAttempt
from mock import MagicMock, Mock, patch
from nose.plugins.attrib import attr
from opaque_keys.edx.locator import UsageKey
from six import text_type
@@ -50,9 +49,9 @@ from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory
@attr(shard=3)
class TestAnalyticsBasic(ModuleStoreTestCase):
""" Test basic analytics functions. """
shard = 3
def setUp(self):
super(TestAnalyticsBasic, self).setUp()

View File

@@ -3,7 +3,6 @@ Test for LMS instructor background task queue management
"""
import ddt
from mock import MagicMock, Mock, patch
from nose.plugins.attrib import attr
from bulk_email.models import SEND_TO_LEARNERS, SEND_TO_MYSELF, SEND_TO_STAFF, CourseEmail
from lms.djangoapps.certificates.models import CertificateGenerationHistory, CertificateStatuses
@@ -89,10 +88,10 @@ class InstructorTaskReportTest(InstructorTaskTestCase):
self.assertEquals(set(task_ids), set())
@attr(shard=3)
@ddt.ddt
class InstructorTaskModuleSubmitTest(InstructorTaskModuleTestCase):
"""Tests API methods that involve the submission of module-based background tasks."""
shard = 3
def setUp(self):
super(InstructorTaskModuleSubmitTest, self).setUp()
@@ -211,10 +210,10 @@ class InstructorTaskModuleSubmitTest(InstructorTaskModuleTestCase):
task_function(self.create_task_request(self.instructor), location, **params)
@attr(shard=3)
@patch('bulk_email.models.html_to_text', Mock(return_value='Mocking CourseEmail.text_message', autospec=True))
class InstructorTaskCourseSubmitTest(TestReportMixin, InstructorTaskCourseTestCase):
"""Tests API methods that involve the submission of course-based background tasks."""
shard = 3
def setUp(self):
super(InstructorTaskCourseSubmitTest, self).setUp()

View File

@@ -15,7 +15,6 @@ from celery.states import FAILURE, SUCCESS
from django.contrib.auth.models import User
from django.urls import reverse
from mock import patch
from nose.plugins.attrib import attr
from six import text_type
from capa.responsetypes import StudentInputError
@@ -66,7 +65,6 @@ class TestIntegrationTask(InstructorTaskModuleTestCase):
self.assertEqual(status['message'], expected_message)
@attr(shard=3)
@ddt.ddt
class TestRescoringTask(TestIntegrationTask):
"""
@@ -74,6 +72,7 @@ class TestRescoringTask(TestIntegrationTask):
Exercises real problems with a minimum of patching.
"""
shard = 3
def setUp(self):
super(TestRescoringTask, self).setUp()

View File

@@ -13,7 +13,6 @@ import ddt
from celery.states import FAILURE, SUCCESS
from django.utils.translation import ugettext_noop
from mock import MagicMock, Mock, patch
from nose.plugins.attrib import attr
from opaque_keys.edx.locations import i4xEncoder
from course_modes.models import CourseMode
@@ -32,6 +31,7 @@ from lms.djangoapps.instructor_task.tasks import (
from lms.djangoapps.instructor_task.tasks_helper.misc import upload_ora2_data
from lms.djangoapps.instructor_task.tests.factories import InstructorTaskFactory
from lms.djangoapps.instructor_task.tests.test_base import InstructorTaskModuleTestCase
from openedx.core.lib.tests import attr
from xmodule.modulestore.exceptions import ItemNotFoundError
PROBLEM_URL_NAME = "test_urlname"

View File

@@ -27,7 +27,6 @@ from django.test.utils import override_settings
from freezegun import freeze_time
from instructor_analytics.basic import UNAVAILABLE, list_problem_responses
from mock import MagicMock, Mock, patch, ANY
from nose.plugins.attrib import attr
from pytz import UTC
from shoppingcart.models import (
Coupon,
@@ -1004,12 +1003,11 @@ class TestProblemGradeReport(TestReportMixin, InstructorTaskModuleTestCase):
])
@attr(shard=3)
class TestProblemReportSplitTestContent(TestReportMixin, TestConditionalContent, InstructorTaskModuleTestCase):
"""
Test the problem report on a course that has split tests.
"""
shard = 3
OPTION_1 = 'Option 1'
OPTION_2 = 'Option 2'
@@ -2122,13 +2120,13 @@ class TestGradeReportEnrollmentAndCertificateInfo(TestReportMixin, InstructorTas
self._verify_csv_data(user.username, expected_output)
@attr(shard=3)
@ddt.ddt
@override_settings(CERT_QUEUE='test-queue')
class TestCertificateGeneration(InstructorTaskModuleTestCase):
"""
Test certificate generation task works.
"""
shard = 3
ENABLED_CACHES = ['default', 'mongo_metadata_inheritance', 'loc_cache']

View File

@@ -2,7 +2,6 @@
Tests of the LMS XBlock Mixin
"""
import ddt
from nose.plugins.attrib import attr
from lms_xblock.mixin import (
INVALID_USER_PARTITION_GROUP_VALIDATION_COMPONENT,
@@ -11,6 +10,7 @@ from lms_xblock.mixin import (
INVALID_USER_PARTITION_VALIDATION_UNIT,
NONSENSICAL_ACCESS_RESTRICTION
)
from openedx.core.lib.tests import attr
from xblock.validation import ValidationMessage
from xmodule.modulestore import ModuleStoreEnum
from xmodule.modulestore.tests.factories import CourseFactory, ToyCourseFactory, ItemFactory