Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
f33832a6
Commit
f33832a6
authored
Jan 12, 2017
by
J. Cliff Dyer
Committed by
J. Cliff Dyer
Jan 18, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
scoutrule: dedupe skip_unless_lms
parent
0d2ae5d4
Show whitespace changes
Inline
Side-by-side
Showing
42 changed files
with
198 additions
and
193 deletions
+198
-193
openedx/core/djangoapps/api_admin/tests/test_forms.py
+2
-3
openedx/core/djangoapps/api_admin/tests/test_models.py
+3
-4
openedx/core/djangoapps/api_admin/tests/test_views.py
+38
-9
openedx/core/djangoapps/bookmarks/tests/test_api.py
+2
-2
openedx/core/djangoapps/bookmarks/tests/test_models.py
+2
-4
openedx/core/djangoapps/bookmarks/tests/test_services.py
+2
-4
openedx/core/djangoapps/bookmarks/tests/test_views.py
+3
-3
openedx/core/djangoapps/cache_toolbox/tests/test_middleware.py
+3
-5
openedx/core/djangoapps/celery_utils/tests/test_task.py
+2
-7
openedx/core/djangoapps/course_groups/tests/test_partition_scheme.py
+3
-6
openedx/core/djangoapps/course_groups/tests/test_views.py
+3
-3
openedx/core/djangoapps/coursetalk/tests/test_helpers.py
+2
-4
openedx/core/djangoapps/credentials/tests/test_models.py
+3
-4
openedx/core/djangoapps/credentials/tests/test_utils.py
+2
-5
openedx/core/djangoapps/credit/tests/test_api.py
+3
-4
openedx/core/djangoapps/credit/tests/test_partition.py
+2
-4
openedx/core/djangoapps/credit/tests/test_signals.py
+2
-3
openedx/core/djangoapps/credit/tests/test_views.py
+6
-6
openedx/core/djangoapps/embargo/tests/test_api.py
+3
-3
openedx/core/djangoapps/embargo/tests/test_middleware.py
+3
-3
openedx/core/djangoapps/embargo/tests/test_views.py
+2
-3
openedx/core/djangoapps/external_auth/tests/test_ssl.py
+18
-18
openedx/core/djangoapps/profile_images/tests/test_images.py
+4
-5
openedx/core/djangoapps/profile_images/tests/test_views.py
+6
-7
openedx/core/djangoapps/programs/tasks/v1/tests/test_tasks.py
+6
-7
openedx/core/djangoapps/programs/tests/test_backpopulate_program_credentials.py
+2
-3
openedx/core/djangoapps/programs/tests/test_utils.py
+6
-8
openedx/core/djangoapps/site_configuration/tests/test_middleware.py
+2
-2
openedx/core/djangoapps/theming/tests/test_finders.py
+2
-2
openedx/core/djangoapps/theming/tests/test_helpers.py
+3
-3
openedx/core/djangoapps/theming/tests/test_microsites.py
+2
-3
openedx/core/djangoapps/theming/tests/test_storage.py
+2
-2
openedx/core/djangoapps/theming/tests/test_theme_locales.py
+5
-4
openedx/core/djangoapps/theming/tests/test_theme_style_overrides.py
+7
-8
openedx/core/djangoapps/user_api/accounts/tests/test_api.py
+7
-6
openedx/core/djangoapps/user_api/accounts/tests/test_image_helpers.py
+3
-4
openedx/core/djangoapps/user_api/accounts/tests/test_views.py
+4
-5
openedx/core/djangoapps/user_api/management/tests/test_email_opt_in_list.py
+2
-3
openedx/core/djangoapps/user_api/preferences/tests/test_api.py
+2
-4
openedx/core/djangoapps/user_api/preferences/tests/test_views.py
+4
-5
openedx/core/djangoapps/user_api/tests/test_views.py
+5
-5
openedx/core/djangolib/testing/utils.py
+15
-0
No files found.
openedx/core/djangoapps/api_admin/tests/test_forms.py
View file @
f33832a6
#pylint: disable=missing-docstring
import
unittest
import
ddt
from
django.conf
import
settings
from
django.test
import
TestCase
from
openedx.core.djangoapps.api_admin.forms
import
ApiAccessRequestForm
from
openedx.core.djangoapps.api_admin.tests.utils
import
VALID_DATA
from
openedx.core.djangolib.testing.utils
import
skip_unless_lms
@
unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
@
skip_unless_lms
@ddt.ddt
class
ApiAccessFormTest
(
TestCase
):
...
...
openedx/core/djangoapps/api_admin/tests/test_models.py
View file @
f33832a6
...
...
@@ -2,21 +2,20 @@
from
smtplib
import
SMTPException
import
ddt
from
django.conf
import
settings
from
django.db
import
IntegrityError
from
django.test
import
TestCase
import
mock
import
unittest
from
microsite_configuration.tests.factories
import
SiteFactory
from
openedx.core.djangoapps.api_admin.models
import
ApiAccessRequest
,
ApiAccessConfig
from
openedx.core.djangoapps.api_admin.models
import
log
as
model_log
from
openedx.core.djangoapps.api_admin.tests.factories
import
ApiAccessRequestFactory
from
openedx.core.djangolib.testing.utils
import
skip_unless_lms
from
student.tests.factories
import
UserFactory
@ddt.ddt
@
unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
@
skip_unless_lms
class
ApiAccessRequestTests
(
TestCase
):
def
setUp
(
self
):
...
...
@@ -79,7 +78,7 @@ class ApiAccessConfigTests(TestCase):
)
@
unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
@
skip_unless_lms
class
ApiAccessRequestSignalTests
(
TestCase
):
def
setUp
(
self
):
super
(
ApiAccessRequestSignalTests
,
self
)
.
setUp
()
...
...
openedx/core/djangoapps/api_admin/tests/test_views.py
View file @
f33832a6
""" Tests for the api_admin app's views. """
import
json
import
unittest
import
ddt
import
httpretty
...
...
@@ -16,19 +15,26 @@ from openedx.core.djangoapps.api_admin.tests.factories import (
ApiAccessRequestFactory
,
ApplicationFactory
,
CatalogFactory
)
from
openedx.core.djangoapps.api_admin.tests.utils
import
VALID_DATA
from
openedx.core.djangolib.testing.utils
import
skip_unless_lms
from
student.tests.factories
import
UserFactory
Application
=
get_application_model
()
# pylint: disable=invalid-name
class
ApiAdminTest
(
TestCase
):
"""
Base class to allow API admin access to tests.
"""
def
setUp
(
self
):
super
(
ApiAdminTest
,
self
)
.
setUp
()
ApiAccessConfig
(
enabled
=
True
)
.
save
()
@
unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
@
skip_unless_lms
class
ApiRequestViewTest
(
ApiAdminTest
):
"""
Test the API Request View.
"""
def
setUp
(
self
):
super
(
ApiRequestViewTest
,
self
)
.
setUp
()
self
.
url
=
reverse
(
'api_admin:api-request'
)
...
...
@@ -93,10 +99,13 @@ class ApiRequestViewTest(ApiAdminTest):
self
.
assertEqual
(
response
.
status_code
,
404
)
@
unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
@
skip_unless_lms
@override_settings
(
PLATFORM_NAME
=
'edX'
)
@ddt.ddt
class
ApiRequestStatusViewTest
(
ApiAdminTest
):
"""
Tests of the API Status endpoint.
"""
def
setUp
(
self
):
super
(
ApiRequestStatusViewTest
,
self
)
.
setUp
()
password
=
'abc123'
...
...
@@ -198,10 +207,15 @@ class ApiRequestStatusViewTest(ApiAdminTest):
self
.
assertIn
(
'Enter a valid URL.'
,
response
.
content
)
@
unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
@
skip_unless_lms
class
ApiTosViewTest
(
ApiAdminTest
):
"""
Tests of the API terms of service endpoint.
"""
def
test_get_api_tos
(
self
):
"""Verify that the terms of service can be read."""
"""
Verify that the terms of service can be read.
"""
url
=
reverse
(
'api_admin:api-tos'
)
response
=
self
.
client
.
get
(
url
)
self
.
assertEqual
(
response
.
status_code
,
200
)
...
...
@@ -209,6 +223,9 @@ class ApiTosViewTest(ApiAdminTest):
class
CatalogTest
(
ApiAdminTest
):
"""
Test the catalog API.
"""
def
setUp
(
self
):
super
(
CatalogTest
,
self
)
.
setUp
()
password
=
'abc123'
...
...
@@ -232,8 +249,11 @@ class CatalogTest(ApiAdminTest):
)
@
unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
@
skip_unless_lms
class
CatalogSearchViewTest
(
CatalogTest
):
"""
Test the catalog search endpoint.
"""
def
setUp
(
self
):
super
(
CatalogSearchViewTest
,
self
)
.
setUp
()
self
.
url
=
reverse
(
'api_admin:catalog-search'
)
...
...
@@ -254,8 +274,11 @@ class CatalogSearchViewTest(CatalogTest):
self
.
assertRedirects
(
response
,
reverse
(
'api_admin:catalog-search'
))
@
unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
@
skip_unless_lms
class
CatalogListViewTest
(
CatalogTest
):
"""
Test the catalog list endpoint.
"""
def
setUp
(
self
):
super
(
CatalogListViewTest
,
self
)
.
setUp
()
self
.
catalog_user
=
UserFactory
()
...
...
@@ -304,8 +327,11 @@ class CatalogListViewTest(CatalogTest):
self
.
assertEqual
(
len
([
r
for
r
in
httpretty
.
httpretty
.
latest_requests
if
r
.
method
==
'POST'
]),
0
)
@
unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
@
skip_unless_lms
class
CatalogEditViewTest
(
CatalogTest
):
"""
Test edits to the catalog endpoint.
"""
def
setUp
(
self
):
super
(
CatalogEditViewTest
,
self
)
.
setUp
()
self
.
catalog_user
=
UserFactory
()
...
...
@@ -353,8 +379,11 @@ class CatalogEditViewTest(CatalogTest):
self
.
assertEqual
(
len
([
r
for
r
in
httpretty
.
httpretty
.
latest_requests
if
r
.
method
==
'PATCH'
]),
0
)
@
unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
@
skip_unless_lms
class
CatalogPreviewViewTest
(
CatalogTest
):
"""
Test the catalog preview endpoint.
"""
def
setUp
(
self
):
super
(
CatalogPreviewViewTest
,
self
)
.
setUp
()
self
.
url
=
reverse
(
'api_admin:catalog-preview'
)
...
...
openedx/core/djangoapps/bookmarks/tests/test_api.py
View file @
f33832a6
...
...
@@ -4,13 +4,13 @@ Tests for bookmarks api.
import
ddt
from
mock
import
patch
from
nose.plugins.attrib
import
attr
from
unittest
import
skipUnless
from
django.conf
import
settings
from
django.core.exceptions
import
ObjectDoesNotExist
from
opaque_keys.edx.keys
import
UsageKey
from
openedx.core.djangolib.testing.utils
import
skip_unless_lms
from
xmodule.modulestore.exceptions
import
ItemNotFoundError
from
..
import
api
...
...
@@ -38,7 +38,7 @@ class BookmarkApiEventTestMixin(object):
@attr
(
shard
=
2
)
@ddt.ddt
@skip
Unless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Tests only valid in LMS'
)
@skip
_unless_lms
class
BookmarksAPITests
(
BookmarkApiEventTestMixin
,
BookmarksTestsBase
):
"""
These tests cover the parts of the API methods.
...
...
openedx/core/djangoapps/bookmarks/tests/test_models.py
View file @
f33832a6
...
...
@@ -8,9 +8,6 @@ from freezegun import freeze_time
import
mock
from
nose.plugins.attrib
import
attr
import
pytz
from
unittest
import
skipUnless
from
django.conf
import
settings
from
opaque_keys.edx.keys
import
UsageKey
from
opaque_keys.edx.locator
import
CourseLocator
,
BlockUsageLocator
...
...
@@ -19,6 +16,7 @@ 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
openedx.core.djangolib.testing.utils
import
skip_unless_lms
from
student.tests.factories
import
AdminFactory
,
UserFactory
from
..
import
DEFAULT_FIELDS
,
OPTIONAL_FIELDS
,
PathItem
...
...
@@ -228,7 +226,7 @@ class BookmarksTestsBase(ModuleStoreTestCase):
@attr
(
shard
=
2
)
@ddt.ddt
@skip
Unless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Tests only valid in LMS'
)
@skip
_unless_lms
class
BookmarkModelTests
(
BookmarksTestsBase
):
"""
Test the Bookmark model.
...
...
openedx/core/djangoapps/bookmarks/tests/test_services.py
View file @
f33832a6
...
...
@@ -2,18 +2,16 @@
Tests for bookmark services.
"""
from
nose.plugins.attrib
import
attr
from
unittest
import
skipUnless
from
django.conf
import
settings
from
opaque_keys.edx.keys
import
UsageKey
from
openedx.core.djangolib.testing.utils
import
skip_unless_lms
from
..services
import
BookmarksService
from
.test_models
import
BookmarksTestsBase
@attr
(
shard
=
2
)
@skip
Unless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Tests only valid in LMS'
)
@skip
_unless_lms
class
BookmarksServiceTests
(
BookmarksTestsBase
):
"""
Tests the Bookmarks service.
...
...
openedx/core/djangoapps/bookmarks/tests/test_views.py
View file @
f33832a6
...
...
@@ -5,7 +5,6 @@ Tests for bookmark views.
import
ddt
import
json
from
nose.plugins.attrib
import
attr
from
unittest
import
skipUnless
import
urllib
from
django.conf
import
settings
...
...
@@ -13,6 +12,7 @@ from django.core.urlresolvers import reverse
from
mock
import
patch
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
...
...
@@ -66,7 +66,7 @@ class BookmarksViewsTestsBase(BookmarksTestsBase, BookmarkApiEventTestMixin):
@attr
(
shard
=
2
)
@ddt.ddt
@skip
Unless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Tests only valid in LMS'
)
@skip
_unless_lms
class
BookmarksListViewTests
(
BookmarksViewsTestsBase
):
"""
This contains the tests for GET & POST methods of bookmark.views.BookmarksListView class
...
...
@@ -371,7 +371,7 @@ class BookmarksListViewTests(BookmarksViewsTestsBase):
@attr
(
shard
=
2
)
@ddt.ddt
@skip
Unless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Tests only valid in LMS'
)
@skip
_unless_lms
class
BookmarksDetailViewTests
(
BookmarksViewsTestsBase
):
"""
This contains the tests for GET & DELETE methods of bookmark.views.BookmarksDetailView class
...
...
openedx/core/djangoapps/cache_toolbox/tests/test_middleware.py
View file @
f33832a6
"""Tests for cached authentication middleware."""
import
unittest
from
django.conf
import
settings
from
django.contrib.auth.models
import
User
from
django.core.urlresolvers
import
reverse
from
django.test
import
TestCase
from
mock
import
patch
from
openedx.core.djangolib.testing.utils
import
skip_unless_cms
,
skip_unless_lms
from
student.tests.factories
import
UserFactory
...
...
@@ -33,13 +31,13 @@ class CachedAuthMiddlewareTestCase(TestCase):
response
=
self
.
client
.
get
(
test_url
)
self
.
assertRedirects
(
response
,
redirect_url
)
@
unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
@
skip_unless_lms
def
test_session_change_lms
(
self
):
"""Test session verification with LMS-specific URLs."""
dashboard_url
=
reverse
(
'dashboard'
)
self
.
_test_change_session_hash
(
dashboard_url
,
reverse
(
'signin_user'
)
+
'?next='
+
dashboard_url
)
@
unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'cms.urls'
,
'Test only valid in cms'
)
@
skip_unless_cms
def
test_session_change_cms
(
self
):
"""Test session verification with CMS-specific URLs."""
home_url
=
reverse
(
'home'
)
...
...
openedx/core/djangoapps/celery_utils/tests/test_task.py
View file @
f33832a6
...
...
@@ -5,15 +5,15 @@ Testing persistent tasks
from
__future__
import
print_function
from
celery
import
task
from
django.conf
import
settings
from
django.test
import
TestCase
from
unittest
import
skipUnless
import
six
from
openedx.core.djangolib.testing.utils
import
skip_unless_lms
from
..models
import
FailedTask
from
..task
import
PersistOnFailureTask
@skip_unless_lms
class
PersistOnFailureTaskTestCase
(
TestCase
):
"""
Test that persistent tasks save the appropriate values when needed.
...
...
@@ -32,15 +32,12 @@ class PersistOnFailureTaskTestCase(TestCase):
cls
.
exampletask
=
exampletask
super
(
PersistOnFailureTaskTestCase
,
cls
)
.
setUpClass
()
@skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
def
test_exampletask_without_failure
(
self
):
result
=
self
.
exampletask
.
delay
()
result
.
wait
()
self
.
assertEqual
(
result
.
status
,
u'SUCCESS'
)
self
.
assertFalse
(
FailedTask
.
objects
.
exists
())
@skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
def
test_exampletask_with_failure
(
self
):
result
=
self
.
exampletask
.
delay
(
message
=
u'The example task failed'
)
with
self
.
assertRaises
(
ValueError
):
...
...
@@ -57,7 +54,6 @@ class PersistOnFailureTaskTestCase(TestCase):
self
.
assertEqual
(
failed_task_object
.
exc
,
u"ValueError(u'The example task failed',)"
)
self
.
assertIsNone
(
failed_task_object
.
datetime_resolved
)
@skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
def
test_persists_when_called_with_wrong_args
(
self
):
result
=
self
.
exampletask
.
delay
(
15
,
u'2001-03-04'
,
err
=
True
)
with
self
.
assertRaises
(
TypeError
):
...
...
@@ -67,7 +63,6 @@ class PersistOnFailureTaskTestCase(TestCase):
self
.
assertEqual
(
failed_task_object
.
args
,
[
15
,
u'2001-03-04'
])
self
.
assertEqual
(
failed_task_object
.
kwargs
,
{
u'err'
:
True
})
@skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
def
test_persists_with_overlength_field
(
self
):
overlong_message
=
u''
.
join
(
u'
%03
d'
%
x
for
x
in
six
.
moves
.
range
(
100
))
result
=
self
.
exampletask
.
delay
(
message
=
overlong_message
)
...
...
openedx/core/djangoapps/course_groups/tests/test_partition_scheme.py
View file @
f33832a6
...
...
@@ -2,13 +2,9 @@
Test the partitions and partitions service
"""
import
json
from
django.conf
import
settings
import
django.test
from
mock
import
patch
from
nose.plugins.attrib
import
attr
from
unittest
import
skipUnless
from
courseware.masquerade
import
handle_ajax
,
setup_masquerade
from
courseware.tests.test_masquerade
import
StaffMasqueradeTestCase
...
...
@@ -19,6 +15,7 @@ from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase, TEST_DAT
from
xmodule.modulestore.tests.factories
import
ToyCourseFactory
from
openedx.core.djangoapps.user_api.partition_schemes
import
RandomUserPartitionScheme
from
openedx.core.djangolib.testing.utils
import
skip_unless_lms
from
..partition_scheme
import
CohortPartitionScheme
,
get_cohorted_user_partition
from
..models
import
CourseUserGroupPartitionGroup
from
..views
import
link_cohort_to_partition_group
,
unlink_cohort_partition_group
...
...
@@ -383,7 +380,7 @@ class TestMasqueradedGroup(StaffMasqueradeTestCase):
self
.
_verify_masquerade_for_group
(
self
.
user_partition
.
groups
[
1
])
self
.
_verify_masquerade_for_group
(
None
)
@skip
Unless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in LMS'
)
@skip
_unless_lms
@patch.dict
(
'django.conf.settings.FEATURES'
,
{
'DISABLE_START_DATES'
:
False
})
def
test_group_masquerade
(
self
):
"""
...
...
@@ -391,7 +388,7 @@ class TestMasqueradedGroup(StaffMasqueradeTestCase):
"""
self
.
_verify_masquerade_for_all_groups
()
@skip
Unless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in LMS'
)
@skip
_unless_lms
@patch.dict
(
'django.conf.settings.FEATURES'
,
{
'DISABLE_START_DATES'
:
False
})
def
test_group_masquerade_with_cohort
(
self
):
"""
...
...
openedx/core/djangoapps/course_groups/tests/test_views.py
View file @
f33832a6
...
...
@@ -8,9 +8,7 @@ import json
from
collections
import
namedtuple
from
datetime
import
datetime
from
nose.plugins.attrib
import
attr
from
unittest
import
skipUnless
from
django.conf
import
settings
from
django.contrib.auth.models
import
User
from
django.http
import
Http404
from
django.test.client
import
RequestFactory
...
...
@@ -22,6 +20,8 @@ from xmodule.modulestore.tests.factories import CourseFactory
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
from
xmodule.modulestore.tests.factories
import
ItemFactory
from
lms.djangoapps.django_comment_client.constants
import
TYPE_ENTRY
,
TYPE_SUBCATEGORY
from
openedx.core.djangolib.testing.utils
import
skip_unless_lms
from
..models
import
CourseUserGroup
,
CourseCohort
from
..views
import
(
...
...
@@ -1207,7 +1207,7 @@ class RemoveUserFromCohortTestCase(CohortViewsTestCase):
@attr
(
shard
=
2
)
@skip
Unless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Tests only valid in LMS'
)
@skip
_unless_lms
class
CourseCohortDiscussionTopicsTestCase
(
CohortViewsTestCase
):
"""
Tests the `cohort_discussion_topics` view.
...
...
openedx/core/djangoapps/coursetalk/tests/test_helpers.py
View file @
f33832a6
""" CourseTalk widget helpers tests """
from
__future__
import
unicode_literals
from
unittest
import
skipUnless
from
django
import
test
from
django.conf
import
settings
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
from
openedx.core.djangoapps.coursetalk
import
helpers
from
openedx.core.djangoapps.coursetalk
import
models
from
openedx.core.djangolib.testing.utils
import
skip_unless_lms
@skip
Unless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Tests only valid in LMS'
)
@skip
_unless_lms
class
CourseTalkKeyTests
(
test
.
TestCase
):
"""
CourseTalkKeyTests:
...
...
openedx/core/djangoapps/credentials/tests/test_models.py
View file @
f33832a6
"""Tests for models supporting Credentials-related functionality."""
import
unittest
from
django.conf
import
settings
from
django.test
import
TestCase
from
nose.plugins.attrib
import
attr
from
openedx.core.djangoapps.credentials.tests.mixins
import
CredentialsApiConfigMixin
from
openedx.core.djangolib.testing.utils
import
skip_unless_lms
@
unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
@
skip_unless_lms
@attr
(
shard
=
2
)
class
TestCredentialsApiConfig
(
CredentialsApiConfigMixin
,
TestCase
):
"""Tests covering the CredentialsApiConfig model."""
...
...
openedx/core/djangoapps/credentials/tests/test_utils.py
View file @
f33832a6
"""Tests covering Credentials utilities."""
import
unittest
from
django.conf
import
settings
from
django.core.cache
import
cache
from
nose.plugins.attrib
import
attr
import
httpretty
...
...
@@ -18,11 +15,11 @@ from openedx.core.djangoapps.credentials.utils import (
from
openedx.core.djangoapps.credentials.tests
import
factories
from
openedx.core.djangoapps.programs.tests.mixins
import
ProgramsApiConfigMixin
,
ProgramsDataMixin
from
openedx.core.djangoapps.programs.models
import
ProgramsApiConfig
from
openedx.core.djangolib.testing.utils
import
CacheIsolationTestCase
from
openedx.core.djangolib.testing.utils
import
CacheIsolationTestCase
,
skip_unless_lms
from
student.tests.factories
import
UserFactory
@
unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
@
skip_unless_lms
@attr
(
shard
=
2
)
class
TestCredentialsRetrieval
(
ProgramsApiConfigMixin
,
CredentialsApiConfigMixin
,
CredentialsDataMixin
,
ProgramsDataMixin
,
CacheIsolationTestCase
):
...
...
openedx/core/djangoapps/credit/tests/test_api.py
View file @
f33832a6
...
...
@@ -3,10 +3,8 @@ Tests for the API functions in the credit app.
"""
import
datetime
import
json
import
unittest
import
ddt
from
django.conf
import
settings
from
django.contrib.auth.models
import
User
from
django.core
import
mail
from
django.test.utils
import
override_settings
...
...
@@ -36,6 +34,7 @@ from openedx.core.djangoapps.credit.models import (
CreditEligibility
,
CreditRequest
)
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
...
...
@@ -203,7 +202,7 @@ class CreditApiTestBase(ModuleStoreTestCase):
@attr
(
shard
=
2
)
@
unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in LMS'
)
@
skip_unless_lms
@ddt.ddt
class
CreditRequirementApiTests
(
CreditApiTestBase
):
"""
...
...
@@ -1165,7 +1164,7 @@ class CreditProviderIntegrationApiTests(CreditApiTestBase):
@attr
(
shard
=
2
)
@
unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in LMS'
)
@
skip_unless_lms
@override_settings
(
ECOMMERCE_API_URL
=
TEST_API_URL
,
ECOMMERCE_API_SIGNING_KEY
=
TEST_API_SIGNING_KEY
,
...
...
openedx/core/djangoapps/credit/tests/test_partition.py
View file @
f33832a6
...
...
@@ -5,9 +5,6 @@ Tests for In-Course Reverification Access Control Partition scheme
import
ddt
from
nose.plugins.attrib
import
attr
import
unittest
from
django.conf
import
settings
from
lms.djangoapps.verify_student.models
import
(
VerificationCheckpoint
,
...
...
@@ -15,6 +12,7 @@ from lms.djangoapps.verify_student.models import (
SkippedReverification
,
)
from
openedx.core.djangoapps.credit.partition_schemes
import
VerificationPartitionScheme
from
openedx.core.djangolib.testing.utils
import
skip_unless_lms
from
student.models
import
CourseEnrollment
from
student.tests.factories
import
UserFactory
from
xmodule.partitions.partitions
import
UserPartition
,
Group
...
...
@@ -24,7 +22,7 @@ from xmodule.modulestore.tests.factories import CourseFactory
@attr
(
shard
=
2
)
@ddt.ddt
@
unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
@
skip_unless_lms
class
ReverificationPartitionTest
(
ModuleStoreTestCase
):
"""Tests for the Reverification Partition Scheme. """
...
...
openedx/core/djangoapps/credit/tests/test_signals.py
View file @
f33832a6
...
...
@@ -6,9 +6,7 @@ import ddt
import
pytz
from
datetime
import
timedelta
,
datetime
from
mock
import
MagicMock
from
unittest
import
skipUnless
from
django.conf
import
settings
from
django.test.client
import
RequestFactory
from
nose.plugins.attrib
import
attr
from
course_modes.models
import
CourseMode
...
...
@@ -22,10 +20,11 @@ from openedx.core.djangoapps.credit.api import (
)
from
openedx.core.djangoapps.credit.models
import
CreditCourse
,
CreditProvider
from
openedx.core.djangoapps.credit.signals
import
listen_for_grade_calculation
from
openedx.core.djangolib.testing.utils
import
skip_unless_lms
@attr
(
shard
=
2
)
@skip
Unless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in LMS'
)
@skip
_unless_lms
@ddt.ddt
class
TestMinGradedRequirementStatus
(
ModuleStoreTestCase
):
"""Test cases to check the minimum grade requirement status updated.
...
...
openedx/core/djangoapps/credit/tests/test_views.py
View file @
f33832a6
...
...
@@ -8,7 +8,6 @@ from __future__ import unicode_literals
import
datetime
import
json
import
unittest
import
ddt
import
pytz
...
...
@@ -28,6 +27,7 @@ from openedx.core.djangoapps.credit.signature import signature
from
openedx.core.djangoapps.credit.tests.factories
import
(
CreditProviderFactory
,
CreditEligibilityFactory
,
CreditCourseFactory
,
CreditRequestFactory
,
)
from
openedx.core.djangolib.testing.utils
import
skip_unless_lms
from
openedx.core.lib.token_utils
import
JwtBuilder
from
student.tests.factories
import
UserFactory
,
AdminFactory
from
util.date_utils
import
to_timestamp
...
...
@@ -113,7 +113,7 @@ class ReadOnlyMixin(object):
@attr
(
shard
=
2
)
@
unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
@
skip_unless_lms
class
CreditCourseViewSetTests
(
AuthMixin
,
UserMixin
,
TestCase
):
""" Tests for the CreditCourse endpoints.
...
...
@@ -276,7 +276,7 @@ class CreditCourseViewSetTests(AuthMixin, UserMixin, TestCase):
@attr
(
shard
=
2
)
@ddt.ddt
@
unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
@
skip_unless_lms
class
CreditProviderViewSetTests
(
ApiTestCaseMixin
,
ReadOnlyMixin
,
AuthMixin
,
UserMixin
,
TestCase
):
""" Tests for CreditProviderViewSet. """
list_path
=
'credit:creditprovider-list'
...
...
@@ -320,7 +320,7 @@ class CreditProviderViewSetTests(ApiTestCaseMixin, ReadOnlyMixin, AuthMixin, Use
@attr
(
shard
=
2
)
@
unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
@
skip_unless_lms
class
CreditProviderRequestCreateViewTests
(
ApiTestCaseMixin
,
UserMixin
,
TestCase
):
""" Tests for CreditProviderRequestCreateView. """
...
...
@@ -470,7 +470,7 @@ class CreditProviderRequestCreateViewTests(ApiTestCaseMixin, UserMixin, TestCase
@attr
(
shard
=
2
)
@ddt.ddt
@
unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
@
skip_unless_lms
class
CreditProviderCallbackViewTests
(
UserMixin
,
TestCase
):
""" Tests for CreditProviderCallbackView. """
...
...
@@ -624,7 +624,7 @@ class CreditProviderCallbackViewTests(UserMixin, TestCase):
@attr
(
shard
=
2
)
@ddt.ddt
@
unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
@
skip_unless_lms
class
CreditEligibilityViewTests
(
AuthMixin
,
UserMixin
,
ReadOnlyMixin
,
TestCase
):
""" Tests for CreditEligibilityView. """
view_name
=
'credit:eligibility_details'
...
...
openedx/core/djangoapps/embargo/tests/test_api.py
View file @
f33832a6
...
...
@@ -5,7 +5,6 @@ Tests for EmbargoMiddleware
from
contextlib
import
contextmanager
import
mock
from
nose.plugins.attrib
import
attr
import
unittest
import
pygeoip
import
ddt
...
...
@@ -14,6 +13,7 @@ from django.test.utils import override_settings
from
django.core.cache
import
cache
from
django.db
import
connection
from
openedx.core.djangolib.testing.utils
import
skip_unless_lms
from
student.tests.factories
import
UserFactory
from
xmodule.modulestore.tests.factories
import
CourseFactory
from
xmodule.modulestore.tests.django_utils
import
(
...
...
@@ -41,7 +41,7 @@ MODULESTORE_CONFIG = mixed_store_config(settings.COMMON_TEST_DATA_ROOT, {})
@attr
(
shard
=
3
)
@ddt.ddt
@override_settings
(
MODULESTORE
=
MODULESTORE_CONFIG
)
@
unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
@
skip_unless_lms
@mock.patch.dict
(
settings
.
FEATURES
,
{
'EMBARGO'
:
True
})
class
EmbargoCheckAccessApiTests
(
ModuleStoreTestCase
):
"""Test the embargo API calls to determine whether a user has access. """
...
...
@@ -239,7 +239,7 @@ class EmbargoCheckAccessApiTests(ModuleStoreTestCase):
@ddt.ddt
@override_settings
(
MODULESTORE
=
MODULESTORE_CONFIG
)
@
unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
@
skip_unless_lms
class
EmbargoMessageUrlApiTests
(
UrlResetMixin
,
ModuleStoreTestCase
):
"""Test the embargo API calls for retrieving the blocking message URLs. """
...
...
openedx/core/djangoapps/embargo/tests/test_middleware.py
View file @
f33832a6
...
...
@@ -2,7 +2,6 @@
Tests for EmbargoMiddleware with CountryAccessRules
"""
import
unittest
from
mock
import
patch
from
nose.plugins.attrib
import
attr
import
ddt
...
...
@@ -11,11 +10,12 @@ from django.core.urlresolvers import reverse
from
django.conf
import
settings
from
django.core.cache
import
cache
as
django_cache
from
config_models.models
import
cache
as
config_cache
from
openedx.core.djangolib.testing.utils
import
skip_unless_lms
from
util.testing
import
UrlResetMixin
from
student.tests.factories
import
UserFactory
from
xmodule.modulestore.tests.factories
import
CourseFactory
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
config_models.models
import
cache
as
config_cache
from
..models
import
RestrictedCourse
,
IPFilter
from
..test_utils
import
restrict_course
...
...
@@ -23,7 +23,7 @@ from ..test_utils import restrict_course
@attr
(
shard
=
3
)
@ddt.ddt
@
unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
@
skip_unless_lms
class
EmbargoMiddlewareAccessTests
(
UrlResetMixin
,
ModuleStoreTestCase
):
"""Tests of embargo middleware country access rules.
...
...
openedx/core/djangoapps/embargo/tests/test_views.py
View file @
f33832a6
"""Tests for embargo app views. """
import
unittest
from
mock
import
patch
from
django.core.urlresolvers
import
reverse
from
django.conf
import
settings
...
...
@@ -8,11 +7,11 @@ import ddt
from
util.testing
import
UrlResetMixin
from
..
import
messages
from
openedx.core.djangolib.testing.utils
import
CacheIsolationTestCase
from
openedx.core.djangolib.testing.utils
import
CacheIsolationTestCase
,
skip_unless_lms
from
openedx.core.djangoapps.theming.tests.test_util
import
with_comprehensive_theme
@
unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
@
skip_unless_lms
@ddt.ddt
class
CourseAccessMessageViewTest
(
CacheIsolationTestCase
,
UrlResetMixin
):
"""Tests for the courseware access message view.
...
...
openedx/core/djangoapps/external_auth/tests/test_ssl.py
View file @
f33832a6
...
...
@@ -3,10 +3,10 @@ Provides unit tests for SSL based authentication portions
of the external_auth app.
"""
# pylint: disable=no-member
from
contextlib
import
contextmanager
import
copy
import
unittest
from
mock
import
Mock
,
patch
from
contextlib
import
contextmanager
from
django.conf
import
settings
from
django.contrib.auth
import
SESSION_KEY
from
django.contrib.auth.models
import
AnonymousUser
,
User
...
...
@@ -15,10 +15,10 @@ from django.core.urlresolvers import reverse
from
django.test.client
import
Client
from
django.test.client
import
RequestFactory
from
django.test.utils
import
override_settings
from
mock
import
Mock
,
patch
from
openedx.core.djangoapps.external_auth.models
import
ExternalAuthMap
import
openedx.core.djangoapps.external_auth.views
as
external_auth_views
from
openedx.core.djangolib.testing.utils
import
skip_unless_cms
,
skip_unless_lms
from
student.models
import
CourseEnrollment
from
student.roles
import
CourseStaffRole
from
student.tests.factories
import
UserFactory
...
...
@@ -81,7 +81,7 @@ class SSLClientTest(ModuleStoreTestCase):
self
.
factory
=
RequestFactory
()
self
.
mock
=
Mock
()
@
unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
@
skip_unless_lms
def
test_ssl_login_with_signup_lms
(
self
):
"""
Validate that an SSL login creates an eamap user and
...
...
@@ -101,7 +101,7 @@ class SSLClientTest(ModuleStoreTestCase):
with
self
.
assertRaises
(
User
.
DoesNotExist
):
User
.
objects
.
get
(
email
=
self
.
USER_EMAIL
)
@
unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'cms.urls'
,
'Test only valid in cms'
)
@
skip_unless_cms
def
test_ssl_login_with_signup_cms
(
self
):
"""
Validate that an SSL login creates an eamap user and
...
...
@@ -120,7 +120,7 @@ class SSLClientTest(ModuleStoreTestCase):
with
self
.
assertRaises
(
User
.
DoesNotExist
):
User
.
objects
.
get
(
email
=
self
.
USER_EMAIL
)
@
unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
@
skip_unless_lms
@override_settings
(
FEATURES
=
FEATURES_WITH_SSL_AUTH_IMMEDIATE_SIGNUP
)
def
test_ssl_login_without_signup_lms
(
self
):
"""
...
...
@@ -140,7 +140,7 @@ class SSLClientTest(ModuleStoreTestCase):
except
ExternalAuthMap
.
DoesNotExist
,
ex
:
self
.
fail
(
'User did not get properly added to internal users, exception was {0}'
.
format
(
str
(
ex
)))
@
unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'cms.urls'
,
'Test only valid in cms'
)
@
skip_unless_cms
@override_settings
(
FEATURES
=
FEATURES_WITH_SSL_AUTH_IMMEDIATE_SIGNUP
)
def
test_ssl_login_without_signup_cms
(
self
):
"""
...
...
@@ -166,7 +166,7 @@ class SSLClientTest(ModuleStoreTestCase):
except
ExternalAuthMap
.
DoesNotExist
,
ex
:
self
.
fail
(
'User did not get properly added to internal users, exception was {0}'
.
format
(
str
(
ex
)))
@
unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
@
skip_unless_lms
@override_settings
(
FEATURES
=
FEATURES_WITH_SSL_AUTH_IMMEDIATE_SIGNUP
)
def
test_default_login_decorator_ssl
(
self
):
"""
...
...
@@ -184,7 +184,7 @@ class SSLClientTest(ModuleStoreTestCase):
response
.
redirect_chain
[
-
1
])
self
.
assertIn
(
SESSION_KEY
,
self
.
client
.
session
)
@
unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
@
skip_unless_lms
@override_settings
(
FEATURES
=
FEATURES_WITH_SSL_AUTH_IMMEDIATE_SIGNUP
)
def
test_registration_page_bypass
(
self
):
"""
...
...
@@ -198,7 +198,7 @@ class SSLClientTest(ModuleStoreTestCase):
response
.
redirect_chain
[
-
1
])
self
.
assertIn
(
SESSION_KEY
,
self
.
client
.
session
)
@
unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'cms.urls'
,
'Test only valid in cms'
)
@
skip_unless_cms
@override_settings
(
FEATURES
=
FEATURES_WITH_SSL_AUTH_IMMEDIATE_SIGNUP
)
def
test_cms_registration_page_bypass
(
self
):
"""
...
...
@@ -217,7 +217,7 @@ class SSLClientTest(ModuleStoreTestCase):
response
=
self
.
client
.
get
(
reverse
(
'signup'
),
follow
=
True
)
self
.
assertEqual
(
response
.
status_code
,
404
)
@
unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
@
skip_unless_lms
@override_settings
(
FEATURES
=
FEATURES_WITH_SSL_AUTH_IMMEDIATE_SIGNUP
)
def
test_signin_page_bypass
(
self
):
"""
...
...
@@ -238,7 +238,7 @@ class SSLClientTest(ModuleStoreTestCase):
response
.
redirect_chain
[
-
1
])
self
.
assertIn
(
SESSION_KEY
,
self
.
client
.
session
)
@
unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
@
skip_unless_lms
@override_settings
(
FEATURES
=
FEATURES_WITH_SSL_AUTH_IMMEDIATE_SIGNUP
)
def
test_ssl_bad_eamap
(
self
):
"""
...
...
@@ -263,7 +263,7 @@ class SSLClientTest(ModuleStoreTestCase):
SSL_CLIENT_S_DN
=
self
.
AUTH_DN
.
format
(
self
.
USER_NAME
,
self
.
USER_EMAIL
))
self
.
assertIn
(
SESSION_KEY
,
self
.
client
.
session
)
@
unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
@
skip_unless_lms
@override_settings
(
FEATURES
=
FEATURES_WITHOUT_SSL_AUTH
)
def
test_ssl_decorator_no_certs
(
self
):
"""Make sure no external auth happens without SSL enabled"""
...
...
@@ -279,7 +279,7 @@ class SSLClientTest(ModuleStoreTestCase):
self
.
assertTrue
(
self
.
mock
.
called
)
self
.
assertEqual
(
0
,
len
(
ExternalAuthMap
.
objects
.
all
()))
@
unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
@
skip_unless_lms
def
test_ssl_login_decorator
(
self
):
"""Create mock function to test ssl login decorator"""
...
...
@@ -305,7 +305,7 @@ class SSLClientTest(ModuleStoreTestCase):
dec_mock
(
request
)
self
.
assertTrue
(
self
.
mock
.
called
)
@
unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
@
skip_unless_lms
@override_settings
(
FEATURES
=
FEATURES_WITH_SSL_AUTH_IMMEDIATE_SIGNUP
)
def
test_ssl_decorator_auto_signup
(
self
):
"""
...
...
@@ -330,7 +330,7 @@ class SSLClientTest(ModuleStoreTestCase):
self
.
assertTrue
(
self
.
mock
.
called
)
@
unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
@
skip_unless_lms
@override_settings
(
FEATURES
=
FEATURES_WITH_SSL_AUTH_AUTO_ACTIVATE
)
def
test_ssl_lms_redirection
(
self
):
"""
...
...
@@ -361,7 +361,7 @@ class SSLClientTest(ModuleStoreTestCase):
response
.
redirect_chain
[
-
1
])
self
.
assertIn
(
SESSION_KEY
,
self
.
client
.
session
)
@
unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'cms.urls'
,
'Test only valid in cms'
)
@
skip_unless_cms
@override_settings
(
FEATURES
=
FEATURES_WITH_SSL_AUTH_AUTO_ACTIVATE
)
def
test_ssl_cms_redirection
(
self
):
"""
...
...
@@ -393,7 +393,7 @@ class SSLClientTest(ModuleStoreTestCase):
response
.
redirect_chain
[
-
1
])
self
.
assertIn
(
SESSION_KEY
,
self
.
client
.
session
)
@
unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
@
skip_unless_lms
@override_settings
(
FEATURES
=
FEATURES_WITH_SSL_AUTH_AUTO_ACTIVATE
)
def
test_ssl_logout
(
self
):
"""
...
...
openedx/core/djangoapps/profile_images/tests/test_images.py
View file @
f33832a6
...
...
@@ -5,9 +5,7 @@ from contextlib import closing
from
itertools
import
product
import
os
from
tempfile
import
NamedTemporaryFile
import
unittest
from
django.conf
import
settings
from
django.core.files.uploadedfile
import
UploadedFile
from
django.test
import
TestCase
from
django.test.utils
import
override_settings
...
...
@@ -17,6 +15,7 @@ from nose.plugins.attrib import attr
import
piexif
from
PIL
import
Image
from
openedx.core.djangolib.testing.utils
import
skip_unless_lms
from
..exceptions
import
ImageValidationError
from
..images
import
(
create_profile_images
,
...
...
@@ -31,7 +30,7 @@ from .helpers import make_image_file, make_uploaded_file
@attr
(
shard
=
2
)
@ddt.ddt
@
unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Profile Image API is only supported in LMS'
)
@
skip_unless_lms
class
TestValidateUploadedImage
(
TestCase
):
"""
Test validate_uploaded_image
...
...
@@ -127,7 +126,7 @@ class TestValidateUploadedImage(TestCase):
@attr
(
shard
=
2
)
@ddt.ddt
@
unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Profile Image API is only supported in LMS'
)
@
skip_unless_lms
class
TestGenerateProfileImages
(
TestCase
):
"""
Test create_profile_images
...
...
@@ -224,7 +223,7 @@ class TestGenerateProfileImages(TestCase):
@attr
(
shard
=
2
)
@
unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Profile Image API is only supported in LMS'
)
@
skip_unless_lms
class
TestRemoveProfileImages
(
TestCase
):
"""
Test remove_profile_images
...
...
openedx/core/djangoapps/profile_images/tests/test_views.py
View file @
f33832a6
...
...
@@ -5,9 +5,7 @@ from contextlib import closing
import
datetime
from
nose.plugins.attrib
import
attr
from
pytz
import
UTC
import
unittest
from
django.conf
import
settings
from
django.core.urlresolvers
import
reverse
from
django.http
import
HttpResponse
...
...
@@ -24,6 +22,7 @@ from openedx.core.djangoapps.user_api.accounts.image_helpers import (
get_profile_image_names
,
get_profile_image_storage
,
)
from
openedx.core.djangolib.testing.utils
import
skip_unless_lms
from
..images
import
create_profile_images
,
ImageValidationError
from
..views
import
LOG_MESSAGE_CREATE
,
LOG_MESSAGE_DELETE
...
...
@@ -153,7 +152,7 @@ class ProfileImageEndpointMixin(UserSettingsEventTestMixin):
@attr
(
shard
=
2
)
@
unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Profile Image API is only supported in LMS'
)
@
skip_unless_lms
@mock.patch
(
'openedx.core.djangoapps.profile_images.views.log'
)
class
ProfileImageViewGeneralTestCase
(
ProfileImageEndpointMixin
,
APITestCase
):
"""
...
...
@@ -174,7 +173,7 @@ class ProfileImageViewGeneralTestCase(ProfileImageEndpointMixin, APITestCase):
@attr
(
shard
=
2
)
@ddt.ddt
@
unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Profile Image API is only supported in LMS'
)
@
skip_unless_lms
@mock.patch
(
'openedx.core.djangoapps.profile_images.views.log'
)
class
ProfileImageViewPostTestCase
(
ProfileImageEndpointMixin
,
APITestCase
):
"""
...
...
@@ -384,7 +383,7 @@ class ProfileImageViewPostTestCase(ProfileImageEndpointMixin, APITestCase):
@attr
(
shard
=
2
)
@
unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Profile Image API is only supported in LMS'
)
@
skip_unless_lms
@mock.patch
(
'openedx.core.djangoapps.profile_images.views.log'
)
class
ProfileImageViewDeleteTestCase
(
ProfileImageEndpointMixin
,
APITestCase
):
"""
...
...
@@ -515,7 +514,7 @@ class DeprecatedProfileImageTestMixin(ProfileImageEndpointMixin):
@attr
(
shard
=
2
)
@
unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Profile Image API is only supported in LMS'
)
@
skip_unless_lms
@mock.patch
(
'openedx.core.djangoapps.profile_images.views.log'
)
class
DeprecatedProfileImageUploadTestCase
(
DeprecatedProfileImageTestMixin
,
APITestCase
):
"""
...
...
@@ -528,7 +527,7 @@ class DeprecatedProfileImageUploadTestCase(DeprecatedProfileImageTestMixin, APIT
@attr
(
shard
=
2
)
@
unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Profile Image API is only supported in LMS'
)
@
skip_unless_lms
@mock.patch
(
'openedx.core.djangoapps.profile_images.views.log'
)
class
DeprecatedProfileImageRemoveTestCase
(
DeprecatedProfileImageTestMixin
,
APITestCase
):
"""
...
...
openedx/core/djangoapps/programs/tasks/v1/tests/test_tasks.py
View file @
f33832a6
...
...
@@ -2,7 +2,6 @@
Tests for programs celery tasks.
"""
import
json
import
unittest
from
celery.exceptions
import
MaxRetriesExceededError
import
ddt
...
...
@@ -20,7 +19,7 @@ from openedx.core.djangoapps.credentials.tests.mixins import CredentialsApiConfi
from
openedx.core.djangoapps.programs.tests
import
factories
from
openedx.core.djangoapps.programs.tests.mixins
import
ProgramsApiConfigMixin
from
openedx.core.djangoapps.programs.tasks.v1
import
tasks
from
openedx.core.djangolib.testing.utils
import
CacheIsolationTestCase
from
openedx.core.djangolib.testing.utils
import
CacheIsolationTestCase
,
skip_unless_lms
from
student.tests.factories
import
UserFactory
...
...
@@ -28,7 +27,7 @@ TASKS_MODULE = 'openedx.core.djangoapps.programs.tasks.v1.tasks'
UTILS_MODULE
=
'openedx.core.djangoapps.programs.utils'
@
unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
@
skip_unless_lms
class
GetApiClientTestCase
(
TestCase
,
ProgramsApiConfigMixin
):
"""
Test the get_api_client function
...
...
@@ -53,7 +52,7 @@ class GetApiClientTestCase(TestCase, ProgramsApiConfigMixin):
@httpretty.activate
@
unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
@
skip_unless_lms
class
GetCompletedProgramsTestCase
(
ProgramsApiConfigMixin
,
CacheIsolationTestCase
):
"""
Test the get_completed_programs function
...
...
@@ -113,7 +112,7 @@ class GetCompletedProgramsTestCase(ProgramsApiConfigMixin, CacheIsolationTestCas
self
.
_assert_num_requests
(
1
)
@
unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
@
skip_unless_lms
class
GetAwardedCertificateProgramsTestCase
(
TestCase
):
"""
Test the get_awarded_certificate_programs function
...
...
@@ -154,7 +153,7 @@ class GetAwardedCertificateProgramsTestCase(TestCase):
self
.
assertEqual
(
result
,
[
1
])
@
unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
@
skip_unless_lms
class
AwardProgramCertificateTestCase
(
TestCase
):
"""
Test the award_program_certificate function
...
...
@@ -183,7 +182,7 @@ class AwardProgramCertificateTestCase(TestCase):
self
.
assertEqual
(
json
.
loads
(
httpretty
.
last_request
()
.
body
),
expected_body
)
@
unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
@
skip_unless_lms
@ddt.ddt
@mock.patch
(
TASKS_MODULE
+
'.award_program_certificate'
)
@mock.patch
(
TASKS_MODULE
+
'.get_awarded_certificate_programs'
)
...
...
openedx/core/djangoapps/programs/tests/test_backpopulate_program_credentials.py
View file @
f33832a6
"""Tests for the backpopulate_program_credentials management command."""
import
json
from
unittest
import
skipUnless
import
ddt
from
django.conf
import
settings
from
django.core.management
import
call_command
,
CommandError
from
django.test
import
TestCase
from
edx_oauth2_provider.tests.factories
import
ClientFactory
...
...
@@ -17,6 +15,7 @@ from lms.djangoapps.certificates.tests.factories import GeneratedCertificateFact
from
openedx.core.djangoapps.programs.models
import
ProgramsApiConfig
from
openedx.core.djangoapps.programs.tests
import
factories
from
openedx.core.djangoapps.programs.tests.mixins
import
ProgramsApiConfigMixin
from
openedx.core.djangolib.testing.utils
import
skip_unless_lms
from
student.tests.factories
import
UserFactory
...
...
@@ -26,7 +25,7 @@ COMMAND_MODULE = 'openedx.core.djangoapps.programs.management.commands.backpopul
@ddt.ddt
@httpretty.activate
@mock.patch
(
COMMAND_MODULE
+
'.award_program_certificates.delay'
)
@skip
Unless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
@skip
_unless_lms
class
BackpopulateProgramCredentialsTests
(
ProgramsApiConfigMixin
,
TestCase
):
"""Tests for the backpopulate_program_credentials management command."""
course_id
,
alternate_course_id
=
'org/course/run'
,
'org/alternate/run'
...
...
openedx/core/djangoapps/programs/tests/test_utils.py
View file @
f33832a6
...
...
@@ -2,11 +2,9 @@
import
copy
import
datetime
import
json
from
unittest
import
skipUnless
import
uuid
import
ddt
from
django.conf
import
settings
from
django.core.cache
import
cache
from
django.core.urlresolvers
import
reverse
from
django.test
import
TestCase
...
...
@@ -29,7 +27,7 @@ from openedx.core.djangoapps.programs import utils
from
openedx.core.djangoapps.programs.models
import
ProgramsApiConfig
from
openedx.core.djangoapps.programs.tests
import
factories
from
openedx.core.djangoapps.programs.tests.mixins
import
ProgramsApiConfigMixin
,
ProgramsDataMixin
from
openedx.core.djangolib.testing.utils
import
CacheIsolationTestCase
from
openedx.core.djangolib.testing.utils
import
CacheIsolationTestCase
,
skip_unless_lms
from
student.tests.factories
import
UserFactory
,
CourseEnrollmentFactory
from
util.date_utils
import
strftime_localized
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
...
...
@@ -45,7 +43,7 @@ MARKETING_URL = 'https://www.example.com/marketing/path'
@ddt.ddt
@attr
(
shard
=
2
)
@httpretty.activate
@skip
Unless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
@skip
_unless_lms
class
TestProgramRetrieval
(
ProgramsApiConfigMixin
,
ProgramsDataMixin
,
CredentialsDataMixin
,
CredentialsApiConfigMixin
,
CacheIsolationTestCase
):
"""Tests covering the retrieval of programs from the Programs service."""
...
...
@@ -190,7 +188,7 @@ class TestProgramRetrieval(ProgramsApiConfigMixin, ProgramsDataMixin, Credential
self
.
assertEqual
(
actual
,
[])
@skip
Unless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
@skip
_unless_lms
class
GetProgramsByRunTests
(
TestCase
):
"""Tests verifying that programs are inverted correctly."""
maxDiff
=
None
...
...
@@ -262,7 +260,7 @@ class GetProgramsByRunTests(TestCase):
self
.
assertEqual
(
course_ids
,
[])
@skip
Unless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
@skip
_unless_lms
class
GetCompletedCoursesTestCase
(
TestCase
):
"""
Test the get_completed_courses function
...
...
@@ -308,7 +306,7 @@ class GetCompletedCoursesTestCase(TestCase):
@attr
(
shard
=
2
)
@httpretty.activate
@skip
Unless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
@skip
_unless_lms
class
TestProgramProgressMeter
(
ProgramsApiConfigMixin
,
TestCase
):
"""Tests of the program progress utility class."""
def
setUp
(
self
):
...
...
@@ -700,7 +698,7 @@ class TestProgramProgressMeter(ProgramsApiConfigMixin, TestCase):
@ddt.ddt
@override_settings
(
ECOMMERCE_PUBLIC_URL_ROOT
=
ECOMMERCE_URL_ROOT
)
@skip
Unless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
@skip
_unless_lms
@mock.patch
(
UTILS_MODULE
+
'.get_run_marketing_url'
,
mock
.
Mock
(
return_value
=
MARKETING_URL
))
class
TestProgramDataExtender
(
ProgramsApiConfigMixin
,
ModuleStoreTestCase
):
"""Tests of the program data extender utility class."""
...
...
openedx/core/djangoapps/site_configuration/tests/test_middleware.py
View file @
f33832a6
...
...
@@ -3,7 +3,6 @@
Test site_configuration middleware.
"""
import
ddt
import
unittest
from
mock
import
patch
from
django.conf
import
settings
...
...
@@ -22,6 +21,7 @@ from microsite_configuration.tests.tests import (
MICROSITE_BACKENDS
,
)
from
openedx.core.djangoapps.site_configuration.tests.factories
import
SiteConfigurationFactory
,
SiteFactory
from
openedx.core.djangolib.testing.utils
import
skip_unless_lms
# NOTE: We set SESSION_SAVE_EVERY_REQUEST to True in order to make sure
...
...
@@ -29,7 +29,7 @@ from openedx.core.djangoapps.site_configuration.tests.factories import SiteConfi
# pylint: disable=no-member, protected-access
@ddt.ddt
@override_settings
(
SESSION_SAVE_EVERY_REQUEST
=
True
)
@
unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
@
skip_unless_lms
class
SessionCookieDomainMicrositeOverrideTests
(
DatabaseMicrositeTestCase
):
"""
Tests regarding the session cookie management in the middlware for Microsites
...
...
openedx/core/djangoapps/theming/tests/test_finders.py
View file @
f33832a6
"""
Tests for comprehensive theme static files finders.
"""
import
unittest
from
django.conf
import
settings
from
django.test
import
TestCase
from
openedx.core.djangoapps.theming.finders
import
ThemeFilesFinder
from
openedx.core.djangolib.testing.utils
import
skip_unless_lms
@
unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
@
skip_unless_lms
class
TestThemeFinders
(
TestCase
):
"""
Test comprehensive theming static files finders.
...
...
openedx/core/djangoapps/theming/tests/test_helpers.py
View file @
f33832a6
"""
Test helpers for Comprehensive Theming.
"""
import
unittest
from
mock
import
patch
,
Mock
from
django.test
import
TestCase
,
override_settings
...
...
@@ -12,6 +11,7 @@ from openedx.core.djangoapps.site_configuration import helpers as configuration_
from
openedx.core.djangoapps.theming
import
helpers
as
theming_helpers
from
openedx.core.djangoapps.theming.helpers
import
get_template_path_with_theme
,
strip_site_theme_templates_path
,
\
get_themes
,
Theme
,
get_theme_base_dir
from
openedx.core.djangolib.testing.utils
import
skip_unless_cms
,
skip_unless_lms
class
TestHelpers
(
TestCase
):
...
...
@@ -201,7 +201,7 @@ class TestHelpers(TestCase):
self
.
assertEqual
(
theming_helpers
.
get_template_path
(
"about.html"
),
"/microsite/about.html"
)
@
unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
@
skip_unless_lms
class
TestHelpersLMS
(
TestCase
):
"""Test comprehensive theming helper functions."""
...
...
@@ -244,7 +244,7 @@ class TestHelpersLMS(TestCase):
self
.
assertEqual
(
template_path
,
'/red-theme/lms/templates/header.html'
)
@
unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'cms.urls'
,
'Test only valid in cms'
)
@
skip_unless_cms
class
TestHelpersCMS
(
TestCase
):
"""Test comprehensive theming helper functions."""
...
...
openedx/core/djangoapps/theming/tests/test_microsites.py
View file @
f33832a6
"""
Tests for microsites and comprehensive themes.
"""
import
unittest
from
django.conf
import
settings
from
django.test
import
TestCase
from
django.contrib.sites.models
import
Site
from
openedx.core.djangoapps.theming.models
import
SiteTheme
from
openedx.core.djangolib.testing.utils
import
skip_unless_lms
@
unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
@
skip_unless_lms
class
TestComprehensiveThemeLMS
(
TestCase
):
"""
Test html, sass and static file overrides for comprehensive themes.
...
...
openedx/core/djangoapps/theming/tests/test_storage.py
View file @
f33832a6
...
...
@@ -2,7 +2,6 @@
Tests for comprehensive theme static files storage classes.
"""
import
ddt
import
unittest
import
re
from
mock
import
patch
...
...
@@ -12,9 +11,10 @@ from django.conf import settings
from
openedx.core.djangoapps.theming.helpers
import
get_theme_base_dirs
,
Theme
,
get_theme_base_dir
from
openedx.core.djangoapps.theming.storage
import
ThemeStorage
from
openedx.core.djangolib.testing.utils
import
skip_unless_lms
@
unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
@
skip_unless_lms
@ddt.ddt
class
TestStorageLMS
(
TestCase
):
"""
...
...
openedx/core/djangoapps/theming/tests/test_theme_locales.py
View file @
f33832a6
"""
Tests for Them
e
ing locales
Tests for Theming locales
"""
import
os
import
unittest
from
django.conf
import
settings
from
django.test
import
TestCase
import
os
from
openedx.core.djangolib.testing.utils
import
skip_unless_lms
class
TestComprehensiveThemeLocale
(
TestCase
):
"""
Test Comprehensive Theme Locales
"""
@
unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
@
skip_unless_lms
def
test_theme_locale_path_in_settings
(
self
):
"""
test comprehensive theming paths in settings.
...
...
openedx/core/djangoapps/theming/tests/test_theme_style_overrides.py
View file @
f33832a6
"""
Tests for comprehensive themes.
Tests for comprehensive themes.
"""
import
unittest
from
django.conf
import
settings
from
django.core.urlresolvers
import
reverse
from
django.test
import
TestCase
from
django.contrib
import
staticfiles
from
openedx.core.djangoapps.theming.tests.test_util
import
with_comprehensive_theme
from
openedx.core.djangolib.testing.utils
import
skip_unless_cms
,
skip_unless_lms
from
student.tests.factories
import
UserFactory
@
unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
@
skip_unless_lms
class
TestComprehensiveThemeLMS
(
TestCase
):
"""
Test html, sass and static file overrides for comprehensive themes.
...
...
@@ -66,7 +65,7 @@ class TestComprehensiveThemeLMS(TestCase):
self
.
assertEqual
(
result
,
settings
.
TEST_THEME
/
'lms/static/images/logo.png'
)
@
unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'cms.urls'
,
'Test only valid in cms'
)
@
skip_unless_cms
class
TestComprehensiveThemeCMS
(
TestCase
):
"""
Test html, sass and static file overrides for comprehensive themes.
...
...
@@ -92,7 +91,7 @@ class TestComprehensiveThemeCMS(TestCase):
self
.
assertContains
(
resp
,
"Login Page override for test-theme."
)
@
unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
@
skip_unless_lms
class
TestComprehensiveThemeDisabledLMS
(
TestCase
):
"""
Test Sass compilation order and sass overrides for comprehensive themes.
...
...
@@ -115,7 +114,7 @@ class TestComprehensiveThemeDisabledLMS(TestCase):
self
.
assertEqual
(
result
,
settings
.
REPO_ROOT
/
'lms/static/images/logo.png'
)
@
unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'cms.urls'
,
'Test only valid in cms'
)
@
skip_unless_cms
class
TestComprehensiveThemeDisabledCMS
(
TestCase
):
"""
Test default html, sass and static file when no theme is applied.
...
...
@@ -139,7 +138,7 @@ class TestComprehensiveThemeDisabledCMS(TestCase):
self
.
assertNotContains
(
resp
,
"Login Page override for test-theme."
)
@
unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
@
skip_unless_lms
class
TestStanfordTheme
(
TestCase
):
"""
Test html, sass and static file overrides for stanford theme.
...
...
openedx/core/djangoapps/user_api/accounts/tests/test_api.py
View file @
f33832a6
...
...
@@ -17,6 +17,7 @@ from django.conf import settings
from
django.contrib.auth.models
import
User
from
django.core
import
mail
from
django.test.client
import
RequestFactory
from
openedx.core.djangolib.testing.utils
import
skip_unless_lms
from
student.models
import
PendingEmailChange
from
student.tests.tests
import
UserSettingsEventTestMixin
from
...errors
import
(
...
...
@@ -35,7 +36,7 @@ def mock_render_to_string(template_name, context):
@attr
(
shard
=
2
)
@
unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Account APIs are only supported in LMS'
)
@
skip_unless_lms
class
TestAccountApi
(
UserSettingsEventTestMixin
,
TestCase
):
"""
These tests specifically cover the parts of the API methods that are not covered by test_views.py.
...
...
@@ -239,7 +240,7 @@ class TestAccountApi(UserSettingsEventTestMixin, TestCase):
{
'full'
:
50
,
'small'
:
10
},
clear
=
True
)
@
unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Account APIs are only supported in LMS'
)
@
skip_unless_lms
class
AccountSettingsOnCreationTest
(
TestCase
):
# pylint: disable=missing-docstring
...
...
@@ -333,7 +334,7 @@ class AccountCreationActivationAndPasswordChangeTest(TestCase):
u'a'
*
(
PASSWORD_MAX_LENGTH
+
1
)
]
@
unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
@
skip_unless_lms
def
test_activate_account
(
self
):
# Create the account, which is initially inactive
activation_key
=
create_account
(
self
.
USERNAME
,
self
.
PASSWORD
,
self
.
EMAIL
)
...
...
@@ -393,7 +394,7 @@ class AccountCreationActivationAndPasswordChangeTest(TestCase):
def
test_activate_account_invalid_key
(
self
):
activate_account
(
u'invalid'
)
@
unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in LMS'
)
@
skip_unless_lms
def
test_request_password_change
(
self
):
# Create and activate an account
activation_key
=
create_account
(
self
.
USERNAME
,
self
.
PASSWORD
,
self
.
EMAIL
)
...
...
@@ -411,7 +412,7 @@ class AccountCreationActivationAndPasswordChangeTest(TestCase):
result
=
re
.
search
(
r'(?P<url>https?://[^\s]+)'
,
email_body
)
self
.
assertIsNot
(
result
,
None
)
@
unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in LMS'
)
@
skip_unless_lms
def
test_request_password_change_invalid_user
(
self
):
with
self
.
assertRaises
(
UserNotFound
):
request_password_change
(
self
.
EMAIL
,
self
.
ORIG_HOST
,
self
.
IS_SECURE
)
...
...
@@ -419,7 +420,7 @@ class AccountCreationActivationAndPasswordChangeTest(TestCase):
# Verify that no email messages have been sent
self
.
assertEqual
(
len
(
mail
.
outbox
),
0
)
@
unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in LMS'
)
@
skip_unless_lms
def
test_request_password_change_inactive_user
(
self
):
# Create an account, but do not activate it
create_account
(
self
.
USERNAME
,
self
.
PASSWORD
,
self
.
EMAIL
)
...
...
openedx/core/djangoapps/user_api/accounts/tests/test_image_helpers.py
View file @
f33832a6
...
...
@@ -6,13 +6,12 @@ import hashlib
from
mock
import
patch
from
nose.plugins.attrib
import
attr
from
pytz
import
UTC
from
unittest
import
skipUnless
from
django.conf
import
settings
from
django.test
import
TestCase
from
..image_helpers
import
get_profile_image_urls_for_user
from
openedx.core.djangolib.testing.utils
import
skip_unless_lms
from
student.tests.factories
import
UserFactory
from
..image_helpers
import
get_profile_image_urls_for_user
TEST_SIZES
=
{
'full'
:
50
,
'small'
:
10
}
TEST_PROFILE_IMAGE_UPLOAD_DT
=
datetime
.
datetime
(
2002
,
1
,
9
,
15
,
43
,
01
,
tzinfo
=
UTC
)
...
...
@@ -20,7 +19,7 @@ TEST_PROFILE_IMAGE_UPLOAD_DT = datetime.datetime(2002, 1, 9, 15, 43, 01, tzinfo=
@attr
(
shard
=
2
)
@patch.dict
(
'openedx.core.djangoapps.user_api.accounts.image_helpers.PROFILE_IMAGE_SIZES_MAP'
,
TEST_SIZES
,
clear
=
True
)
@skip
Unless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
@skip
_unless_lms
class
ProfileImageUrlTestCase
(
TestCase
):
"""
Tests for profile image URL generation helpers.
...
...
openedx/core/djangoapps/user_api/accounts/tests/test_views.py
View file @
f33832a6
...
...
@@ -12,7 +12,6 @@ import json
from
mock
import
patch
from
nose.plugins.attrib
import
attr
from
pytz
import
UTC
import
unittest
from
django.conf
import
settings
from
django.core.urlresolvers
import
reverse
...
...
@@ -25,7 +24,7 @@ from student.tests.factories import UserFactory
from
student.models
import
UserProfile
,
LanguageProficiency
,
PendingEmailChange
from
openedx.core.djangoapps.user_api.accounts
import
ACCOUNT_VISIBILITY_PREF_KEY
from
openedx.core.djangoapps.user_api.preferences.api
import
set_user_preference
from
openedx.core.djangolib.testing.utils
import
CacheIsolationTestCase
from
openedx.core.djangolib.testing.utils
import
CacheIsolationTestCase
,
skip_unless_lms
from
..
import
PRIVATE_VISIBILITY
,
ALL_USERS_VISIBILITY
TEST_PROFILE_IMAGE_UPLOADED_AT
=
datetime
.
datetime
(
2002
,
1
,
9
,
15
,
43
,
01
,
tzinfo
=
UTC
)
...
...
@@ -140,7 +139,7 @@ class UserAPITestCase(APITestCase):
@ddt.ddt
@
unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Account APIs are only supported in LMS'
)
@
skip_unless_lms
@attr
(
shard
=
2
)
class
TestOwnUsernameAPI
(
CacheIsolationTestCase
,
UserAPITestCase
):
"""
...
...
@@ -193,7 +192,7 @@ class TestOwnUsernameAPI(CacheIsolationTestCase, UserAPITestCase):
@ddt.ddt
@
unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Account APIs are only supported in LMS'
)
@
skip_unless_lms
@patch
(
'openedx.core.djangoapps.user_api.accounts.image_helpers._PROFILE_IMAGE_SIZES'
,
[
50
,
10
])
@patch.dict
(
'openedx.core.djangoapps.user_api.accounts.image_helpers.PROFILE_IMAGE_SIZES_MAP'
,
...
...
@@ -783,7 +782,7 @@ class TestAccountsAPI(CacheIsolationTestCase, UserAPITestCase):
@attr
(
shard
=
2
)
@
unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
@
skip_unless_lms
class
TestAccountAPITransactions
(
TransactionTestCase
):
"""
Tests the transactional behavior of the account API
...
...
openedx/core/djangoapps/user_api/management/tests/test_email_opt_in_list.py
View file @
f33832a6
...
...
@@ -6,10 +6,8 @@ import shutil
import
csv
from
collections
import
defaultdict
from
nose.plugins.attrib
import
attr
from
unittest
import
skipUnless
import
ddt
from
django.conf
import
settings
from
django.contrib.auth.models
import
User
from
django.core.management.base
import
CommandError
...
...
@@ -21,11 +19,12 @@ from student.models import CourseEnrollment
from
openedx.core.djangoapps.user_api.preferences.api
import
update_email_opt_in
from
openedx.core.djangoapps.user_api.models
import
UserOrgTag
from
openedx.core.djangoapps.user_api.management.commands
import
email_opt_in_list
from
openedx.core.djangolib.testing.utils
import
skip_unless_lms
@attr
(
shard
=
2
)
@ddt.ddt
@skip
Unless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
@skip
_unless_lms
class
EmailOptInListTest
(
ModuleStoreTestCase
):
"""Tests for the email opt-in list management command. """
...
...
openedx/core/djangoapps/user_api/preferences/tests/test_api.py
View file @
f33832a6
...
...
@@ -4,17 +4,15 @@ Unit tests for preference APIs.
"""
import
datetime
import
ddt
import
unittest
from
mock
import
patch
from
nose.plugins.attrib
import
attr
from
pytz
import
common_timezones
,
utc
from
django.conf
import
settings
from
django.contrib.auth.models
import
User
from
django.test.utils
import
override_settings
from
dateutil.parser
import
parse
as
parse_datetime
from
openedx.core.djangolib.testing.utils
import
CacheIsolationTestCase
from
openedx.core.djangolib.testing.utils
import
CacheIsolationTestCase
,
skip_unless_lms
from
openedx.core.lib.time_zone_utils
import
get_display_time_zone
from
student.tests.factories
import
UserFactory
...
...
@@ -42,7 +40,7 @@ from ...preferences.api import (
@attr
(
shard
=
2
)
@
unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Account APIs are only supported in LMS'
)
@
skip_unless_lms
class
TestPreferenceAPI
(
CacheIsolationTestCase
):
"""
These tests specifically cover the parts of the API methods that are not covered by test_views.py.
...
...
openedx/core/djangoapps/user_api/preferences/tests/test_views.py
View file @
f33832a6
...
...
@@ -3,17 +3,16 @@
Unit tests for preference APIs.
"""
import
unittest
import
ddt
import
json
from
mock
import
patch
from
django.core.urlresolvers
import
reverse
from
django.conf
import
settings
from
django.test.testcases
import
TransactionTestCase
from
rest_framework.test
import
APIClient
from
student.tests.factories
import
UserFactory
from
openedx.core.djangolib.testing.utils
import
skip_unless_lms
from
...accounts.tests.test_views
import
UserAPITestCase
from
..api
import
set_user_preference
from
.test_api
import
get_expected_validation_developer_message
,
get_expected_key_error_user_message
...
...
@@ -22,7 +21,7 @@ TOO_LONG_PREFERENCE_KEY = u"x" * 256
@ddt.ddt
@
unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
@
skip_unless_lms
class
TestPreferencesAPI
(
UserAPITestCase
):
"""
Unit tests /api/user/v1/accounts/{username}/
...
...
@@ -316,7 +315,7 @@ class TestPreferencesAPI(UserAPITestCase):
)
@
unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
@
skip_unless_lms
class
TestPreferencesAPITransactions
(
TransactionTestCase
):
"""
Tests the transactional behavior of the preferences API
...
...
@@ -363,7 +362,7 @@ class TestPreferencesAPITransactions(TransactionTestCase):
@ddt.ddt
@
unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
@
skip_unless_lms
class
TestPreferencesDetailAPI
(
UserAPITestCase
):
"""
Unit tests /api/user/v1/accounts/{username}/{preference_key}
...
...
openedx/core/djangoapps/user_api/tests/test_views.py
View file @
f33832a6
...
...
@@ -21,7 +21,7 @@ from social.apps.django_app.default.models import UserSocialAuth
from
django_comment_common
import
models
from
openedx.core.lib.api.test_utils
import
ApiTestCase
,
TEST_API_KEY
from
openedx.core.lib.time_zone_utils
import
get_display_time_zone
from
openedx.core.djangolib.testing.utils
import
CacheIsolationTestCase
from
openedx.core.djangolib.testing.utils
import
CacheIsolationTestCase
,
skip_unless_lms
from
student.tests.factories
import
UserFactory
from
third_party_auth.tests.testutil
import
simulate_running_pipeline
,
ThirdPartyAuthTestMixin
from
third_party_auth.tests.utils
import
(
...
...
@@ -541,7 +541,7 @@ class PreferenceUsersListViewTest(UserApiTestCase):
@ddt.ddt
@skip
Unless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
@skip
_unless_lms
class
LoginSessionViewTest
(
UserAPITestCase
):
"""Tests for the login end-points of the user API. """
...
...
@@ -713,7 +713,7 @@ class LoginSessionViewTest(UserAPITestCase):
@ddt.ddt
@skip
Unless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
@skip
_unless_lms
class
PasswordResetViewTest
(
UserAPITestCase
):
"""Tests of the user API's password reset endpoint. """
...
...
@@ -771,7 +771,7 @@ class PasswordResetViewTest(UserAPITestCase):
@ddt.ddt
@skip
Unless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
@skip
_unless_lms
class
RegistrationViewTest
(
ThirdPartyAuthTestMixin
,
UserAPITestCase
):
"""Tests for the registration end-points of the User API. """
...
...
@@ -1925,7 +1925,7 @@ class TestGoogleRegistrationView(
@ddt.ddt
@skip
Unless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
@skip
_unless_lms
class
UpdateEmailOptInTestCase
(
UserAPITestCase
,
SharedModuleStoreTestCase
):
"""Tests the UpdateEmailOptInPreference view. """
...
...
openedx/core/djangolib/testing/utils.py
View file @
f33832a6
...
...
@@ -9,6 +9,7 @@ Utility classes for testing django applications.
"""
import
copy
from
unittest
import
skipUnless
import
crum
from
django
import
db
...
...
@@ -175,3 +176,17 @@ def get_mock_request(user=None):
request
.
get_host
=
lambda
:
"edx.org"
crum
.
set_current_request
(
request
)
return
request
def
skip_unless_cms
(
func
):
"""
Only run the decorated test in the CMS test suite
"""
return
skipUnless
(
settings
.
ROOT_URLCONF
==
'cms.urls'
,
'Test only valid in CMS'
)(
func
)
def
skip_unless_lms
(
func
):
"""
Only run the decorated test in the LMS test suite
"""
return
skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in LMS'
)(
func
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment