Commit 3abc7dc0 by cahrens

isort updates

parent e1916eb9
...@@ -16,9 +16,9 @@ from common.test.acceptance.pages.lms.staff_view import StaffCoursewarePage ...@@ -16,9 +16,9 @@ from common.test.acceptance.pages.lms.staff_view import StaffCoursewarePage
from common.test.acceptance.pages.studio.component_editor import ComponentVisibilityEditorView from common.test.acceptance.pages.studio.component_editor import ComponentVisibilityEditorView
from common.test.acceptance.pages.studio.overview import CourseOutlinePage as StudioCourseOutlinePage from common.test.acceptance.pages.studio.overview import CourseOutlinePage as StudioCourseOutlinePage
from common.test.acceptance.pages.studio.settings_group_configurations import GroupConfigurationsPage from common.test.acceptance.pages.studio.settings_group_configurations import GroupConfigurationsPage
from common.test.acceptance.tests.discussion.helpers import CohortTestMixin
from common.test.acceptance.tests.helpers import remove_file from common.test.acceptance.tests.helpers import remove_file
from common.test.acceptance.tests.studio.base_studio_test import ContainerBase from common.test.acceptance.tests.studio.base_studio_test import ContainerBase
from common.test.acceptance.tests.discussion.helpers import CohortTestMixin
@attr(shard=1) @attr(shard=1)
......
...@@ -2,15 +2,12 @@ ...@@ -2,15 +2,12 @@
Test Help links in LMS Test Help links in LMS
""" """
import json
from common.test.acceptance.fixtures import LMS_BASE_URL
from common.test.acceptance.fixtures.course import CourseFixture from common.test.acceptance.fixtures.course import CourseFixture
from common.test.acceptance.pages.lms.instructor_dashboard import InstructorDashboardPage from common.test.acceptance.pages.lms.instructor_dashboard import InstructorDashboardPage
from common.test.acceptance.tests.discussion.helpers import CohortTestMixin
from common.test.acceptance.tests.helpers import assert_opened_help_link_is_correct, url_for_help from common.test.acceptance.tests.helpers import assert_opened_help_link_is_correct, url_for_help
from common.test.acceptance.tests.lms.test_lms_instructor_dashboard import BaseInstructorDashboardTest from common.test.acceptance.tests.lms.test_lms_instructor_dashboard import BaseInstructorDashboardTest
from common.test.acceptance.tests.studio.base_studio_test import ContainerBase from common.test.acceptance.tests.studio.base_studio_test import ContainerBase
from common.test.acceptance.tests.discussion.helpers import CohortTestMixin
class TestCohortHelp(ContainerBase, CohortTestMixin): class TestCohortHelp(ContainerBase, CohortTestMixin):
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
End-to-end test for cohorted courseware. This uses both Studio and LMS. End-to-end test for cohorted courseware. This uses both Studio and LMS.
""" """
import json
from bok_choy.page_object import XSS_INJECTION from bok_choy.page_object import XSS_INJECTION
from nose.plugins.attrib import attr from nose.plugins.attrib import attr
...@@ -14,8 +12,8 @@ from common.test.acceptance.pages.lms.courseware import CoursewarePage ...@@ -14,8 +12,8 @@ from common.test.acceptance.pages.lms.courseware import CoursewarePage
from common.test.acceptance.pages.lms.instructor_dashboard import InstructorDashboardPage from common.test.acceptance.pages.lms.instructor_dashboard import InstructorDashboardPage
from common.test.acceptance.pages.studio.component_editor import ComponentVisibilityEditorView from common.test.acceptance.pages.studio.component_editor import ComponentVisibilityEditorView
from common.test.acceptance.pages.studio.settings_group_configurations import GroupConfigurationsPage from common.test.acceptance.pages.studio.settings_group_configurations import GroupConfigurationsPage
from common.test.acceptance.tests.lms.test_lms_user_preview import verify_expected_problem_visibility
from common.test.acceptance.tests.discussion.helpers import CohortTestMixin from common.test.acceptance.tests.discussion.helpers import CohortTestMixin
from common.test.acceptance.tests.lms.test_lms_user_preview import verify_expected_problem_visibility
from studio.base_studio_test import ContainerBase from studio.base_studio_test import ContainerBase
AUDIT_TRACK = "Audit" AUDIT_TRACK = "Audit"
......
import json import json
import logging import logging
from datetime import datetime from datetime import datetime
import ddt import ddt
from mock import ANY, Mock, call, patch
from nose.tools import assert_true
from course_modes.models import CourseMode
from course_modes.tests.factories import CourseModeFactory
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.http import Http404 from django.http import Http404
from django.test.client import Client, RequestFactory from django.test.client import Client, RequestFactory
from django.test.utils import override_settings from django.test.utils import override_settings
from django.utils import translation from django.utils import translation
from lms.lib.comment_client.utils import CommentClientPaginatedResult from django_comment_client.constants import TYPE_ENTRY, TYPE_SUBCATEGORY
from course_modes.models import CourseMode
from course_modes.tests.factories import CourseModeFactory
from django_comment_common.utils import ThreadContext
from django_comment_common.models import ForumsConfig, CourseDiscussionSettings
from django_comment_client.permissions import get_team from django_comment_client.permissions import get_team
from django_comment_client.tests.utils import config_course_discussions
from django_comment_client.tests.group_id import ( from django_comment_client.tests.group_id import (
GroupIdAssertionMixin,
CohortedTopicGroupIdTestMixin, CohortedTopicGroupIdTestMixin,
NonCohortedTopicGroupIdTestMixin, GroupIdAssertionMixin,
NonCohortedTopicGroupIdTestMixin
) )
from django_comment_client.constants import TYPE_ENTRY, TYPE_SUBCATEGORY
from django_comment_client.tests.unicode import UnicodeTestMixin from django_comment_client.tests.unicode import UnicodeTestMixin
from django_comment_client.tests.utils import CohortedTestCase, ForumsEnableMixin, topic_name_to_id from django_comment_client.tests.utils import (
CohortedTestCase,
ForumsEnableMixin,
config_course_discussions,
topic_name_to_id
)
from django_comment_client.utils import strip_none from django_comment_client.utils import strip_none
from django_comment_common.models import CourseDiscussionSettings, ForumsConfig
from django_comment_common.utils import ThreadContext
from lms.djangoapps.courseware.exceptions import CourseAccessRedirect
from lms.djangoapps.discussion import views from lms.djangoapps.discussion import views
from lms.djangoapps.discussion.views import course_discussions_settings_handler from lms.djangoapps.discussion.views import course_discussions_settings_handler
from student.tests.factories import UserFactory, CourseEnrollmentFactory from lms.djangoapps.teams.tests.factories import CourseTeamFactory
from util.testing import UrlResetMixin from lms.lib.comment_client.utils import CommentClientPaginatedResult
from openedx.core.djangoapps.course_groups.models import CourseUserGroup
from openedx.core.djangoapps.course_groups.tests.helpers import config_course_cohorts from openedx.core.djangoapps.course_groups.tests.helpers import config_course_cohorts
from openedx.core.djangoapps.course_groups.tests.test_views import CohortViewsTestCase from openedx.core.djangoapps.course_groups.tests.test_views import CohortViewsTestCase
from openedx.core.djangoapps.util.testing import ContentGroupTestCase from openedx.core.djangoapps.util.testing import ContentGroupTestCase
from openedx.features.enterprise_support.tests.mixins.enterprise import EnterpriseTestConsentRequired from openedx.features.enterprise_support.tests.mixins.enterprise import EnterpriseTestConsentRequired
from student.tests.factories import CourseEnrollmentFactory, UserFactory
from util.testing import UrlResetMixin
from xmodule.modulestore import ModuleStoreEnum from xmodule.modulestore import ModuleStoreEnum
from xmodule.modulestore.django import modulestore from xmodule.modulestore.django import modulestore
from xmodule.modulestore.tests.django_utils import ( from xmodule.modulestore.tests.django_utils import (
ModuleStoreTestCase,
SharedModuleStoreTestCase,
TEST_DATA_MONGO_MODULESTORE, TEST_DATA_MONGO_MODULESTORE,
ModuleStoreTestCase,
SharedModuleStoreTestCase
) )
from xmodule.modulestore.tests.factories import check_mongo_calls, CourseFactory, ItemFactory from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory, check_mongo_calls
from nose.tools import assert_true
from mock import patch, Mock, ANY, call
from openedx.core.djangoapps.course_groups.models import CourseUserGroup
from lms.djangoapps.courseware.exceptions import CourseAccessRedirect
from lms.djangoapps.teams.tests.factories import CourseTeamFactory
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
......
...@@ -2,67 +2,56 @@ ...@@ -2,67 +2,56 @@
Views handling read (GET) requests for the Discussion tab and inline discussions. Views handling read (GET) requests for the Discussion tab and inline discussions.
""" """
from functools import wraps
import logging import logging
from contextlib import contextmanager
from functools import wraps
from sets import Set from sets import Set
import django_comment_client.utils as utils
import lms.lib.comment_client as cc
from courseware.access import has_access
from courseware.courses import get_course_with_access
from courseware.views.views import CourseTabView
from django.conf import settings from django.conf import settings
from django.contrib.auth.decorators import login_required from django.contrib.auth.decorators import login_required
from django.core.context_processors import csrf
from django.core.urlresolvers import reverse
from django.contrib.auth.models import User from django.contrib.auth.models import User
from django.contrib.staticfiles.storage import staticfiles_storage from django.contrib.staticfiles.storage import staticfiles_storage
from django.core.context_processors import csrf
from django.core.urlresolvers import reverse
from django.http import Http404, HttpResponseServerError from django.http import Http404, HttpResponseServerError
from django.shortcuts import render_to_response from django.shortcuts import render_to_response
from django.template.loader import render_to_string from django.template.loader import render_to_string
from django.utils.translation import get_language_bidi from django.utils.translation import get_language_bidi
from django.views.decorators.http import require_GET
log = logging.getLogger("edx.discussions")
try:
import newrelic.agent
except ImportError:
newrelic = None # pylint: disable=invalid-name
from django.views.decorators.csrf import ensure_csrf_cookie from django.views.decorators.csrf import ensure_csrf_cookie
from django.views.decorators.http import require_http_methods from django.views.decorators.http import require_GET, require_http_methods
from rest_framework import status
from web_fragments.fragment import Fragment
from courseware.courses import get_course_with_access
from courseware.views.views import CourseTabView
from openedx.core.djangoapps.plugin_api.views import EdxFragmentView
from courseware.access import has_access
from student.models import CourseEnrollment
from xmodule.modulestore.django import modulestore
from django_comment_common.utils import ThreadContext, get_course_discussion_settings, set_course_discussion_settings
from django_comment_client.constants import TYPE_ENTRY from django_comment_client.constants import TYPE_ENTRY
from django_comment_client.permissions import has_permission, get_team from django_comment_client.permissions import get_team, has_permission
from django_comment_client.utils import ( from django_comment_client.utils import (
add_courseware_context,
available_division_schemes, available_division_schemes,
merge_dict, course_discussion_division_enabled,
extract, extract,
strip_none,
add_courseware_context,
get_group_id_for_comments_service, get_group_id_for_comments_service,
course_discussion_division_enabled, get_group_id_for_user,
get_group_names_by_id, get_group_names_by_id,
is_commentable_divided, is_commentable_divided,
get_group_id_for_user, merge_dict,
strip_none
) )
from django_comment_common.utils import ThreadContext, get_course_discussion_settings, set_course_discussion_settings
import django_comment_client.utils as utils
import lms.lib.comment_client as cc
from opaque_keys.edx.keys import CourseKey from opaque_keys.edx.keys import CourseKey
from openedx.core.djangoapps.plugin_api.views import EdxFragmentView
from rest_framework import status
from student.models import CourseEnrollment
from util.json_request import JsonResponse, expect_json
from web_fragments.fragment import Fragment
from xmodule.modulestore.django import modulestore
from contextlib import contextmanager log = logging.getLogger("edx.discussions")
from util.json_request import expect_json, JsonResponse try:
import newrelic.agent
except ImportError:
newrelic = None # pylint: disable=invalid-name
THREADS_PER_PAGE = 20 THREADS_PER_PAGE = 20
......
""" """
Discussion API internal interface Discussion API internal interface
""" """
import itertools
from collections import defaultdict from collections import defaultdict
from enum import Enum
from urllib import urlencode from urllib import urlencode
from urlparse import urlunparse from urlparse import urlunparse
from django.core.exceptions import ValidationError
from django.core.urlresolvers import reverse
from django.http import Http404
import itertools
from enum import Enum
from openedx.core.djangoapps.user_api.accounts.views import AccountViewSet
from rest_framework.exceptions import PermissionDenied
from lms.djangoapps.courseware.exceptions import CourseAccessRedirect
from opaque_keys import InvalidKeyError
from opaque_keys.edx.locator import CourseKey
from courseware.courses import get_course_with_access from courseware.courses import get_course_with_access
from discussion_api.exceptions import CommentNotFoundError, DiscussionDisabledError, ThreadNotFoundError
from discussion_api.exceptions import ThreadNotFoundError, CommentNotFoundError, DiscussionDisabledError
from discussion_api.forms import CommentActionsForm, ThreadActionsForm from discussion_api.forms import CommentActionsForm, ThreadActionsForm
from discussion_api.permissions import ( from discussion_api.permissions import (
can_delete, can_delete,
get_editable_fields, get_editable_fields,
get_initializable_comment_fields, get_initializable_comment_fields,
get_initializable_thread_fields, get_initializable_thread_fields
)
from discussion_api.serializers import CommentSerializer, ThreadSerializer, get_context, DiscussionTopicSerializer
from django_comment_client.base.views import (
track_comment_created_event,
track_thread_created_event,
track_voted_event,
) )
from discussion_api.serializers import CommentSerializer, DiscussionTopicSerializer, ThreadSerializer, get_context
from django.core.exceptions import ValidationError
from django.core.urlresolvers import reverse
from django.http import Http404
from django_comment_client.base.views import track_comment_created_event, track_thread_created_event, track_voted_event
from django_comment_client.utils import get_accessible_discussion_xblocks, get_group_id_for_user, is_commentable_divided
from django_comment_common.signals import ( from django_comment_common.signals import (
thread_created,
thread_edited,
thread_deleted,
thread_voted,
comment_created, comment_created,
comment_deleted,
comment_edited, comment_edited,
comment_voted, comment_voted,
comment_deleted, thread_created,
thread_deleted,
thread_edited,
thread_voted
) )
from django_comment_common.utils import get_course_discussion_settings from django_comment_common.utils import get_course_discussion_settings
from lms.djangoapps.courseware.exceptions import CourseAccessRedirect
from django_comment_client.utils import get_accessible_discussion_xblocks, is_commentable_divided, get_group_id_for_user
from lms.djangoapps.discussion_api.pagination import DiscussionAPIPagination from lms.djangoapps.discussion_api.pagination import DiscussionAPIPagination
from lms.lib.comment_client.comment import Comment from lms.lib.comment_client.comment import Comment
from lms.lib.comment_client.thread import Thread from lms.lib.comment_client.thread import Thread
from lms.lib.comment_client.utils import CommentClientRequestError from lms.lib.comment_client.utils import CommentClientRequestError
from openedx.core.lib.exceptions import CourseNotFoundError, PageNotFoundError, DiscussionNotFoundError from opaque_keys import InvalidKeyError
from opaque_keys.edx.locator import CourseKey
from openedx.core.djangoapps.user_api.accounts.views import AccountViewSet
from openedx.core.lib.exceptions import CourseNotFoundError, DiscussionNotFoundError, PageNotFoundError
from rest_framework.exceptions import PermissionDenied
class DiscussionTopic(object): class DiscussionTopic(object):
......
...@@ -4,31 +4,20 @@ Discussion API serializers ...@@ -4,31 +4,20 @@ Discussion API serializers
from urllib import urlencode from urllib import urlencode
from urlparse import urlunparse from urlparse import urlunparse
from discussion_api.permissions import NON_UPDATABLE_COMMENT_FIELDS, NON_UPDATABLE_THREAD_FIELDS, get_editable_fields
from discussion_api.render import render_body
from django.contrib.auth.models import User as DjangoUser from django.contrib.auth.models import User as DjangoUser
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from rest_framework import serializers
from discussion_api.permissions import (
NON_UPDATABLE_COMMENT_FIELDS,
NON_UPDATABLE_THREAD_FIELDS,
get_editable_fields,
)
from discussion_api.render import render_body
from django_comment_client.utils import is_comment_too_deep from django_comment_client.utils import is_comment_too_deep
from django_comment_common.models import FORUM_ROLE_ADMINISTRATOR, FORUM_ROLE_COMMUNITY_TA, FORUM_ROLE_MODERATOR, Role
from django_comment_common.utils import get_course_discussion_settings from django_comment_common.utils import get_course_discussion_settings
from django_comment_common.models import ( from lms.djangoapps.django_comment_client.utils import course_discussion_division_enabled, get_group_names_by_id
FORUM_ROLE_ADMINISTRATOR,
FORUM_ROLE_COMMUNITY_TA,
FORUM_ROLE_MODERATOR,
Role,
)
from lms.lib.comment_client.comment import Comment from lms.lib.comment_client.comment import Comment
from lms.lib.comment_client.thread import Thread from lms.lib.comment_client.thread import Thread
from lms.lib.comment_client.user import User as CommentClientUser from lms.lib.comment_client.user import User as CommentClientUser
from lms.lib.comment_client.utils import CommentClientRequestError from lms.lib.comment_client.utils import CommentClientRequestError
from lms.djangoapps.django_comment_client.utils import course_discussion_division_enabled, get_group_names_by_id from rest_framework import serializers
def get_context(course, request, thread=None): def get_context(course, request, thread=None):
......
""" """
Tests for Discussion API internal interface Tests for Discussion API internal interface
""" """
from datetime import datetime, timedelta
import itertools import itertools
from urlparse import parse_qs, urlparse, urlunparse from datetime import datetime, timedelta
from urllib import urlencode from urllib import urlencode
from urlparse import parse_qs, urlparse, urlunparse
import ddt import ddt
import httpretty
import mock import mock
from nose.plugins.attrib import attr from nose.plugins.attrib import attr
from pytz import UTC
from django.core.exceptions import ValidationError
from django.test.client import RequestFactory
from rest_framework.exceptions import PermissionDenied
from opaque_keys.edx.locator import CourseLocator
import httpretty
from common.test.utils import MockSignalHandlerMixin, disable_signal from common.test.utils import MockSignalHandlerMixin, disable_signal
from courseware.tests.factories import BetaTesterFactory, StaffFactory from courseware.tests.factories import BetaTesterFactory, StaffFactory
from discussion_api import api from discussion_api import api
...@@ -30,29 +22,34 @@ from discussion_api.api import ( ...@@ -30,29 +22,34 @@ from discussion_api.api import (
get_comment_list, get_comment_list,
get_course, get_course,
get_course_topics, get_course_topics,
get_thread,
get_thread_list, get_thread_list,
update_comment, update_comment,
update_thread, update_thread
get_thread,
) )
from discussion_api.exceptions import DiscussionDisabledError, ThreadNotFoundError, CommentNotFoundError from discussion_api.exceptions import CommentNotFoundError, DiscussionDisabledError, ThreadNotFoundError
from discussion_api.tests.utils import ( from discussion_api.tests.utils import (
CommentsServiceMockMixin, CommentsServiceMockMixin,
make_minimal_cs_comment, make_minimal_cs_comment,
make_minimal_cs_thread, make_minimal_cs_thread,
make_paginated_api_response, make_paginated_api_response
) )
from django.core.exceptions import ValidationError
from django.test.client import RequestFactory
from django_comment_client.tests.utils import ForumsEnableMixin
from django_comment_common.models import ( from django_comment_common.models import (
FORUM_ROLE_ADMINISTRATOR, FORUM_ROLE_ADMINISTRATOR,
FORUM_ROLE_COMMUNITY_TA, FORUM_ROLE_COMMUNITY_TA,
FORUM_ROLE_MODERATOR, FORUM_ROLE_MODERATOR,
FORUM_ROLE_STUDENT, FORUM_ROLE_STUDENT,
Role, Role
) )
from django_comment_client.tests.utils import ForumsEnableMixin from opaque_keys.edx.locator import CourseLocator
from openedx.core.djangoapps.course_groups.models import CourseUserGroupPartitionGroup from openedx.core.djangoapps.course_groups.models import CourseUserGroupPartitionGroup
from openedx.core.djangoapps.course_groups.tests.helpers import CohortFactory from openedx.core.djangoapps.course_groups.tests.helpers import CohortFactory
from openedx.core.lib.exceptions import CourseNotFoundError, PageNotFoundError from openedx.core.lib.exceptions import CourseNotFoundError, PageNotFoundError
from pytz import UTC
from rest_framework.exceptions import PermissionDenied
from student.tests.factories import CourseEnrollmentFactory, UserFactory from student.tests.factories import CourseEnrollmentFactory, UserFactory
from util.testing import UrlResetMixin from util.testing import UrlResetMixin
from xmodule.modulestore import ModuleStoreEnum from xmodule.modulestore import ModuleStoreEnum
......
...@@ -5,35 +5,30 @@ import itertools ...@@ -5,35 +5,30 @@ import itertools
from urlparse import urlparse from urlparse import urlparse
import ddt import ddt
import httpretty
import mock import mock
from nose.plugins.attrib import attr from nose.plugins.attrib import attr
from django.test.client import RequestFactory import httpretty
from discussion_api.serializers import CommentSerializer, ThreadSerializer, get_context from discussion_api.serializers import CommentSerializer, ThreadSerializer, get_context
from discussion_api.tests.utils import ( from discussion_api.tests.utils import CommentsServiceMockMixin, make_minimal_cs_comment, make_minimal_cs_thread
CommentsServiceMockMixin, from django.test.client import RequestFactory
make_minimal_cs_thread, from django_comment_client.tests.utils import ForumsEnableMixin
make_minimal_cs_comment,
)
from django_comment_common.models import ( from django_comment_common.models import (
FORUM_ROLE_ADMINISTRATOR, FORUM_ROLE_ADMINISTRATOR,
FORUM_ROLE_COMMUNITY_TA, FORUM_ROLE_COMMUNITY_TA,
FORUM_ROLE_MODERATOR, FORUM_ROLE_MODERATOR,
FORUM_ROLE_STUDENT, FORUM_ROLE_STUDENT,
Role, Role
) )
from lms.lib.comment_client.comment import Comment from lms.lib.comment_client.comment import Comment
from lms.lib.comment_client.thread import Thread from lms.lib.comment_client.thread import Thread
from openedx.core.djangoapps.course_groups.tests.helpers import CohortFactory
from student.tests.factories import UserFactory from student.tests.factories import UserFactory
from util.testing import UrlResetMixin from util.testing import UrlResetMixin
from xmodule.modulestore import ModuleStoreEnum from xmodule.modulestore import ModuleStoreEnum
from xmodule.modulestore.django import modulestore from xmodule.modulestore.django import modulestore
from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory from xmodule.modulestore.tests.factories import CourseFactory
from openedx.core.djangoapps.course_groups.tests.helpers import CohortFactory
from django_comment_client.tests.utils import ForumsEnableMixin
@ddt.ddt @ddt.ddt
......
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import datetime import datetime
import json import json
import ddt import ddt
import mock import mock
from mock import patch, Mock from mock import Mock, patch
from nose.plugins.attrib import attr from nose.plugins.attrib import attr
from pytz import UTC
from django.utils.timezone import UTC as django_utc
from django.core.urlresolvers import reverse
from django.test import TestCase, RequestFactory
from edxmako import add_lookup
from django_comment_client.tests.factories import RoleFactory
from django_comment_client.tests.unicode import UnicodeTestMixin
from django_comment_client.tests.utils import topic_name_to_id, config_course_discussions
from django_comment_client.constants import TYPE_ENTRY, TYPE_SUBCATEGORY
import django_comment_client.utils as utils import django_comment_client.utils as utils
from lms.lib.comment_client.utils import perform_request, CommentClientMaintenanceError
from django_comment_common.models import ForumsConfig, CourseDiscussionSettings
from django_comment_common.utils import get_course_discussion_settings, set_course_discussion_settings
from course_modes.models import CourseMode from course_modes.models import CourseMode
from course_modes.tests.factories import CourseModeFactory from course_modes.tests.factories import CourseModeFactory
from courseware.tests.factories import InstructorFactory
from courseware.tabs import get_course_tab_list from courseware.tabs import get_course_tab_list
from courseware.tests.factories import InstructorFactory
from django.core.urlresolvers import reverse
from django.test import RequestFactory, TestCase
from django.utils.timezone import UTC as django_utc
from django_comment_client.constants import TYPE_ENTRY, TYPE_SUBCATEGORY
from django_comment_client.tests.factories import RoleFactory
from django_comment_client.tests.unicode import UnicodeTestMixin
from django_comment_client.tests.utils import config_course_discussions, topic_name_to_id
from django_comment_common.models import CourseDiscussionSettings, ForumsConfig
from django_comment_common.utils import get_course_discussion_settings, set_course_discussion_settings
from edxmako import add_lookup
from lms.djangoapps.teams.tests.factories import CourseTeamFactory
from lms.lib.comment_client.utils import CommentClientMaintenanceError, perform_request
from openedx.core.djangoapps.content.course_structures.models import CourseStructure
from openedx.core.djangoapps.course_groups import cohorts from openedx.core.djangoapps.course_groups import cohorts
from openedx.core.djangoapps.course_groups.cohorts import set_course_cohorted from openedx.core.djangoapps.course_groups.cohorts import set_course_cohorted
from openedx.core.djangoapps.course_groups.tests.helpers import config_course_cohorts, CohortFactory from openedx.core.djangoapps.course_groups.tests.helpers import CohortFactory, config_course_cohorts
from student.tests.factories import UserFactory, AdminFactory, CourseEnrollmentFactory
from openedx.core.djangoapps.content.course_structures.models import CourseStructure
from openedx.core.djangoapps.util.testing import ContentGroupTestCase from openedx.core.djangoapps.util.testing import ContentGroupTestCase
from pytz import UTC
from student.roles import CourseStaffRole from student.roles import CourseStaffRole
from student.tests.factories import AdminFactory, CourseEnrollmentFactory, UserFactory
from xmodule.modulestore import ModuleStoreEnum from xmodule.modulestore import ModuleStoreEnum
from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory, ToyCourseFactory
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase, TEST_DATA_MIXED_MODULESTORE
from xmodule.modulestore.django import modulestore from xmodule.modulestore.django import modulestore
from lms.djangoapps.teams.tests.factories import CourseTeamFactory from xmodule.modulestore.tests.django_utils import TEST_DATA_MIXED_MODULESTORE, ModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory, ToyCourseFactory
@attr(shard=1) @attr(shard=1)
......
...@@ -3,15 +3,15 @@ Utilities for tests within the django_comment_client module. ...@@ -3,15 +3,15 @@ Utilities for tests within the django_comment_client module.
""" """
from mock import patch from mock import patch
from django_comment_common.models import ForumsConfig, Role
from django_comment_common.utils import CourseDiscussionSettings, seed_permissions_roles, set_course_discussion_settings
from openedx.core.djangoapps.course_groups.tests.helpers import CohortFactory from openedx.core.djangoapps.course_groups.tests.helpers import CohortFactory
from django_comment_common.models import Role, ForumsConfig
from django_comment_common.utils import seed_permissions_roles, set_course_discussion_settings, CourseDiscussionSettings
from student.tests.factories import CourseEnrollmentFactory, UserFactory from student.tests.factories import CourseEnrollmentFactory, UserFactory
from util.testing import UrlResetMixin from util.testing import UrlResetMixin
from xmodule.modulestore import ModuleStoreEnum from xmodule.modulestore import ModuleStoreEnum
from xmodule.modulestore.django import modulestore from xmodule.modulestore.django import modulestore
from xmodule.modulestore.tests.factories import CourseFactory
from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory
class ForumsEnableMixin(object): class ForumsEnableMixin(object):
......
from collections import defaultdict
from datetime import datetime
import json import json
import logging import logging
from django.conf import settings from collections import defaultdict
from datetime import datetime
import pystache_custom as pystache
import pytz import pytz
from courseware import courses
from courseware.access import has_access
from django.conf import settings
from django.contrib.auth.models import User from django.contrib.auth.models import User
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.db import connection from django.db import connection
from django.http import HttpResponse from django.http import HttpResponse
from django.utils.timezone import UTC from django.utils.timezone import UTC
import pystache_custom as pystache
from opaque_keys.edx.locations import i4xEncoder
from opaque_keys.edx.keys import CourseKey
from xmodule.modulestore.django import modulestore
from xmodule.partitions.partitions_service import PartitionService
from xmodule.partitions.partitions import ENROLLMENT_TRACK_PARTITION_ID
from django_comment_client.constants import TYPE_ENTRY, TYPE_SUBCATEGORY from django_comment_client.constants import TYPE_ENTRY, TYPE_SUBCATEGORY
from django_comment_client.permissions import check_permissions_by_view, has_permission, get_team from django_comment_client.permissions import check_permissions_by_view, get_team, has_permission
from django_comment_client.settings import MAX_COMMENT_DEPTH from django_comment_client.settings import MAX_COMMENT_DEPTH
from django_comment_common.models import Role, FORUM_ROLE_STUDENT, CourseDiscussionSettings from django_comment_common.models import FORUM_ROLE_STUDENT, CourseDiscussionSettings, Role
from django_comment_common.utils import get_course_discussion_settings from django_comment_common.utils import get_course_discussion_settings
from edxmako import lookup_template from edxmako import lookup_template
from opaque_keys.edx.keys import CourseKey
from courseware import courses from opaque_keys.edx.locations import i4xEncoder
from courseware.access import has_access
from openedx.core.djangoapps.content.course_structures.models import CourseStructure from openedx.core.djangoapps.content.course_structures.models import CourseStructure
from openedx.core.djangoapps.course_groups.cohorts import ( from openedx.core.djangoapps.course_groups.cohorts import get_cohort_id, get_cohort_names, is_course_cohorted
is_course_cohorted, get_cohort_id, get_cohort_names
)
from request_cache.middleware import request_cached from request_cache.middleware import request_cached
from student.roles import GlobalStaff from student.roles import GlobalStaff
from xmodule.modulestore.django import modulestore
from xmodule.partitions.partitions import ENROLLMENT_TRACK_PARTITION_ID
from xmodule.partitions.partitions_service import PartitionService
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
......
...@@ -2,18 +2,18 @@ ...@@ -2,18 +2,18 @@
Helper methods for testing cohorts. Helper methods for testing cohorts.
""" """
from factory import post_generation, Sequence
from factory.django import DjangoModelFactory
import json import json
from django_comment_common.models import CourseDiscussionSettings
from django_comment_common.utils import set_course_discussion_settings
from factory import Sequence, post_generation
from factory.django import DjangoModelFactory
from opaque_keys.edx.locations import SlashSeparatedCourseKey from opaque_keys.edx.locations import SlashSeparatedCourseKey
from xmodule.modulestore.django import modulestore
from xmodule.modulestore import ModuleStoreEnum from xmodule.modulestore import ModuleStoreEnum
from xmodule.modulestore.django import modulestore
from ..cohorts import set_course_cohorted from ..cohorts import set_course_cohorted
from django_comment_common.models import CourseDiscussionSettings from ..models import CohortMembership, CourseCohort, CourseCohortsSettings, CourseUserGroup
from django_comment_common.utils import set_course_discussion_settings
from ..models import CourseUserGroup, CourseCohort, CourseCohortsSettings, CohortMembership
class CohortFactory(DjangoModelFactory): class CohortFactory(DjangoModelFactory):
......
...@@ -5,13 +5,12 @@ Tests for cohorts ...@@ -5,13 +5,12 @@ Tests for cohorts
import ddt import ddt
from mock import call, patch from mock import call, patch
from nose.plugins.attrib import attr from nose.plugins.attrib import attr
import before_after
import before_after
from django.contrib.auth.models import User from django.contrib.auth.models import User
from django.db import IntegrityError from django.db import IntegrityError
from django.http import Http404 from django.http import Http404
from django.test import TestCase from django.test import TestCase
from opaque_keys.edx.locations import SlashSeparatedCourseKey from opaque_keys.edx.locations import SlashSeparatedCourseKey
from student.models import CourseEnrollment from student.models import CourseEnrollment
from student.tests.factories import UserFactory from student.tests.factories import UserFactory
...@@ -19,12 +18,9 @@ from xmodule.modulestore.django import modulestore ...@@ -19,12 +18,9 @@ from xmodule.modulestore.django import modulestore
from xmodule.modulestore.tests.django_utils import TEST_DATA_MIXED_MODULESTORE, ModuleStoreTestCase from xmodule.modulestore.tests.django_utils import TEST_DATA_MIXED_MODULESTORE, ModuleStoreTestCase
from xmodule.modulestore.tests.factories import ToyCourseFactory from xmodule.modulestore.tests.factories import ToyCourseFactory
from ..models import CourseUserGroup, CourseCohort, CourseUserGroupPartitionGroup
from .. import cohorts from .. import cohorts
from ..tests.helpers import ( from ..models import CourseCohort, CourseUserGroup, CourseUserGroupPartitionGroup
config_course_cohorts, config_course_cohorts_legacy, from ..tests.helpers import CohortFactory, CourseCohortFactory, config_course_cohorts, config_course_cohorts_legacy
CohortFactory, CourseCohortFactory
)
@attr(shard=2) @attr(shard=2)
......
...@@ -4,37 +4,32 @@ Tests for course group views ...@@ -4,37 +4,32 @@ Tests for course group views
# pylint: disable=attribute-defined-outside-init # pylint: disable=attribute-defined-outside-init
# pylint: disable=no-member # pylint: disable=no-member
import json import json
from collections import namedtuple from collections import namedtuple
from nose.plugins.attrib import attr from nose.plugins.attrib import attr
from django.contrib.auth.models import User from django.contrib.auth.models import User
from django.http import Http404 from django.http import Http404
from django.test.client import RequestFactory from django.test.client import RequestFactory
from django_comment_common.models import CourseDiscussionSettings from django_comment_common.models import CourseDiscussionSettings
from django_comment_common.utils import get_course_discussion_settings from django_comment_common.utils import get_course_discussion_settings
from opaque_keys.edx.locations import SlashSeparatedCourseKey
from student.models import CourseEnrollment from student.models import CourseEnrollment
from student.tests.factories import UserFactory from student.tests.factories import UserFactory
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory from xmodule.modulestore.tests.factories import CourseFactory
from opaque_keys.edx.locations import SlashSeparatedCourseKey
from ..models import CourseUserGroup, CourseCohort from ..cohorts import DEFAULT_COHORT_NAME, get_cohort, get_cohort_by_id, get_cohort_by_name, get_group_info_for_cohort
from ..models import CourseCohort, CourseUserGroup
from ..views import ( from ..views import (
add_users_to_cohort,
cohort_handler,
course_cohort_settings_handler, course_cohort_settings_handler,
cohort_handler, users_in_cohort,
add_users_to_cohort, remove_user_from_cohort,
link_cohort_to_partition_group, link_cohort_to_partition_group,
remove_user_from_cohort,
users_in_cohort
) )
from ..cohorts import ( from .helpers import CohortFactory, CourseCohortFactory, config_course_cohorts, config_course_cohorts_legacy
get_cohort, get_cohort_by_name, get_cohort_by_id,
DEFAULT_COHORT_NAME, get_group_info_for_cohort
)
from .helpers import (
config_course_cohorts, config_course_cohorts_legacy, CohortFactory, CourseCohortFactory
)
@attr(shard=2) @attr(shard=2)
......
""" """
UserPartitionScheme for enrollment tracks. UserPartitionScheme for enrollment tracks.
""" """
from django.conf import settings from course_modes.models import CourseMode
from courseware.masquerade import ( from courseware.masquerade import (
get_course_masquerade, get_course_masquerade,
get_masquerading_user_group, get_masquerading_user_group,
is_masquerading_as_specific_student is_masquerading_as_specific_student
) )
from course_modes.models import CourseMode from django.conf import settings
from student.models import CourseEnrollment
from opaque_keys.edx.keys import CourseKey from opaque_keys.edx.keys import CourseKey
from openedx.core.djangoapps.verified_track_content.models import VerifiedTrackCohortedCourse from openedx.core.djangoapps.verified_track_content.models import VerifiedTrackCohortedCourse
from student.models import CourseEnrollment
from xmodule.partitions.partitions import Group, UserPartition from xmodule.partitions.partitions import Group, UserPartition
# These IDs must be less than 100 so that they do not overlap with Groups in # These IDs must be less than 100 so that they do not overlap with Groups in
# CohortUserPartition or RandomUserPartitionScheme # CohortUserPartition or RandomUserPartitionScheme
# (CMS' course_group_config uses a minimum value of 100 for all generated IDs). # (CMS' course_group_config uses a minimum value of 100 for all generated IDs).
......
...@@ -4,23 +4,26 @@ Tests for Verified Track Cohorting models ...@@ -4,23 +4,26 @@ Tests for Verified Track Cohorting models
# pylint: disable=attribute-defined-outside-init # pylint: disable=attribute-defined-outside-init
# pylint: disable=no-member # pylint: disable=no-member
from django.test import TestCase
import mock import mock
from mock import patch from mock import patch
from django.test import TestCase
from opaque_keys.edx.keys import CourseKey from opaque_keys.edx.keys import CourseKey
from openedx.core.djangoapps.course_groups.cohorts import (
from openedx.core.djangoapps.course_groups.cohorts import get_cohort DEFAULT_COHORT_NAME,
CourseCohort,
add_cohort,
get_cohort,
set_course_cohorted
)
from openedx.core.djangolib.testing.utils import skip_unless_lms
from student.models import CourseMode from student.models import CourseMode
from student.tests.factories import UserFactory, CourseEnrollmentFactory from student.tests.factories import CourseEnrollmentFactory, UserFactory
from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory from xmodule.modulestore.tests.factories import CourseFactory
from ..models import VerifiedTrackCohortedCourse, DEFAULT_VERIFIED_COHORT_NAME
from ..models import DEFAULT_VERIFIED_COHORT_NAME, VerifiedTrackCohortedCourse
from ..tasks import sync_cohort_with_mode from ..tasks import sync_cohort_with_mode
from openedx.core.djangoapps.course_groups.cohorts import (
set_course_cohorted, add_cohort, CourseCohort, DEFAULT_COHORT_NAME
)
from openedx.core.djangolib.testing.utils import skip_unless_lms
class TestVerifiedTrackCohortedCourse(TestCase): class TestVerifiedTrackCohortedCourse(TestCase):
......
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