Commit 93464298 by Jose Antonio Gonzalez

Merge remote-tracking branch 'upstream/master' into…

Merge remote-tracking branch 'upstream/master' into proversity/add-recover-password-endpoint [ci skip]
parents 7a1dd74a b6d9dfb2
......@@ -993,7 +993,7 @@ class TranscriptPreferencesTestCase(VideoUploadTestBase, CourseTestCase):
(
{
'provider': TranscriptProvider.THREE_PLAY_MEDIA,
'three_play_turnaround': 'default',
'three_play_turnaround': 'standard',
'video_source_language': 'zh',
},
True,
......@@ -1003,7 +1003,7 @@ class TranscriptPreferencesTestCase(VideoUploadTestBase, CourseTestCase):
(
{
'provider': TranscriptProvider.THREE_PLAY_MEDIA,
'three_play_turnaround': 'default',
'three_play_turnaround': 'standard',
'video_source_language': 'es',
'preferred_languages': ['es', 'ur']
},
......@@ -1014,7 +1014,7 @@ class TranscriptPreferencesTestCase(VideoUploadTestBase, CourseTestCase):
(
{
'provider': TranscriptProvider.THREE_PLAY_MEDIA,
'three_play_turnaround': 'default',
'three_play_turnaround': 'standard',
'video_source_language': 'en',
'preferred_languages': ['es', 'ur']
},
......@@ -1038,7 +1038,7 @@ class TranscriptPreferencesTestCase(VideoUploadTestBase, CourseTestCase):
(
{
'provider': TranscriptProvider.THREE_PLAY_MEDIA,
'three_play_turnaround': 'default',
'three_play_turnaround': 'standard',
'preferred_languages': ['en'],
'video_source_language': 'en',
},
......
......@@ -2,10 +2,13 @@ import unittest
from django.conf import settings
from django.test import RequestFactory
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from entitlements.api.v1.serializers import CourseEntitlementSerializer
from entitlements.tests.factories import CourseEntitlementFactory
# Entitlements is not in CMS' INSTALLED_APPS so these imports will error during test collection
if settings.ROOT_URLCONF == 'lms.urls':
from entitlements.api.v1.serializers import CourseEntitlementSerializer
from entitlements.tests.factories import CourseEntitlementFactory
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms')
......
......@@ -6,12 +6,14 @@ from django.conf import settings
from django.core.urlresolvers import reverse
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory
from entitlements.tests.factories import CourseEntitlementFactory
from entitlements.models import CourseEntitlement
from entitlements.api.v1.serializers import CourseEntitlementSerializer
from student.tests.factories import CourseEnrollmentFactory, UserFactory, TEST_PASSWORD
# Entitlements is not in CMS' INSTALLED_APPS so these imports will error during test collection
if settings.ROOT_URLCONF == 'lms.urls':
from entitlements.tests.factories import CourseEntitlementFactory
from entitlements.models import CourseEntitlement
from entitlements.api.v1.serializers import CourseEntitlementSerializer
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms')
class EntitlementViewSetTest(ModuleStoreTestCase):
......
......@@ -8,8 +8,10 @@ from django.core.cache import cache
from django.test import TestCase
from opaque_keys.edx.locations import CourseLocator
from .models import CourseMessage, GlobalStatusMessage
from .status import get_site_status_msg
# Status is not in CMS' INSTALLED_APPS so these imports will error during test collection
if settings.ROOT_URLCONF == 'lms.urls':
from .models import CourseMessage, GlobalStatusMessage
from .status import get_site_status_msg
@ddt.ddt
......
"""
Tests for the Badges app models.
"""
import pytest
from django.core.exceptions import ValidationError
from django.core.files.images import ImageFile
from django.core.files.storage import default_storage
......@@ -37,6 +38,7 @@ class BadgeImageConfigurationTest(TestCase):
Test the validation features of BadgeImageConfiguration.
"""
@pytest.mark.django111_expected_failure
def test_no_double_default(self):
"""
Verify that creating two configurations as default is not permitted.
......
......@@ -3,6 +3,7 @@ Tests for branding page
"""
import datetime
import pytest
from django.conf import settings
from django.contrib.auth.models import AnonymousUser
from django.core.urlresolvers import reverse
......@@ -156,6 +157,7 @@ class PreRequisiteCourseCatalog(ModuleStoreTestCase, LoginEnrollmentTestCase, Mi
@attr(shard=1)
@pytest.mark.django111_expected_failure
class IndexPageCourseCardsSortingTests(ModuleStoreTestCase):
"""
Test for Index page course cards sorting
......@@ -291,6 +293,7 @@ class IndexPageCourseCardsSortingTests(ModuleStoreTestCase):
@attr(shard=1)
@pytest.mark.django111_expected_failure
class IndexPageProgramsTests(SiteMixin, ModuleStoreTestCase):
"""
Tests for Programs List in Marketing Pages.
......
"""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
......@@ -138,6 +139,7 @@ class ResubmitErrorCertificatesTest(CertificateManagementTest):
with self.assertRaisesRegexp(CommandError, invalid_key):
call_command(self.command, course_key_list=[invalid_key])
@pytest.mark.django111_expected_failure
def test_course_does_not_exist(self):
phantom_course = CourseLocator(org='phantom', course='phantom', run='phantom')
self._create_cert(phantom_course, self.user, 'error')
......
......@@ -2,6 +2,7 @@
import json
import ddt
import pytest
from django.conf import settings
from django.core.exceptions import ValidationError
from django.core.files.uploadedfile import SimpleUploadedFile
......@@ -263,6 +264,7 @@ class TestCertificateGenerationHistory(TestCase):
({"statuses_to_regenerate": ['downloadable', 'not_readable']}, 'already received', False),
)
@ddt.unpack
@pytest.mark.django111_expected_failure
def test_get_certificate_generation_candidates(self, task_input, expected, is_regeneration):
staff = AdminFactory.create()
instructor_task = InstructorTaskFactory.create(
......@@ -284,6 +286,7 @@ class TestCertificateGenerationHistory(TestCase):
@ddt.data((True, "regenerated"), (False, "generated"))
@ddt.unpack
@pytest.mark.django111_expected_failure
def test_get_task_name(self, is_regeneration, expected):
staff = AdminFactory.create()
instructor_task = InstructorTaskFactory.create(
......
......@@ -5,6 +5,7 @@ from uuid import uuid4
import ddt
import datetime
import pytest
from django.conf import settings
from django.core.cache import cache
from django.core.urlresolvers import reverse
......@@ -260,6 +261,7 @@ class MicrositeCertificatesViewsTests(ModuleStoreTestCase):
self.store.update_item(self.course, self.user.id)
@override_settings(FEATURES=FEATURES_WITH_CERTS_ENABLED)
@pytest.mark.django111_expected_failure
def test_html_view_for_microsite(self):
test_configuration_string = """{
"default": {
......@@ -309,6 +311,7 @@ class MicrositeCertificatesViewsTests(ModuleStoreTestCase):
self.assertIn('Microsite title', response.content)
@override_settings(FEATURES=FEATURES_WITH_CERTS_ENABLED)
@pytest.mark.django111_expected_failure
def test_html_view_microsite_configuration_missing(self):
test_configuration_string = """{
"default": {
......
# -*- coding: utf-8 -*-
"""Tests for certificates views. """
import datetime
import json
from collections import OrderedDict
from urllib import urlencode
from uuid import uuid4
import ddt
import datetime
import pytest
from django.conf import settings
from django.core.urlresolvers import reverse
from django.test.client import Client, RequestFactory
from django.test.utils import override_settings
from util.date_utils import strftime_localized
from mock import patch
from nose.plugins.attrib import attr
import ddt
from certificates.api import get_certificate_url
from certificates.models import (
CertificateGenerationCourseSetting,
......@@ -40,6 +38,7 @@ 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
......@@ -47,6 +46,7 @@ from student.roles import CourseStaffRole
from student.tests.factories import CourseEnrollmentFactory, UserFactory
from track.tests import EventTrackingTestCase
from util import organizations_helpers as organizations_api
from util.date_utils import strftime_localized
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory
......@@ -243,6 +243,7 @@ class CommonCertificatesTestCase(ModuleStoreTestCase):
@attr(shard=1)
@ddt.ddt
@pytest.mark.django111_expected_failure
class CertificatesViewsTests(CommonCertificatesTestCase):
"""
Tests for the certificates web/html views
......
......@@ -2,6 +2,7 @@
Tests for wiki middleware.
"""
import pytest
from django.test.client import Client
from nose.plugins.attrib import attr
from wiki.models import URLPath
......@@ -13,6 +14,7 @@ from xmodule.modulestore.tests.factories import CourseFactory
@attr(shard=1)
@pytest.mark.django111_expected_failure
class TestWikiAccessMiddleware(ModuleStoreTestCase):
"""Tests for WikiAccessMiddleware."""
......
"""
Tests for course wiki
"""
import pytest
from django.core.urlresolvers import reverse
from mock import patch
from nose.plugins.attrib import attr
......@@ -9,6 +14,7 @@ from xmodule.modulestore.tests.factories import CourseFactory
@attr(shard=1)
@pytest.mark.django111_expected_failure
class WikiRedirectTestCase(EnterpriseTestConsentRequired, LoginEnrollmentTestCase, ModuleStoreTestCase):
"""
Tests for wiki course redirection.
......
......@@ -3,6 +3,7 @@ Test the about xblock
"""
import datetime
import pytest
import pytz
from ccx_keys.locator import CCXLocator
from django.conf import settings
......@@ -38,6 +39,7 @@ SHIB_ERROR_STR = "The currently logged-in user account does not have permission
@attr(shard=1)
@pytest.mark.django111_expected_failure
class AboutTestCase(LoginEnrollmentTestCase, SharedModuleStoreTestCase, EventTrackingTestCase, MilestonesTestCaseMixin):
"""
Tests about xblock.
......@@ -192,6 +194,7 @@ class AboutTestCase(LoginEnrollmentTestCase, SharedModuleStoreTestCase, EventTra
@attr(shard=1)
@pytest.mark.django111_expected_failure
class AboutTestCaseXML(LoginEnrollmentTestCase, ModuleStoreTestCase):
"""
Tests for the course about page
......@@ -240,6 +243,7 @@ class AboutTestCaseXML(LoginEnrollmentTestCase, ModuleStoreTestCase):
@attr(shard=1)
@pytest.mark.django111_expected_failure
class AboutWithCappedEnrollmentsTestCase(LoginEnrollmentTestCase, SharedModuleStoreTestCase):
"""
This test case will check the About page when a course has a capped enrollment
......@@ -287,6 +291,7 @@ class AboutWithCappedEnrollmentsTestCase(LoginEnrollmentTestCase, SharedModuleSt
@attr(shard=1)
@pytest.mark.django111_expected_failure
class AboutWithInvitationOnly(SharedModuleStoreTestCase):
"""
This test case will check the About page when a course is invitation only.
......@@ -334,6 +339,7 @@ class AboutWithInvitationOnly(SharedModuleStoreTestCase):
@attr(shard=1)
@patch.dict(settings.FEATURES, {'RESTRICT_ENROLL_BY_REG_METHOD': True})
@pytest.mark.django111_expected_failure
class AboutTestCaseShibCourse(LoginEnrollmentTestCase, SharedModuleStoreTestCase):
"""
Test cases covering about page behavior for courses that use shib enrollment domain ("shib courses")
......@@ -374,6 +380,7 @@ class AboutTestCaseShibCourse(LoginEnrollmentTestCase, SharedModuleStoreTestCase
@attr(shard=1)
@pytest.mark.django111_expected_failure
class AboutWithClosedEnrollment(ModuleStoreTestCase):
"""
This test case will check the About page for a course that has enrollment start/end
......@@ -419,6 +426,7 @@ class AboutWithClosedEnrollment(ModuleStoreTestCase):
@attr(shard=1)
@patch.dict(settings.FEATURES, {'ENABLE_SHOPPING_CART': True})
@patch.dict(settings.FEATURES, {'ENABLE_PAID_COURSE_REGISTRATION': True})
@pytest.mark.django111_expected_failure
class AboutPurchaseCourseTestCase(LoginEnrollmentTestCase, SharedModuleStoreTestCase):
"""
This test class runs through a suite of verifications regarding
......
......@@ -6,6 +6,7 @@ import datetime
import itertools
import ddt
import pytest
import pytz
from ccx_keys.locator import CCXLocator
from django.contrib.auth.models import User
......@@ -158,6 +159,7 @@ class CoachAccessTestCaseCCX(SharedModuleStoreTestCase, LoginEnrollmentTestCase)
@attr(shard=1)
@ddt.ddt
@pytest.mark.django111_expected_failure
class AccessTestCase(LoginEnrollmentTestCase, ModuleStoreTestCase, MilestonesTestCaseMixin):
"""
Tests for the various access controls on the student dashboard
......@@ -631,6 +633,7 @@ class AccessTestCase(LoginEnrollmentTestCase, ModuleStoreTestCase, MilestonesTes
self.assertEqual(bool(access._has_access_course(self.staff, 'load_mobile', descriptor)), staff_expected)
@patch.dict("django.conf.settings.FEATURES", {'ENABLE_PREREQUISITE_COURSES': True, 'MILESTONES_APP': True})
@pytest.mark.django111_expected_failure
def test_courseware_page_unfulfilled_prereqs(self):
"""
Test courseware access when a course has pre-requisite course yet to be completed
......
......@@ -3,11 +3,13 @@
Test the course_info xblock
"""
import mock
from ccx_keys.locator import CCXLocator
import pytest
from django.conf import settings
from django.core.urlresolvers import reverse
from django.http import QueryDict
from django.test.utils import override_settings
from ccx_keys.locator import CCXLocator
from lms.djangoapps.ccx.tests.factories import CcxFactory
from nose.plugins.attrib import attr
from openedx.core.djangoapps.self_paced.models import SelfPacedConfiguration
......@@ -33,6 +35,7 @@ QUERY_COUNT_TABLE_BLACKLIST = WAFFLE_TABLES
@attr(shard=1)
@pytest.mark.django111_expected_failure
class CourseInfoTestCase(EnterpriseTestConsentRequired, LoginEnrollmentTestCase, SharedModuleStoreTestCase):
"""
Tests for the Course Info page
......@@ -142,6 +145,7 @@ class CourseInfoTestCase(EnterpriseTestConsentRequired, LoginEnrollmentTestCase,
@attr(shard=1)
@pytest.mark.django111_expected_failure
class CourseInfoLastAccessedTestCase(LoginEnrollmentTestCase, ModuleStoreTestCase):
"""
Tests of the CourseInfo last accessed link.
......@@ -300,6 +304,7 @@ class CourseInfoTestCaseCCX(SharedModuleStoreTestCase, LoginEnrollmentTestCase):
@attr(shard=1)
@pytest.mark.django111_expected_failure
class CourseInfoTestCaseXML(LoginEnrollmentTestCase, ModuleStoreTestCase):
"""
Tests for the Course Info page for an XML course
......@@ -349,6 +354,7 @@ class CourseInfoTestCaseXML(LoginEnrollmentTestCase, ModuleStoreTestCase):
@attr(shard=1)
@override_settings(FEATURES=dict(settings.FEATURES, EMBARGO=False))
@pytest.mark.django111_expected_failure
class SelfPacedCourseInfoTestCase(LoginEnrollmentTestCase, SharedModuleStoreTestCase):
"""
Tests for the info page of self-paced courses.
......
......@@ -5,6 +5,7 @@ Python tests for the Survey workflows
from collections import OrderedDict
from copy import deepcopy
import pytest
from django.contrib.auth.models import User
from django.core.urlresolvers import reverse
from nose.plugins.attrib import attr
......@@ -17,6 +18,7 @@ from xmodule.modulestore.tests.factories import CourseFactory
@attr(shard=1)
@pytest.mark.django111_expected_failure
class SurveyViewsTests(LoginEnrollmentTestCase, SharedModuleStoreTestCase, XssTestMixin):
"""
All tests for the views.py file
......
......@@ -3,6 +3,7 @@
from datetime import datetime, timedelta
import ddt
import pytest
import waffle
from django.contrib.messages.middleware import MessageMiddleware
from django.core.urlresolvers import reverse
......@@ -45,6 +46,7 @@ from xmodule.modulestore.tests.factories import CourseFactory
@attr(shard=1)
@ddt.ddt
@pytest.mark.django111_expected_failure
class CourseDateSummaryTest(SharedModuleStoreTestCase):
"""Tests for course date summary blocks."""
......
"""
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.
......
......@@ -5,13 +5,14 @@ import urllib
from collections import OrderedDict
import mock
import oauthlib
import pytest
from django.conf import settings
from django.core.urlresolvers import reverse
from nose.plugins.attrib import attr
import oauthlib
from courseware.tests.helpers import BaseTestXmodule
from courseware.views.views import get_course_lti_endpoints
from nose.plugins.attrib import attr
from openedx.core.lib.url_utils import quote_slashes
from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory
......@@ -188,6 +189,7 @@ class TestLTIModuleListing(SharedModuleStoreTestCase):
response = self.client.get(lti_rest_endpoints_url)
self.assertEqual(404, response.status_code)
@pytest.mark.django111_expected_failure
def test_lti_rest_listing(self):
"""tests that the draft lti module is part of the endpoint response"""
request = mock.Mock()
......
......@@ -5,30 +5,24 @@ import json
import pickle
from datetime import datetime
import pytest
from django.conf import settings
from django.core.urlresolvers import reverse
from django.test import TestCase
from pytz import UTC
from mock import patch
from nose.plugins.attrib import attr
from xblock.runtime import DictKeyValueStore
from pytz import UTC
from capa.tests.response_xml_factory import OptionResponseXMLFactory
from courseware.masquerade import (
CourseMasquerade,
MasqueradingKeyValueStore,
get_masquerading_user_group,
)
from courseware.masquerade import CourseMasquerade, MasqueradingKeyValueStore, get_masquerading_user_group
from courseware.tests.factories import StaffFactory
from courseware.tests.helpers import LoginEnrollmentTestCase, masquerade_as_group_member
from courseware.tests.test_submitting_problems import ProblemSubmissionTestMixin
from nose.plugins.attrib import attr
from openedx.core.djangoapps.lang_pref import LANGUAGE_KEY
from openedx.core.djangoapps.self_paced.models import SelfPacedConfiguration
from openedx.core.djangoapps.user_api.preferences.api import (
get_user_preference,
set_user_preference
)
from openedx.core.djangoapps.user_api.preferences.api import get_user_preference, set_user_preference
from student.tests.factories import UserFactory
from xblock.runtime import DictKeyValueStore
from xmodule.modulestore.django import modulestore
from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory
......@@ -180,6 +174,7 @@ class NormalStudentVisibilityTest(MasqueradeTestCase):
return UserFactory()
@patch.dict('django.conf.settings.FEATURES', {'DISABLE_START_DATES': False})
@pytest.mark.django111_expected_failure
def test_staff_debug_not_visible(self):
"""
Tests that staff debug control is not present for a student.
......@@ -229,6 +224,7 @@ class TestStaffMasqueradeAsStudent(StaffMasqueradeTestCase):
Check for staff being able to masquerade as student.
"""
@patch.dict('django.conf.settings.FEATURES', {'DISABLE_START_DATES': False})
@pytest.mark.django111_expected_failure
def test_staff_debug_with_masquerade(self):
"""
Tests that staff debug control is not visible when masquerading as a student.
......@@ -318,6 +314,7 @@ class TestStaffMasqueradeAsSpecificStudent(StaffMasqueradeTestCase, ProblemSubmi
)
@patch.dict('django.conf.settings.FEATURES', {'DISABLE_START_DATES': False})
@pytest.mark.django111_expected_failure
def test_masquerade_as_specific_user_on_self_paced(self):
"""
Test masquerading as a specific user for course info page when self paced configuration
......@@ -342,6 +339,7 @@ class TestStaffMasqueradeAsSpecificStudent(StaffMasqueradeTestCase, ProblemSubmi
self.assertIn("OOGIE BLOOGIE", content)
@patch.dict('django.conf.settings.FEATURES', {'DISABLE_START_DATES': False})
@pytest.mark.django111_expected_failure
def test_masquerade_as_specific_student(self):
"""
Test masquerading as a specific user.
......
"""
Tests related to the Site Configuration feature
"""
import pytest
from bs4 import BeautifulSoup
from contextlib import contextmanager
from django.conf import settings
......@@ -17,6 +19,7 @@ from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory
@attr(shard=1)
@pytest.mark.django111_expected_failure
class TestSites(SharedModuleStoreTestCase, LoginEnrollmentTestCase):
"""
This is testing of the Site Configuration feature
......
......@@ -8,6 +8,7 @@ from datetime import datetime
from functools import partial
import ddt
import pytest
import pytz
from bson import ObjectId
from django.conf import settings
......@@ -222,6 +223,7 @@ class ModuleRenderTestCase(SharedModuleStoreTestCase, LoginEnrollmentTestCase):
# note if the URL mapping changes then this assertion will break
self.assertIn('/courses/' + self.course_key.to_deprecated_string() + '/jump_to_id/vertical_test', html)
@pytest.mark.django111_expected_failure
def test_xqueue_callback_success(self):
"""
Test for happy-path xqueue_callback
......@@ -690,6 +692,7 @@ class TestHandleXBlockCallback(SharedModuleStoreTestCase, LoginEnrollmentTestCas
BlockCompletion.objects.get(block_key=block.scope_ids.usage_id)
@patch.dict('django.conf.settings.FEATURES', {'ENABLE_XBLOCK_VIEW_ENDPOINT': True})
@pytest.mark.django111_expected_failure
def test_xblock_view_handler(self):
args = [
'edX/toy/2012_Fall',
......@@ -823,6 +826,7 @@ class TestTOC(ModuleStoreTestCase):
@attr(shard=1)
@ddt.ddt
@patch.dict('django.conf.settings.FEATURES', {'ENABLE_SPECIAL_EXAMS': True})
@pytest.mark.django111_expected_failure
class TestProctoringRendering(SharedModuleStoreTestCase):
@classmethod
def setUpClass(cls):
......@@ -1238,6 +1242,7 @@ class TestGatedSubsectionRendering(SharedModuleStoreTestCase, MilestonesTestCase
@attr(shard=1)
@ddt.ddt
@pytest.mark.django111_expected_failure
class TestHtmlModifiers(ModuleStoreTestCase):
"""
Tests to verify that standard modifications to the output of XModule/XBlock
......@@ -1402,6 +1407,7 @@ class XBlockWithJsonInitData(XBlock):
@attr(shard=1)
@ddt.ddt
@pytest.mark.django111_expected_failure
class JsonInitDataTest(ModuleStoreTestCase):
"""Tests for JSON data injected into the JS init function."""
......@@ -1486,6 +1492,7 @@ class ViewInStudioTest(ModuleStoreTestCase):
@attr(shard=1)
@pytest.mark.django111_expected_failure
class MongoViewInStudioTest(ViewInStudioTest):
"""Test the 'View in Studio' link visibility in a mongo backed course."""
......@@ -1515,6 +1522,7 @@ class MongoViewInStudioTest(ViewInStudioTest):
@attr(shard=1)
@pytest.mark.django111_expected_failure
class MixedViewInStudioTest(ViewInStudioTest):
"""Test the 'View in Studio' link visibility in a mixed mongo backed course."""
......@@ -1549,6 +1557,7 @@ class DetachedXBlock(XBlock):
@attr(shard=1)
@patch.dict('django.conf.settings.FEATURES', {'DISPLAY_DEBUG_INFO_TO_STAFF': True, 'DISPLAY_HISTOGRAMS_TO_STAFF': True})
@patch('courseware.module_render.has_access', Mock(return_value=True, autospec=True))
@pytest.mark.django111_expected_failure
class TestStaffDebugInfo(SharedModuleStoreTestCase):
"""Tests to verify that Staff Debug Info panel and histograms are displayed to staff."""
......@@ -1896,6 +1905,7 @@ class TestModuleTrackingContext(SharedModuleStoreTestCase):
@attr(shard=1)
@pytest.mark.django111_expected_failure
class TestXmoduleRuntimeEvent(TestSubmittingProblems):
"""
Inherit from TestSubmittingProblems to get functionality that set up a course and problems structure
......@@ -1965,6 +1975,7 @@ class TestXmoduleRuntimeEvent(TestSubmittingProblems):
@attr(shard=1)
@pytest.mark.django111_expected_failure
class TestRebindModule(TestSubmittingProblems):
"""
Tests to verify the functionality of rebinding a module.
......
......@@ -3,13 +3,15 @@ This test file will run through some LMS test scenarios regarding access and nav
"""
import time
from courseware.tests.factories import GlobalStaffFactory
from courseware.tests.helpers import LoginEnrollmentTestCase
import pytest
from django.conf import settings
from django.core.urlresolvers import reverse
from django.test.utils import override_settings
from mock import patch
from nose.plugins.attrib import attr
from courseware.tests.factories import GlobalStaffFactory
from courseware.tests.helpers import LoginEnrollmentTestCase
from openedx.core.djangoapps.waffle_utils.testutils import override_waffle_flag
from openedx.features.course_experience import COURSE_OUTLINE_PAGE_FLAG
from student.tests.factories import UserFactory
......@@ -19,6 +21,7 @@ from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory
@attr(shard=1)
@pytest.mark.django111_expected_failure
class TestNavigation(SharedModuleStoreTestCase, LoginEnrollmentTestCase):
"""
Check that navigation state is saved properly.
......
......@@ -6,6 +6,7 @@ from datetime import timedelta
from uuid import uuid4
import ddt
import pytest
from django.contrib.auth.models import User
from django.contrib.auth.tokens import default_token_generator
from django.core.urlresolvers import reverse
......@@ -23,6 +24,7 @@ from student.models import PasswordHistory
@attr(shard=1)
@patch.dict("django.conf.settings.FEATURES", {'ADVANCED_SECURITY': True})
@ddt.ddt
@pytest.mark.django111_expected_failure
class TestPasswordHistory(LoginEnrollmentTestCase):
"""
Go through some of the PasswordHistory use cases
......
"""
Test for split test XModule
"""
import pytest
from django.core.urlresolvers import reverse
from mock import MagicMock
from nose.plugins.attrib import attr
......@@ -142,6 +143,7 @@ class SplitTestBase(SharedModuleStoreTestCase):
self.assertIn(visible, content)
@pytest.mark.django111_expected_failure
class TestSplitTestVert(SplitTestBase):
"""
Tests a sequential whose top-level vertical is determined by a split test.
......@@ -210,6 +212,7 @@ class TestSplitTestVert(SplitTestBase):
]
@pytest.mark.django111_expected_failure
class TestVertSplitTestVert(SplitTestBase):
"""
Tests a sequential whose top-level vertical contains a split test determining content within that vertical.
......
......@@ -10,6 +10,7 @@ import os
from textwrap import dedent
import ddt
import pytest
from django.conf import settings
from django.contrib.auth.models import User
from django.core.urlresolvers import reverse
......@@ -779,6 +780,7 @@ class ProblemWithUploadedFilesTest(TestSubmittingProblems):
# re-fetch the course from the database so the object is up to date
self.refresh_course()
@pytest.mark.django111_expected_failure
def test_three_files(self):
# Open the test files, and arrange to close them later.
filenames = "prog1.py prog2.py prog3.py"
......@@ -807,6 +809,7 @@ class ProblemWithUploadedFilesTest(TestSubmittingProblems):
@attr(shard=1)
@pytest.mark.django111_expected_failure
class TestPythonGradedResponse(TestSubmittingProblems):
"""
Check that we can submit a schematic and custom response, and it answers properly.
......@@ -1174,6 +1177,7 @@ class TestConditionalContent(TestSubmittingProblems):
# Submit answers for problem in Section 1, which is visible to all students.
self.submit_question_answer('H1P1', {'2_1': 'Correct', '2_2': 'Incorrect'})
@pytest.mark.django111_expected_failure
def test_split_different_problems_group_0(self):
"""
Tests that users who see different problems in a split_test module instance are graded correctly.
......@@ -1193,6 +1197,7 @@ class TestConditionalContent(TestSubmittingProblems):
homework_2_score = (1.0 + 2.0) / 4
self.check_grade_percent(round((homework_1_score + homework_2_score) / 2, 2))
@pytest.mark.django111_expected_failure
def test_split_different_problems_group_1(self):
"""
Tests that users who see different problems in a split_test module instance are graded correctly.
......@@ -1229,6 +1234,7 @@ class TestConditionalContent(TestSubmittingProblems):
self.submit_question_answer('H1P1', {'2_1': 'Correct'})
@pytest.mark.django111_expected_failure
def test_split_one_group_no_problems_group_0(self):
"""
Tests what happens when a given group has no problems in it (students receive 0 for that section).
......@@ -1244,6 +1250,7 @@ class TestConditionalContent(TestSubmittingProblems):
homework_2_score = 0.0
self.check_grade_percent(round((homework_1_score + homework_2_score) / 2, 2))
@pytest.mark.django111_expected_failure
def test_split_one_group_no_problems_group_1(self):
"""
Verifies students in the group that DOES have a problem receive a score for their problem.
......
......@@ -2,6 +2,7 @@
Test cases for tabs.
"""
import pytest
from django.core.urlresolvers import reverse
from django.http import Http404
from milestones.tests.utils import MilestonesTestCaseMixin
......@@ -245,6 +246,7 @@ class StaticTabDateTestCase(LoginEnrollmentTestCase, SharedModuleStoreTestCase):
cls.course.tabs.append(xmodule_tabs.CourseTab.load('static_tab', name='New Tab', url_slug='new_tab'))
cls.course.save()
@pytest.mark.django111_expected_failure
def test_logged_in(self):
self.setup_user()
url = reverse('static_tab', args=[self.course.id.to_deprecated_string(), 'new_tab'])
......@@ -258,12 +260,14 @@ class StaticTabDateTestCase(LoginEnrollmentTestCase, SharedModuleStoreTestCase):
self.assertEqual(resp.status_code, 200)
self.assertIn("OOGIE BLOOGIE", resp.content)
@pytest.mark.django111_expected_failure
def test_invalid_course_key(self):
self.setup_user()
request = get_mock_request(self.user)
with self.assertRaises(Http404):
StaticCourseTabView().get(request, course_id='edX/toy', tab_slug='new_tab')
@pytest.mark.django111_expected_failure
def test_get_static_tab_fragment(self):
self.setup_user()
course = get_course_by_id(self.course.id)
......@@ -319,6 +323,7 @@ class StaticTabDateTestCaseXML(LoginEnrollmentTestCase, ModuleStoreTestCase):
self.xml_url = "8e4cce2b4aaf4ba28b1220804619e41f"
@patch.dict('django.conf.settings.FEATURES', {'DISABLE_START_DATES': False})
@pytest.mark.django111_expected_failure
def test_logged_in_xml(self):
self.setup_user()
url = reverse('static_tab', args=[self.xml_course_key.to_deprecated_string(), self.xml_url])
......@@ -336,6 +341,7 @@ class StaticTabDateTestCaseXML(LoginEnrollmentTestCase, ModuleStoreTestCase):
@attr(shard=1)
@patch.dict('django.conf.settings.FEATURES', {'ENTRANCE_EXAMS': True})
@pytest.mark.django111_expected_failure
class EntranceExamsTabsTestCase(LoginEnrollmentTestCase, ModuleStoreTestCase, MilestonesTestCaseMixin):
"""
Validate tab behavior when dealing with Entrance Exams
......@@ -443,6 +449,7 @@ class EntranceExamsTabsTestCase(LoginEnrollmentTestCase, ModuleStoreTestCase, Mi
@attr(shard=1)
@pytest.mark.django111_expected_failure
class TextBookCourseViewsTestCase(LoginEnrollmentTestCase, SharedModuleStoreTestCase):
"""
Validate tab behavior when dealing with textbooks.
......@@ -690,6 +697,7 @@ class CourseTabListTestCase(TabListTestCase):
# get tab by id
self.assertEquals(xmodule_tabs.CourseTabList.get_tab_by_id(self.course.tabs, tab.tab_id), tab)
@pytest.mark.django111_expected_failure
def test_course_tabs_staff_only(self):
"""
Tests the static tabs that available only for instructor
......@@ -721,6 +729,7 @@ class CourseTabListTestCase(TabListTestCase):
@attr(shard=1)
@pytest.mark.django111_expected_failure
class ProgressTestCase(TabTestCase):
"""Test cases for Progress Tab."""
......@@ -751,6 +760,7 @@ class ProgressTestCase(TabTestCase):
@attr(shard=1)
@pytest.mark.django111_expected_failure
class StaticTabTestCase(TabTestCase):
"""Test cases for Static Tab."""
......@@ -770,6 +780,7 @@ class StaticTabTestCase(TabTestCase):
@attr(shard=1)
@pytest.mark.django111_expected_failure
class CourseInfoTabTestCase(TabTestCase):
"""Test cases for the course info tab."""
def setUp(self):
......@@ -798,6 +809,7 @@ class CourseInfoTabTestCase(TabTestCase):
@attr(shard=1)
@pytest.mark.django111_expected_failure
class DiscussionLinkTestCase(TabTestCase):
"""Test cases for discussion link tab."""
......
import datetime
import pytz
import pytest
from django.core.urlresolvers import reverse
from mock import patch
from nose.plugins.attrib import attr
......@@ -163,6 +164,7 @@ class TestViewAuth(EnterpriseTestConsentRequired, ModuleStoreTestCase, LoginEnro
self.org_staff_user = OrgStaffFactory(course_key=self.course.id)
self.org_instructor_user = OrgInstructorFactory(course_key=self.course.id)
@pytest.mark.django111_expected_failure
def test_redirection_unenrolled(self):
"""
Verify unenrolled student is redirected to the 'about' section of the chapter
......@@ -179,6 +181,7 @@ class TestViewAuth(EnterpriseTestConsentRequired, ModuleStoreTestCase, LoginEnro
)
)
@pytest.mark.django111_expected_failure
def test_redirection_enrolled(self):
"""
Verify enrolled student is redirected to the 'Welcome' section of
......@@ -302,6 +305,7 @@ class TestViewAuth(EnterpriseTestConsentRequired, ModuleStoreTestCase, LoginEnro
self.assert_request_status_code(200, url)
@patch.dict('courseware.access.settings.FEATURES', {'DISABLE_START_DATES': False})
@pytest.mark.django111_expected_failure
def test_dark_launch_enrolled_student(self):
"""
Make sure that before course start, students can't access course
......@@ -329,6 +333,7 @@ class TestViewAuth(EnterpriseTestConsentRequired, ModuleStoreTestCase, LoginEnro
self._check_non_staff_dark(self.test_course)
@patch.dict('courseware.access.settings.FEATURES', {'DISABLE_START_DATES': False})
@pytest.mark.django111_expected_failure
def test_dark_launch_instructor(self):
"""
Make sure that before course start instructors can access the
......@@ -352,6 +357,7 @@ class TestViewAuth(EnterpriseTestConsentRequired, ModuleStoreTestCase, LoginEnro
self._check_non_staff_dark(self.test_course)
@patch.dict('courseware.access.settings.FEATURES', {'DISABLE_START_DATES': False})
@pytest.mark.django111_expected_failure
def test_dark_launch_global_staff(self):
"""
Make sure that before course start staff can access
......
......@@ -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
......@@ -114,6 +115,7 @@ class TestJumpTo(ModuleStoreTestCase):
response = self.client.get(jumpto_url)
self.assertRedirects(response, expected, status_code=302, target_status_code=302)
@pytest.mark.django111_expected_failure
def test_jumpto_from_section(self):
course = CourseFactory.create()
chapter = ItemFactory.create(category='chapter', parent_location=course.location)
......@@ -132,6 +134,7 @@ class TestJumpTo(ModuleStoreTestCase):
response = self.client.get(jumpto_url)
self.assertRedirects(response, expected, status_code=302, target_status_code=302)
@pytest.mark.django111_expected_failure
def test_jumpto_from_module(self):
course = CourseFactory.create()
chapter = ItemFactory.create(category='chapter', parent_location=course.location)
......@@ -169,6 +172,7 @@ class TestJumpTo(ModuleStoreTestCase):
response = self.client.get(jumpto_url)
self.assertRedirects(response, expected, status_code=302, target_status_code=302)
@pytest.mark.django111_expected_failure
def test_jumpto_from_nested_module(self):
course = CourseFactory.create()
chapter = ItemFactory.create(category='chapter', parent_location=course.location)
......@@ -206,6 +210,7 @@ class TestJumpTo(ModuleStoreTestCase):
@attr(shard=2)
@ddt.ddt
@pytest.mark.django111_expected_failure
class IndexQueryTestCase(ModuleStoreTestCase):
"""
Tests for query count.
......@@ -248,6 +253,7 @@ class IndexQueryTestCase(ModuleStoreTestCase):
@attr(shard=2)
@ddt.ddt
@pytest.mark.django111_expected_failure
class ViewsTestCase(ModuleStoreTestCase):
"""
Tests for views.py methods.
......@@ -1111,6 +1117,7 @@ class TestProgressDueDate(BaseDueDateTests):
# TODO: LEARNER-71: Delete entire TestAccordionDueDate class
@pytest.mark.django111_expected_failure
class TestAccordionDueDate(BaseDueDateTests):
"""
Test that the accordion page displays due dates correctly
......@@ -1183,6 +1190,7 @@ class StartDateTests(ModuleStoreTestCase):
@patch('util.date_utils.ugettext', fake_ugettext(translations={
"SHORT_DATE_FORMAT": "%Y-%b-%d",
}))
@pytest.mark.django111_expected_failure
def test_format_localized_in_studio_course(self):
course = self.set_up_course()
response = self.get_about_response(course.id)
......@@ -2190,6 +2198,7 @@ class ViewCheckerBlock(XBlock):
@attr(shard=1)
@ddt.ddt
@pytest.mark.django111_expected_failure
class TestIndexView(ModuleStoreTestCase):
"""
Tests of the courseware.views.index view.
......@@ -2527,6 +2536,7 @@ class TestIndexViewCrawlerStudentStateWrites(SharedModuleStoreTestCase):
@attr(shard=1)
@pytest.mark.django111_expected_failure
class EnterpriseConsentTestCase(EnterpriseTestConsentRequired, ModuleStoreTestCase):
"""
Ensure that the Enterprise Data Consent redirects are in place only when consent is required.
......
......@@ -5,6 +5,7 @@ from textwrap import dedent
from unittest import TestCase
import mock
import pytest
from django.core.urlresolvers import reverse
from nose.plugins.attrib import attr
from opaque_keys.edx.keys import CourseKey
......@@ -18,6 +19,7 @@ from xmodule.modulestore.tests.factories import ToyCourseFactory
@attr(shard=1)
@pytest.mark.django111_expected_failure
class ActivateLoginTest(LoginEnrollmentTestCase):
"""
Test logging in and logging out.
......@@ -122,6 +124,7 @@ class PageLoaderTestCase(LoginEnrollmentTestCase):
@attr(shard=1)
@pytest.mark.django111_expected_failure
class TestMongoCoursesLoad(ModuleStoreTestCase, PageLoaderTestCase):
"""
Check that all pages in test courses load properly from Mongo.
......
......@@ -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)
......
......@@ -4,6 +4,8 @@ import json
import ddt
import mock
import pytest
from django.core.urlresolvers import reverse
from django.test import RequestFactory, TestCase
from mock import Mock, patch
......@@ -70,6 +72,7 @@ class DictionaryTestCase(TestCase):
@attr(shard=1)
@pytest.mark.django111_expected_failure
class AccessUtilsTestCase(ModuleStoreTestCase):
"""
Base testcase class for access and roles for the
......
......@@ -3,13 +3,14 @@ Django admin page for grades models
"""
from config_models.admin import ConfigurationModelAdmin, KeyedConfigurationModelAdmin
from django.contrib import admin
from django.utils.translation import ugettext_lazy as _
from lms.djangoapps.grades.config.forms import CoursePersistentGradesAdminForm
from lms.djangoapps.grades.config.models import (
ComputeGradesSetting,
CoursePersistentGradesFlag,
PersistentGradesEnabledFlag
)
from lms.djangoapps.grades.models import PersistentSubsectionGradeOverride, PersistentSubsectionGrade
class CoursePersistentGradesAdmin(KeyedConfigurationModelAdmin):
......@@ -26,6 +27,49 @@ class CoursePersistentGradesAdmin(KeyedConfigurationModelAdmin):
}),
)
class PersistentSubsectionGradeOverrideAdmin(admin.ModelAdmin):
fieldsets = (
(None, {
'fields': (
'grade',
'earned_all_override',
'earned_graded_override',
'possible_all_override',
'possible_graded_override',
),
'description': 'Enter the ID of the subsection grade you want to override. You will probably need to '
'find this in the read replica in the grades_persistentsubsectiongrade table.'
}),
)
list_display = [
'get_course_id',
'get_usage_key',
'get_user_id',
'earned_all_override',
'earned_graded_override',
'created',
'modified',
]
list_filter = ('grade__course_id', 'grade__user_id',)
raw_id_fields = ('grade',)
search_fields = ['grade__course_id', 'grade__user_id', 'grade__usage_key']
def get_course_id(self, persistent_grade):
return persistent_grade.grade.course_id
def get_usage_key(self, persistent_grade):
return persistent_grade.grade.usage_key
def get_user_id(self, persistent_grade):
return persistent_grade.grade.user_id
get_course_id.short_description = _('Course Id')
get_usage_key.short_description = _('Usage Key')
get_user_id.short_description = _('User Id')
admin.site.register(CoursePersistentGradesFlag, CoursePersistentGradesAdmin)
admin.site.register(PersistentGradesEnabledFlag, ConfigurationModelAdmin)
admin.site.register(ComputeGradesSetting, ConfigurationModelAdmin)
admin.site.register(PersistentSubsectionGradeOverride, PersistentSubsectionGradeOverrideAdmin)
......@@ -11,6 +11,7 @@ import shutil
import tempfile
import ddt
import pytest
from boto.exception import BotoServerError
from django.conf import settings
from django.contrib.auth.models import User
......@@ -2860,6 +2861,7 @@ class TestInstructorAPILevelsDataDump(SharedModuleStoreTestCase, LoginEnrollment
decorated_func(request, self.course.id.to_deprecated_string())
self.assertTrue(func.called)
@pytest.mark.django111_expected_failure
def test_enrollment_report_features_csv(self):
"""
test to generate enrollment report.
......@@ -2900,6 +2902,7 @@ class TestInstructorAPILevelsDataDump(SharedModuleStoreTestCase, LoginEnrollment
response = self.client.post(url, {})
self.assertIn('The detailed enrollment report is being created.', response.content)
@pytest.mark.django111_expected_failure
def test_bulk_purchase_detailed_report(self):
"""
test to generate detailed enrollment report.
......@@ -2955,6 +2958,7 @@ class TestInstructorAPILevelsDataDump(SharedModuleStoreTestCase, LoginEnrollment
response = self.client.post(url, {})
self.assertIn('The detailed enrollment report is being created.', response.content)
@pytest.mark.django111_expected_failure
def test_create_registration_code_without_invoice_and_order(self):
"""
test generate detailed enrollment report,
......@@ -2977,6 +2981,7 @@ class TestInstructorAPILevelsDataDump(SharedModuleStoreTestCase, LoginEnrollment
response = self.client.post(url, {})
self.assertIn('The detailed enrollment report is being created.', response.content)
@pytest.mark.django111_expected_failure
def test_invoice_payment_is_still_pending_for_registration_codes(self):
"""
test generate enrollment report
......@@ -3630,6 +3635,7 @@ class TestEntranceExamInstructorAPIRegradeTask(SharedModuleStoreTestCase, LoginE
@attr(shard=1)
@patch('bulk_email.models.html_to_text', Mock(return_value='Mocking CourseEmail.text_message', autospec=True))
@pytest.mark.django111_expected_failure
class TestInstructorSendEmail(SiteMixin, SharedModuleStoreTestCase, LoginEnrollmentTestCase):
"""
Checks that only instructors have access to email endpoints, and that
......@@ -4515,6 +4521,7 @@ class TestCourseIssuedCertificatesData(SharedModuleStoreTestCase):
@attr(shard=1)
@override_settings(REGISTRATION_CODE_LENGTH=8)
@pytest.mark.django111_expected_failure
class TestCourseRegistrationCodes(SharedModuleStoreTestCase):
"""
Test data dumps for E-commerce Course Registration Codes.
......
......@@ -4,6 +4,7 @@ Unit tests for Ecommerce feature flag in new instructor dashboard.
import datetime
import pytest
import pytz
from django.core.urlresolvers import reverse
from nose.plugins.attrib import attr
......@@ -18,6 +19,7 @@ from xmodule.modulestore.tests.factories import CourseFactory
@attr(shard=1)
@pytest.mark.django111_expected_failure
class TestECommerceDashboardViews(SiteMixin, SharedModuleStoreTestCase):
"""
Check for E-commerce view on the new instructor dashboard
......
......@@ -5,6 +5,7 @@ import unittest
from datetime import datetime
import ddt
import pytest
import pytz
from dateutil import parser
from django.conf import settings
......@@ -79,6 +80,7 @@ class TestDashboard(SharedModuleStoreTestCase):
response = self.client.get(self.teams_url)
self.assertEqual(404, response.status_code)
@pytest.mark.django111_expected_failure
def test_not_enrolled_staff(self):
"""
Verifies that a user with global access who is not enrolled in the course can access the team dashboard.
......@@ -89,6 +91,7 @@ class TestDashboard(SharedModuleStoreTestCase):
response = staff_client.get(self.teams_url)
self.assertContains(response, "TeamsTabFactory", status_code=200)
@pytest.mark.django111_expected_failure
def test_enrolled_not_staff(self):
"""
Verifies that a user without global access who is enrolled in the course can access the team dashboard.
......
......@@ -123,6 +123,10 @@ def rsa_decrypt(data, rsa_priv_key_bytes):
"""
When given some `data` and an RSA private key, decrypt the data
"""
if isinstance(data, text_type):
data = data.encode('utf-8')
if isinstance(rsa_priv_key_bytes, text_type):
rsa_priv_key_bytes = rsa_priv_key_bytes.encode('utf-8')
if rsa_priv_key_bytes.startswith(b'-----'):
key = serialization.load_pem_private_key(rsa_priv_key_bytes, password=None, backend=default_backend())
else:
......
import base64
"""
Tests of the encryption and decryption utilities in the ssencrypt module.
"""
from nose.tools import assert_equals
import base64
from lms.djangoapps.verify_student.ssencrypt import (
aes_decrypt,
......@@ -11,32 +13,10 @@ from lms.djangoapps.verify_student.ssencrypt import (
rsa_encrypt
)
AES_KEY_BYTES = b'32fe72aaf2abb44de9e161131b5435c8d37cbdb6f5df242ae860b283115f2dae'.decode('hex')
def test_aes():
key_str = "32fe72aaf2abb44de9e161131b5435c8d37cbdb6f5df242ae860b283115f2dae"
key = key_str.decode("hex")
def assert_roundtrip(text):
assert_equals(text, aes_decrypt(aes_encrypt(text, key), key))
assert_equals(
text,
decode_and_decrypt(
encrypt_and_encode(text, key),
key
)
)
assert_roundtrip("Hello World!")
assert_roundtrip("1234567890123456") # AES block size, padding corner case
# Longer string
assert_roundtrip("12345678901234561234567890123456123456789012345601")
assert_roundtrip("")
assert_roundtrip("\xe9\xe1a\x13\x1bT5\xc8") # Random, non-ASCII text
def test_rsa():
# Make up some garbage keys for testing purposes.
pub_key_str = """-----BEGIN PUBLIC KEY-----
# Make up some garbage keys for testing purposes.
PUB_KEY_BYTES = b"""-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA1hLVjP0oV0Uy/+jQ+Upz
c+eYc4Pyflb/WpfgYATggkoQdnsdplmvPtQr85+utgqKPxOh+PvYGW8QNUzjLIu4
5/GlmvBa82i1jRMgEAxGI95bz7j9DtH+7mnj+06zR5xHwT49jK0zMs5MjMaz5WRq
......@@ -45,7 +25,7 @@ h5svjspz1MIsOoShjbAdfG+4VX7sVwYlw2rnQeRsMH5/xpnNeqtScyOMoz0N9UDG
dtRMNGa2MihAg7zh7/zckbUrtf+o5wQtlCJL1Kdj4EjshqYvCxzWnSM+MaYAjb3M
EQIDAQAB
-----END PUBLIC KEY-----"""
priv_key_str = """-----BEGIN RSA PRIVATE KEY-----
PRIV_KEY_BYTES = b"""-----BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCAQEA1hLVjP0oV0Uy/+jQ+Upzc+eYc4Pyflb/WpfgYATggkoQdnsd
plmvPtQr85+utgqKPxOh+PvYGW8QNUzjLIu45/GlmvBa82i1jRMgEAxGI95bz7j9
DtH+7mnj+06zR5xHwT49jK0zMs5MjMaz5WRqBUNkz7dxWzDrYJZQx230sPp6upy1
......@@ -72,13 +52,46 @@ MlpJNBECgYAmIswPdldm+G8SJd5j9O2fcDVTURjKAoSXCv2j4gEZzzfudpLWNHYu
l8N6+LEIVTMAytPk+/bImHvGHKZkCz5rEMSuYJWOmqKI92rUtI6fz5DUb3XSbrwT
3W+sdGFUK3GH1NAX71VxbAlFVLUetcMwai1+wXmGkRw6A7YezVFnhw==
-----END RSA PRIVATE KEY-----"""
aes_key_str = "32fe72aaf2abb44de9e161131b5435c8d37cbdb6f5df242ae860b283115f2dae"
aes_key = aes_key_str.decode('hex')
encrypted_aes_key = rsa_encrypt(aes_key, pub_key_str)
assert_equals(aes_key, rsa_decrypt(encrypted_aes_key, priv_key_str))
def test_aes():
def assert_roundtrip(data):
"""
Verify that the original data is retrieved after encrypting and
decrypting, and again when also using base64 encoding/decoding.
"""
assert aes_decrypt(aes_encrypt(data, AES_KEY_BYTES), AES_KEY_BYTES) == data
assert decode_and_decrypt(encrypt_and_encode(data, AES_KEY_BYTES), AES_KEY_BYTES) == data
assert_roundtrip(b"Hello World!")
assert_roundtrip(b"1234567890123456") # AES block size, padding corner case
# Longer string
assert_roundtrip(b"12345678901234561234567890123456123456789012345601")
assert_roundtrip(b"")
assert_roundtrip(b"\xe9\xe1a\x13\x1bT5\xc8") # Random, non-ASCII text
def test_rsa():
_assert_rsa(AES_KEY_BYTES, PUB_KEY_BYTES, PRIV_KEY_BYTES)
def test_rsa_unicode_data():
data = u'12345678901234567890123456789012'
_assert_rsa(data, PUB_KEY_BYTES, PRIV_KEY_BYTES)
def test_rsa_unicode_keys():
_assert_rsa(AES_KEY_BYTES, PUB_KEY_BYTES.decode('utf-8'), PRIV_KEY_BYTES.decode('utf-8'))
def _assert_rsa(data, public_key, private_key):
"""
Assert that the original provided data is retrieved after RSA encryption
and decryption using the given keys.
"""
encrypted_data = rsa_encrypt(data, public_key)
assert rsa_decrypt(encrypted_data, private_key) == data
# Even though our AES key is only 32 bytes, RSA encryption will make it 256
# Even though our test data is only 32 bytes, RSA encryption will make it 256
# bytes, and base64 encoding will blow that up to 344
assert_equals(len(base64.urlsafe_b64encode(encrypted_aes_key)), 344)
assert len(base64.urlsafe_b64encode(encrypted_data)) == 344
......@@ -14,7 +14,7 @@ from branding import api as branding_api
%>
<h1 class="header-logo">
<a href="${reverse('dashboard')}">
<a href="${branding_api.get_home_url()}">
<%block name="navigation_logo">
<img class="logo" src="${branding_api.get_logo_url(is_secure)}" alt="${_("{platform_name} Home Page").format(platform_name=static.get_platform_name())}"/>
</%block>
......
......@@ -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
......
"""Tests for cross-domain request views. """
import ddt
import json
import unittest
from django.conf import settings
from django.core.urlresolvers import NoReverseMatch, reverse
from django.test import TestCase
from django.core.urlresolvers import reverse, NoReverseMatch
import ddt
from config_models.models import cache
from ..models import XDomainProxyConfiguration
# cors_csrf is not in CMS' INSTALLED_APPS so these imports will error during test collection
if settings.ROOT_URLCONF == 'lms.urls':
from ..models import XDomainProxyConfiguration
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms')
@ddt.ddt
class XDomainProxyTest(TestCase):
"""Tests for the xdomain proxy end-point. """
......
......@@ -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.
......
......@@ -2,20 +2,22 @@
Tests for DOT Adapter
"""
import unittest
from datetime import timedelta
import ddt
from django.conf import settings
from django.test import TestCase
from django.utils.timezone import now
from oauth2_provider import models
import unittest
import ddt
from oauth2_provider import models
from student.tests.factories import UserFactory
from ..adapters import DOTAdapter
from .constants import DUMMY_REDIRECT_URL, DUMMY_REDIRECT_URL2
from ..models import RestrictedApplication
# oauth_dispatch is not in CMS' INSTALLED_APPS so these imports will error during test collection
if settings.FEATURES.get("ENABLE_OAUTH2_PROVIDER"):
from ..adapters import DOTAdapter
from .constants import DUMMY_REDIRECT_URL, DUMMY_REDIRECT_URL2
from ..models import RestrictedApplication
@ddt.ddt
......@@ -24,11 +26,9 @@ class DOTAdapterTestCase(TestCase):
"""
Test class for DOTAdapter.
"""
adapter = DOTAdapter()
def setUp(self):
super(DOTAdapterTestCase, self).setUp()
self.adapter = DOTAdapter()
self.user = UserFactory()
self.public_client = self.adapter.create_public_client(
name='public app',
......
......@@ -3,12 +3,18 @@ Test of custom django-oauth-toolkit behavior
"""
# pylint: disable=protected-access
import unittest
from django.conf import settings
from django.contrib.auth.models import User
from django.test import TestCase, RequestFactory
from ..dot_overrides import EdxOAuth2Validator
# oauth_dispatch is not in CMS' INSTALLED_APPS so these imports will error during test collection
if settings.ROOT_URLCONF == 'lms.urls':
from ..dot_overrides import EdxOAuth2Validator
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms')
class AuthenticateTestCase(TestCase):
"""
Test that users can authenticate with either username or email
......@@ -38,6 +44,7 @@ class AuthenticateTestCase(TestCase):
)
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms')
class CustomValidationTestCase(TestCase):
"""
Test custom user validation works.
......
......@@ -12,22 +12,26 @@ from django.conf import settings
from django.core.urlresolvers import reverse
from django.test import RequestFactory, TestCase, override_settings
from oauth2_provider import models as dot_models
from provider import constants
from provider import constants
from student.tests.factories import UserFactory
from third_party_auth.tests.utils import ThirdPartyOAuthTestMixin, ThirdPartyOAuthTestMixinGoogle
from . import mixins
from .constants import DUMMY_REDIRECT_URL
from .. import adapters
from .. import models
# NOTE (CCB): We use this feature flag in a roundabout way to determine if the oauth_dispatch app is installed
# in the current service--LMS or Studio. Normally we would check if settings.ROOT_URLCONF == 'lms.urls'; however,
# simply importing the views will results in an error due to the requisite apps not being installed (in Studio). Thus,
# we are left with this hack, of checking the feature flag which will never be True for Studio.
#
# NOTE (BJM): As of Django 1.9 we also can't import models for apps which aren't in INSTALLED_APPS, so making all of
# these imports conditional except mixins, which doesn't currently import forbidden models, and is needed at test
# discovery time.
OAUTH_PROVIDER_ENABLED = settings.FEATURES.get('ENABLE_OAUTH2_PROVIDER')
if OAUTH_PROVIDER_ENABLED:
from .constants import DUMMY_REDIRECT_URL
from .. import adapters
from .. import models
from .. import views
......@@ -75,11 +79,10 @@ class _DispatchingViewTestCase(TestCase):
Subclasses need to define self.url.
"""
dop_adapter = adapters.DOPAdapter()
dot_adapter = adapters.DOTAdapter()
def setUp(self):
super(_DispatchingViewTestCase, self).setUp()
self.dop_adapter = adapters.DOPAdapter()
self.dot_adapter = adapters.DOTAdapter()
self.user = UserFactory()
self.dot_app = self.dot_adapter.create_public_client(
name='test dot application',
......@@ -270,10 +273,9 @@ class TestAuthorizationView(_DispatchingViewTestCase):
Test class for AuthorizationView
"""
dop_adapter = adapters.DOPAdapter()
def setUp(self):
super(TestAuthorizationView, self).setUp()
self.dop_adapter = adapters.DOPAdapter()
self.user = UserFactory()
self.dot_app = self.dot_adapter.create_confidential_client(
name='test dot application',
......@@ -399,11 +401,10 @@ class TestViewDispatch(TestCase):
Test that the DispatchingView dispatches the right way.
"""
dop_adapter = adapters.DOPAdapter()
dot_adapter = adapters.DOTAdapter()
def setUp(self):
super(TestViewDispatch, self).setUp()
self.dop_adapter = adapters.DOPAdapter()
self.dot_adapter = adapters.DOTAdapter()
self.user = UserFactory()
self.view = views._DispatchingView() # pylint: disable=protected-access
self.dop_adapter.create_public_client(
......
......@@ -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):
......
......@@ -604,8 +604,8 @@ class ProgramMarketingDataExtender(ProgramDataExtender):
def __init__(self, program_data, user):
super(ProgramMarketingDataExtender, self).__init__(program_data, user)
# Aggregate dict of instructors for the program keyed by name
self.instructors = {}
# Aggregate list of instructors for the program
self.instructors = []
# Values for programs' price calculation.
self.data['avg_price_per_course'] = 0.0
......@@ -627,7 +627,7 @@ class ProgramMarketingDataExtender(ProgramDataExtender):
if not program_instructors:
# We cache the program instructors list to avoid repeated modulestore queries
program_instructors = self.instructors.values()
program_instructors = self.instructors
cache.set(cache_key, program_instructors, 3600)
self.data['instructors'] = program_instructors
......@@ -687,6 +687,7 @@ class ProgramMarketingDataExtender(ProgramDataExtender):
course_instructors = getattr(course_descriptor, 'instructor_info', {})
# Deduplicate program instructors using instructor name
self.instructors.update(
{instructor.get('name', '').strip(): instructor for instructor in course_instructors.get('instructors', [])}
)
curr_instructors_names = [instructor.get('name', '').strip() for instructor in self.instructors]
for instructor in course_instructors.get('instructors', []):
if instructor.get('name', '').strip() not in curr_instructors_names:
self.instructors.append(instructor)
......@@ -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'
......
......@@ -4,6 +4,7 @@ Test scenarios for the crowdsource hinter xblock.
import json
import unittest
import pytest
from django.conf import settings
from django.core.urlresolvers import reverse
from nose.plugins.attrib import attr
......@@ -135,6 +136,7 @@ class TestCrowdsourceHinter(SharedModuleStoreTestCase, LoginEnrollmentTestCase):
@attr(shard=1)
@pytest.mark.django111_expected_failure
class TestHinterFunctions(TestCrowdsourceHinter):
"""
Check that the essential functions of the hinter work as expected.
......
......@@ -9,13 +9,14 @@ import StringIO
import unittest
from copy import deepcopy
from ddt import data, ddt
import pytest
from django.conf import settings
from django.core.urlresolvers import reverse
from nose.plugins.attrib import attr
from ddt import data, ddt
from lms.djangoapps.courseware.tests.factories import GlobalStaffFactory
from lms.djangoapps.courseware.tests.helpers import LoginEnrollmentTestCase
from nose.plugins.attrib import attr
from openedx.core.lib.url_utils import quote_slashes
from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory
......@@ -196,6 +197,7 @@ class TestRecommender(SharedModuleStoreTestCase, LoginEnrollmentTestCase):
@attr(shard=1)
@pytest.mark.django111_expected_failure
class TestRecommenderCreateFromEmpty(TestRecommender):
"""
Check whether we can add resources to an empty database correctly
......@@ -256,6 +258,7 @@ class TestRecommenderResourceBase(TestRecommender):
@attr(shard=1)
@pytest.mark.django111_expected_failure
class TestRecommenderWithResources(TestRecommenderResourceBase):
"""
Check whether we can add/edit/flag/export resources correctly
......@@ -422,6 +425,7 @@ class TestRecommenderWithResources(TestRecommenderResourceBase):
@attr(shard=1)
@ddt
@pytest.mark.django111_expected_failure
class TestRecommenderVoteWithResources(TestRecommenderResourceBase):
"""
Check whether we can vote resources correctly
......@@ -536,6 +540,7 @@ class TestRecommenderVoteWithResources(TestRecommenderResourceBase):
@attr(shard=1)
@ddt
@pytest.mark.django111_expected_failure
class TestRecommenderStaffFeedbackWithResources(TestRecommenderResourceBase):
"""
Check whether we can remove/endorse resources correctly
......@@ -631,6 +636,7 @@ class TestRecommenderStaffFeedbackWithResources(TestRecommenderResourceBase):
@attr(shard=1)
@ddt
@pytest.mark.django111_expected_failure
class TestRecommenderFileUploading(TestRecommender):
"""
Check whether we can handle file uploading correctly
......
......@@ -54,7 +54,7 @@ edx-organizations==0.4.8
edx-rest-api-client==1.7.1
edx-search==1.1.0
edx-submissions==2.0.12
edxval==0.1.5
edxval==0.1.6
event-tracking==0.2.4
feedparser==5.1.3
firebase-token-generator==1.3.2
......
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