Unverified Commit 3d5fef78 by Brian Mesick Committed by GitHub

Merge pull request #16655 from edx/bmedx/django111_tag_test_failures_lms_2

Tag LMS Unit 2 tests that fail in Django 1.11
parents 4a0d6264 d827d47b
"""
Tests use cases related to LMS Entrance Exam behavior, such as gated content access (TOC)
"""
import pytest
from django.core.urlresolvers import reverse
from django.test.client import RequestFactory
from mock import Mock, patch
from capa.tests.response_xml_factory import MultipleChoiceResponseXMLFactory
from courseware.entrance_exams import (
course_has_entrance_exam,
......@@ -12,10 +17,7 @@ from courseware.model_data import FieldDataCache
from courseware.module_render import get_module, handle_xblock_callback, toc_for_course
from courseware.tests.factories import InstructorFactory, StaffFactory, UserFactory
from courseware.tests.helpers import LoginEnrollmentTestCase
from django.core.urlresolvers import reverse
from django.test.client import RequestFactory
from milestones.tests.utils import MilestonesTestCaseMixin
from mock import Mock, patch
from nose.plugins.attrib import attr
from openedx.core.djangoapps.waffle_utils.testutils import override_waffle_flag
from openedx.core.djangolib.testing.utils import get_mock_request
......@@ -37,6 +39,7 @@ from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory
@attr(shard=2)
@patch.dict('django.conf.settings.FEATURES', {'ENTRANCE_EXAMS': True})
@pytest.mark.django111_expected_failure
class EntranceExamTestCases(LoginEnrollmentTestCase, ModuleStoreTestCase, MilestonesTestCaseMixin):
"""
Check that content is properly gated.
......
......@@ -11,6 +11,7 @@ from urllib import quote, urlencode
from uuid import uuid4
import ddt
import pytest
from django.conf import settings
from django.contrib.auth.models import AnonymousUser
from django.core.urlresolvers import reverse, reverse_lazy
......@@ -206,6 +207,7 @@ class TestJumpTo(ModuleStoreTestCase):
@attr(shard=2)
@ddt.ddt
@pytest.mark.django111_expected_failure
class IndexQueryTestCase(ModuleStoreTestCase):
"""
Tests for query count.
......@@ -248,6 +250,7 @@ class IndexQueryTestCase(ModuleStoreTestCase):
@attr(shard=2)
@ddt.ddt
@pytest.mark.django111_expected_failure
class ViewsTestCase(ModuleStoreTestCase):
"""
Tests for views.py methods.
......
......@@ -6,6 +6,7 @@ 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.core.urlresolvers import reverse
......@@ -75,6 +76,7 @@ class MockRequestSetupMixin(object):
@attr(shard=2)
@patch('lms.lib.comment_client.utils.requests.request', autospec=True)
@pytest.mark.django111_expected_failure
class CreateThreadGroupIdTestCase(
MockRequestSetupMixin,
CohortedTestCase,
......@@ -495,6 +497,7 @@ class ViewsTestCase(
with self.assert_discussion_signals('thread_created'):
self.create_thread_helper(mock_request)
@pytest.mark.django111_expected_failure
def test_create_thread_standalone(self, mock_request):
team = CourseTeamFactory.create(
name="A Team",
......@@ -1408,6 +1411,7 @@ class CreateSubCommentUnicodeTestCase(
@disable_signal(views, 'comment_created')
@disable_signal(views, 'comment_voted')
@disable_signal(views, 'comment_deleted')
@pytest.mark.django111_expected_failure
class TeamsPermissionsTestCase(ForumsEnableMixin, UrlResetMixin, SharedModuleStoreTestCase, MockRequestSetupMixin):
# Most of the test points use the same ddt data.
# args: user, commentable_id, status_code
......@@ -1874,6 +1878,7 @@ class ForumEventTestCase(ForumsEnableMixin, SharedModuleStoreTestCase, MockReque
{'comment_id': 'dummy_comment_id'}
))
@ddt.unpack
@pytest.mark.django111_expected_failure
def test_team_events(self, view_name, event_name, view_data, view_kwargs, mock_request, mock_emit):
user = self.student
team = CourseTeamFactory.create(discussion_topic_id=TEAM_COMMENTABLE_ID)
......
......@@ -2,6 +2,7 @@
Tests for bookmarks api.
"""
import ddt
import pytest
from mock import patch
from nose.plugins.attrib import attr
......@@ -39,6 +40,7 @@ class BookmarkApiEventTestMixin(object):
@attr(shard=2)
@ddt.ddt
@skip_unless_lms
@pytest.mark.django111_expected_failure
class BookmarksAPITests(BookmarkApiEventTestMixin, BookmarksTestsBase):
"""
These tests cover the parts of the API methods.
......
"""
Tests for Bookmarks models.
"""
from contextlib import contextmanager
import datetime
from contextlib import contextmanager
import ddt
from freezegun import freeze_time
import mock
from nose.plugins.attrib import attr
import pytest
import pytz
from freezegun import freeze_time
from nose.plugins.attrib import attr
from opaque_keys.edx.keys import UsageKey
from opaque_keys.edx.locator import CourseLocator, BlockUsageLocator
from xmodule.modulestore import ModuleStoreEnum
from xmodule.modulestore.django import modulestore
from xmodule.modulestore.tests.factories import check_mongo_calls, CourseFactory, ItemFactory
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from opaque_keys.edx.locator import BlockUsageLocator, CourseLocator
from openedx.core.djangolib.testing.utils import skip_unless_lms
from student.tests.factories import AdminFactory, UserFactory
from xmodule.modulestore import ModuleStoreEnum
from xmodule.modulestore.django import modulestore
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory, check_mongo_calls
from .. import DEFAULT_FIELDS, OPTIONAL_FIELDS, PathItem
from ..models import Bookmark, XBlockCache, parse_path_data
......@@ -264,6 +265,7 @@ class BookmarkModelTests(BookmarksTestsBase):
(ModuleStoreEnum.Type.split, 'html_1', ['chapter_1', 'sequential_2', 'vertical_2'], 2),
)
@ddt.unpack
@pytest.mark.django111_expected_failure
def test_path_and_queries_on_create(self, store_type, block_to_bookmark, ancestors_attrs, expected_mongo_calls):
"""
In case of mongo, 1 query is used to fetch the block, and 2
......@@ -287,6 +289,7 @@ class BookmarkModelTests(BookmarksTestsBase):
self.assertIsNotNone(bookmark.xblock_cache)
self.assertEqual(bookmark.xblock_cache.paths, [])
@pytest.mark.django111_expected_failure
def test_create_bookmark_success(self):
"""
Tests creation of bookmark.
......@@ -309,6 +312,7 @@ class BookmarkModelTests(BookmarksTestsBase):
self.assertNotEqual(bookmark, bookmark3)
self.assert_bookmark_model_is_valid(bookmark3, bookmark_data_different_user)
@pytest.mark.django111_expected_failure
def test_create_bookmark_successfully_with_display_name_none(self):
"""
Tests creation of bookmark with display_name None.
......@@ -327,6 +331,7 @@ class BookmarkModelTests(BookmarksTestsBase):
)
@ddt.unpack
@mock.patch('openedx.core.djangoapps.bookmarks.models.Bookmark.get_path')
@pytest.mark.django111_expected_failure
def test_path(self, seconds_delta, paths, get_path_call_count, mock_get_path):
block_path = [PathItem(UsageKey.from_string(EXAMPLE_USAGE_KEY_1), '1')]
......@@ -364,6 +369,7 @@ class BookmarkModelTests(BookmarksTestsBase):
(ModuleStoreEnum.Type.split, 2, 4, 2),
)
@ddt.unpack
@pytest.mark.django111_expected_failure
def test_get_path_queries(self, store_type, children_per_block, depth, expected_mongo_calls):
"""
In case of mongo, 2 queries are used by path_to_location(), and then
......@@ -382,6 +388,7 @@ class BookmarkModelTests(BookmarksTestsBase):
path = Bookmark.get_path(block.location)
self.assertEqual(len(path), depth - 2)
@pytest.mark.django111_expected_failure
def test_get_path_in_case_of_exceptions(self):
user = UserFactory.create()
......
"""
Tests for bookmark services.
"""
from nose.plugins.attrib import attr
import pytest
from nose.plugins.attrib import attr
from opaque_keys.edx.keys import UsageKey
from openedx.core.djangolib.testing.utils import skip_unless_lms
......@@ -12,6 +13,7 @@ from .test_models import BookmarksTestsBase
@attr(shard=2)
@skip_unless_lms
@pytest.mark.django111_expected_failure
class BookmarksServiceTests(BookmarksTestsBase):
"""
Tests the Bookmarks service.
......
......@@ -2,11 +2,11 @@
Tests for tasks.
"""
import ddt
import pytest
from nose.plugins.attrib import attr
from xmodule.modulestore import ModuleStoreEnum
from xmodule.modulestore.tests.factories import check_mongo_calls, ItemFactory
from ..models import XBlockCache
from ..tasks import _calculate_course_xblocks_data, _update_xblocks_cache
from .test_models import BookmarksTestsBase
......@@ -14,6 +14,7 @@ from .test_models import BookmarksTestsBase
@attr(shard=2)
@ddt.ddt
@pytest.mark.django111_expected_failure
class XBlockCacheTaskTests(BookmarksTestsBase):
"""
Test the XBlockCache model.
......
"""
Tests for bookmark views.
"""
import ddt
import json
from nose.plugins.attrib import attr
import urllib
import ddt
import pytest
from django.conf import settings
from django.core.urlresolvers import reverse
from mock import patch
from nose.plugins.attrib import attr
from rest_framework.test import APIClient
from openedx.core.djangolib.testing.utils import skip_unless_lms
from xmodule.modulestore import ModuleStoreEnum
from .test_models import BookmarksTestsBase
from .test_api import BookmarkApiEventTestMixin
from .test_models import BookmarksTestsBase
# pylint: disable=no-member
......@@ -67,6 +66,7 @@ class BookmarksViewsTestsBase(BookmarksTestsBase, BookmarkApiEventTestMixin):
@attr(shard=2)
@ddt.ddt
@skip_unless_lms
@pytest.mark.django111_expected_failure
class BookmarksListViewTests(BookmarksViewsTestsBase):
"""
This contains the tests for GET & POST methods of bookmark.views.BookmarksListView class
......@@ -372,6 +372,7 @@ class BookmarksListViewTests(BookmarksViewsTestsBase):
@attr(shard=2)
@ddt.ddt
@skip_unless_lms
@pytest.mark.django111_expected_failure
class BookmarksDetailViewTests(BookmarksViewsTestsBase):
"""
This contains the tests for GET & DELETE methods of bookmark.views.BookmarksDetailView class
......
......@@ -5,44 +5,45 @@ import datetime
import json
import ddt
import httpretty
import mock
import pytest
import pytz
from django.contrib.auth.models import User
from django.core import mail
from django.test.utils import override_settings
from django.db import connection
from django.test.utils import override_settings
from nose.plugins.attrib import attr
import httpretty
from lms.djangoapps.commerce.tests import TEST_API_URL
import mock
import pytz
from opaque_keys.edx.keys import CourseKey
from course_modes.models import CourseMode
from lms.djangoapps.commerce.tests import TEST_API_URL
from openedx.core.djangoapps.credit import api
from openedx.core.djangoapps.credit.email_utils import get_credit_provider_display_names, make_providers_strings
from openedx.core.djangoapps.credit.exceptions import (
InvalidCreditRequirements,
CreditRequestNotFound,
InvalidCreditCourse,
RequestAlreadyCompleted,
UserIsNotEligible,
InvalidCreditRequirements,
InvalidCreditStatus,
CreditRequestNotFound,
RequestAlreadyCompleted,
UserIsNotEligible
)
from openedx.core.djangoapps.credit.models import (
CreditConfig,
CreditCourse,
CreditEligibility,
CreditProvider,
CreditRequest,
CreditRequirement,
CreditRequirementStatus,
CreditEligibility,
CreditRequest
CreditRequirementStatus
)
from openedx.core.djangolib.testing.utils import skip_unless_lms
from course_modes.models import CourseMode
from student.models import CourseEnrollment
from student.tests.factories import UserFactory
from util.date_utils import from_timestamp
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory
TEST_CREDIT_PROVIDER_SECRET_KEY = "931433d583c84ca7ba41784bad3232e6"
TEST_ECOMMERCE_WORKER = 'test_worker'
......@@ -205,6 +206,7 @@ class CreditApiTestBase(ModuleStoreTestCase):
@attr(shard=2)
@skip_unless_lms
@ddt.ddt
@pytest.mark.django111_expected_failure
class CreditRequirementApiTests(CreditApiTestBase):
"""
Test Python API for credit requirements and eligibility.
......
......@@ -6,11 +6,12 @@ import uuid
import ddt
import httpretty
import mock
import pytest
from django.conf import settings
from django.core.urlresolvers import reverse
from django.test import TestCase
from django.test.utils import override_settings
import mock
from nose.plugins.attrib import attr
from pytz import utc
......@@ -20,28 +21,27 @@ from lms.djangoapps.commerce.tests.test_utils import update_commerce_config
from lms.djangoapps.commerce.utils import EcommerceService
from lms.djangoapps.grades.tests.utils import mock_passing_grade
from openedx.core.djangoapps.catalog.tests.factories import (
generate_course_run_key,
ProgramFactory,
CourseFactory,
CourseRunFactory,
ProgramFactory,
SeatFactory,
generate_course_run_key
)
from openedx.core.djangoapps.programs.tests.factories import ProgressFactory
from openedx.core.djangoapps.programs.utils import (
DEFAULT_ENROLLMENT_START_DATE,
ProgramProgressMeter,
ProgramDataExtender,
ProgramMarketingDataExtender,
get_certificates,
ProgramProgressMeter,
get_certificates
)
from openedx.core.djangoapps.site_configuration.tests.factories import SiteFactory
from openedx.core.djangolib.testing.utils import skip_unless_lms
from student.tests.factories import AnonymousUserFactory, UserFactory, CourseEnrollmentFactory
from student.tests.factories import AnonymousUserFactory, CourseEnrollmentFactory, UserFactory
from util.date_utils import strftime_localized
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory as ModuleStoreCourseFactory
CERTIFICATES_API_MODULE = 'lms.djangoapps.certificates.api'
ECOMMERCE_URL_ROOT = 'https://ecommerce.example.com'
UTILS_MODULE = 'openedx.core.djangoapps.programs.utils'
......@@ -51,6 +51,7 @@ UTILS_MODULE = 'openedx.core.djangoapps.programs.utils'
@attr(shard=2)
@skip_unless_lms
@mock.patch(UTILS_MODULE + '.get_programs')
@pytest.mark.django111_expected_failure
class TestProgramProgressMeter(TestCase):
"""Tests of the program progress utility class."""
def setUp(self):
......
......@@ -6,6 +6,7 @@ Most of the functionality is covered in test_views.py.
import re
import ddt
import pytest
from dateutil.parser import parse as parse_datetime
from django.conf import settings
......@@ -14,11 +15,10 @@ from django.core import mail
from django.test import TestCase
from django.test.client import RequestFactory
from mock import Mock, patch
from six import iteritems
import ddt
from nose.plugins.attrib import attr
from nose.tools import raises
from six import iteritems
from openedx.core.djangoapps.user_api.accounts import PRIVATE_VISIBILITY, USERNAME_MAX_LENGTH
from openedx.core.djangoapps.user_api.accounts.api import (
activate_account,
......@@ -409,6 +409,7 @@ class AccountCreationActivationAndPasswordChangeTest(TestCase):
activate_account(u'invalid')
@skip_unless_lms
@pytest.mark.django111_expected_failure
def test_request_password_change(self):
# Create and activate an account
activation_key = create_account(self.USERNAME, self.PASSWORD, self.EMAIL)
......@@ -427,6 +428,7 @@ class AccountCreationActivationAndPasswordChangeTest(TestCase):
self.assertIsNot(result, None)
@skip_unless_lms
@pytest.mark.django111_expected_failure
def test_request_password_change_invalid_user(self):
with self.assertRaises(UserNotFound):
request_password_change(self.EMAIL, self.IS_SECURE)
......
......@@ -3,36 +3,40 @@
Test cases to cover Accounts-related behaviors of the User API application
"""
import datetime
import ddt
import hashlib
import json
import unittest
from copy import deepcopy
from mock import patch
from nose.plugins.attrib import attr
from pytz import UTC
import ddt
import pytest
from django.conf import settings
from django.core.urlresolvers import reverse
from django.test import TestCase
from django.test.testcases import TransactionTestCase
from django.test.utils import override_settings
from mock import patch
from nose.plugins.attrib import attr
from pytz import UTC
from rest_framework import status
from rest_framework.test import APITestCase, APIClient
from rest_framework.test import APIClient, APITestCase
from .. import PRIVATE_VISIBILITY, ALL_USERS_VISIBILITY
from openedx.core.djangoapps.user_api.accounts import ACCOUNT_VISIBILITY_PREF_KEY
from openedx.core.djangoapps.user_api.models import UserPreference
from openedx.core.djangoapps.user_api.preferences.api import set_user_preference
from openedx.core.djangolib.testing.utils import CacheIsolationTestCase, skip_unless_lms
from openedx.core.lib.token_utils import JwtBuilder
from student.models import UserProfile, LanguageProficiency, PendingEmailChange
from student.models import LanguageProficiency, PendingEmailChange, UserProfile
from student.tests.factories import (
ContentTypeFactory, TEST_PASSWORD, PermissionFactory, SuperuserFactory, UserFactory
TEST_PASSWORD,
ContentTypeFactory,
PermissionFactory,
SuperuserFactory,
UserFactory
)
from .. import ALL_USERS_VISIBILITY, PRIVATE_VISIBILITY
TEST_PROFILE_IMAGE_UPLOADED_AT = datetime.datetime(2002, 1, 9, 15, 43, 01, tzinfo=UTC)
TEST_PROFILE_IMAGE_UPLOADED_AT = datetime.datetime(2002, 1, 9, 15, 43, 1, tzinfo=UTC)
# this is used in one test to check the behavior of profile image url
......@@ -297,6 +301,7 @@ class TestAccountsAPI(CacheIsolationTestCase, UserAPITestCase):
# This is needed when testing CMS as the patching is still executed even though the
# suite is skipped.
@patch.dict(getattr(settings, "ACCOUNT_VISIBILITY_CONFIGURATION", {}), {"default_visibility": "all_users"})
@pytest.mark.django111_expected_failure
def test_get_account_different_user_visible(self):
"""
Test that a client (logged in) can only get the shareable fields for a different user.
......@@ -312,6 +317,7 @@ class TestAccountsAPI(CacheIsolationTestCase, UserAPITestCase):
# This is needed when testing CMS as the patching is still executed even though the
# suite is skipped.
@patch.dict(getattr(settings, "ACCOUNT_VISIBILITY_CONFIGURATION", {}), {"default_visibility": "private"})
@pytest.mark.django111_expected_failure
def test_get_account_different_user_private(self):
"""
Test that a client (logged in) can only get the shareable fields for a different user.
......@@ -333,6 +339,7 @@ class TestAccountsAPI(CacheIsolationTestCase, UserAPITestCase):
("staff_client", "staff_user", ALL_USERS_VISIBILITY),
)
@ddt.unpack
@pytest.mark.django111_expected_failure
def test_get_account_private_visibility(self, api_client, requesting_username, preference_visibility):
"""
Test the return from GET based on user visibility setting.
......@@ -611,6 +618,7 @@ class TestAccountsAPI(CacheIsolationTestCase, UserAPITestCase):
{'full': 50, 'medium': 30, 'small': 10},
clear=True
)
@pytest.mark.django111_expected_failure
def test_patch_email(self):
"""
Test that the user can request an email change through the accounts API.
......
......@@ -7,29 +7,30 @@ from __future__ import unicode_literals
import itertools
import json
import unittest
from collections import namedtuple
from datetime import datetime, timedelta
import ddt
from datetime import datetime, timedelta
import pytest
from django.conf import settings
from django.conf.urls import url, include
from django.conf.urls import include, url
from django.contrib.auth.models import User
from django.http import HttpResponse
from django.test import TestCase
from django.utils.http import urlencode
from nose.plugins.attrib import attr
from oauth2_provider import models as dot_models
from provider import constants, scope
from rest_framework import status
from rest_framework.permissions import IsAuthenticated
from rest_framework.test import APIRequestFactory, APIClient
from rest_framework.test import APIClient, APIRequestFactory
from rest_framework.views import APIView
from rest_framework_oauth import permissions
from rest_framework_oauth.compat import oauth2_provider, oauth2_provider_scope
import unittest
from openedx.core.djangoapps.oauth_dispatch import adapters
from openedx.core.lib.api import authentication
from provider import constants, scope
factory = APIRequestFactory() # pylint: disable=invalid-name
......@@ -74,6 +75,7 @@ urlpatterns = [
@attr(shard=2)
@ddt.ddt
@unittest.skipUnless(settings.FEATURES.get("ENABLE_OAUTH2_PROVIDER"), "OAuth2 not enabled")
@pytest.mark.django111_expected_failure
class OAuth2Tests(TestCase):
"""OAuth 2.0 authentication"""
urls = 'openedx.core.lib.api.tests.test_authentication'
......
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