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
aba53517
Commit
aba53517
authored
Dec 18, 2017
by
Jeremy Bowman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PLAT-1859 Fix LMS shard 1 tests under Django 1.9
parent
b26fe5fd
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
22 deletions
+14
-22
lms/djangoapps/certificates/tests/test_models.py
+4
-8
lms/djangoapps/course_wiki/tests/tests.py
+4
-5
lms/djangoapps/courseware/tests/test_views.py
+5
-8
lms/djangoapps/instructor/tests/test_api.py
+1
-1
No files found.
lms/djangoapps/certificates/tests/test_models.py
View file @
aba53517
...
@@ -2,13 +2,11 @@
...
@@ -2,13 +2,11 @@
import
json
import
json
import
ddt
import
ddt
import
pytest
from
django.conf
import
settings
from
django.conf
import
settings
from
django.core.exceptions
import
ValidationError
from
django.core.exceptions
import
ValidationError
from
django.core.files.uploadedfile
import
SimpleUploadedFile
from
django.core.files.uploadedfile
import
SimpleUploadedFile
from
django.test
import
TestCase
from
django.test
import
TestCase
from
django.test.utils
import
override_settings
from
django.test.utils
import
override_settings
from
mock
import
Mock
from
nose.plugins.attrib
import
attr
from
nose.plugins.attrib
import
attr
from
opaque_keys.edx.locator
import
CourseLocator
from
opaque_keys.edx.locator
import
CourseLocator
from
path
import
Path
as
path
from
path
import
Path
as
path
...
@@ -264,14 +262,13 @@ class TestCertificateGenerationHistory(TestCase):
...
@@ -264,14 +262,13 @@ class TestCertificateGenerationHistory(TestCase):
({
"statuses_to_regenerate"
:
[
'downloadable'
,
'not_readable'
]},
'already received'
,
False
),
({
"statuses_to_regenerate"
:
[
'downloadable'
,
'not_readable'
]},
'already received'
,
False
),
)
)
@ddt.unpack
@ddt.unpack
@pytest.mark.django111_expected_failure
def
test_get_certificate_generation_candidates
(
self
,
task_input
,
expected
,
is_regeneration
):
def
test_get_certificate_generation_candidates
(
self
,
task_input
,
expected
,
is_regeneration
):
staff
=
AdminFactory
.
create
()
staff
=
AdminFactory
.
create
()
instructor_task
=
InstructorTaskFactory
.
create
(
instructor_task
=
InstructorTaskFactory
.
create
(
task_input
=
json
.
dumps
(
task_input
),
task_input
=
json
.
dumps
(
task_input
),
requester
=
staff
,
requester
=
staff
,
task_key
=
Mock
()
,
task_key
=
''
,
task_id
=
Mock
()
,
task_id
=
''
,
)
)
certificate_generation_history
=
CertificateGenerationHistory
(
certificate_generation_history
=
CertificateGenerationHistory
(
course_id
=
instructor_task
.
course_id
,
course_id
=
instructor_task
.
course_id
,
...
@@ -286,14 +283,13 @@ class TestCertificateGenerationHistory(TestCase):
...
@@ -286,14 +283,13 @@ class TestCertificateGenerationHistory(TestCase):
@ddt.data
((
True
,
"regenerated"
),
(
False
,
"generated"
))
@ddt.data
((
True
,
"regenerated"
),
(
False
,
"generated"
))
@ddt.unpack
@ddt.unpack
@pytest.mark.django111_expected_failure
def
test_get_task_name
(
self
,
is_regeneration
,
expected
):
def
test_get_task_name
(
self
,
is_regeneration
,
expected
):
staff
=
AdminFactory
.
create
()
staff
=
AdminFactory
.
create
()
instructor_task
=
InstructorTaskFactory
.
create
(
instructor_task
=
InstructorTaskFactory
.
create
(
task_input
=
json
.
dumps
({}),
task_input
=
json
.
dumps
({}),
requester
=
staff
,
requester
=
staff
,
task_key
=
Mock
()
,
task_key
=
''
,
task_id
=
Mock
()
,
task_id
=
''
,
)
)
certificate_generation_history
=
CertificateGenerationHistory
(
certificate_generation_history
=
CertificateGenerationHistory
(
course_id
=
instructor_task
.
course_id
,
course_id
=
instructor_task
.
course_id
,
...
...
lms/djangoapps/course_wiki/tests/tests.py
View file @
aba53517
...
@@ -2,19 +2,18 @@
...
@@ -2,19 +2,18 @@
Tests for course wiki
Tests for course wiki
"""
"""
import
pytest
from
django.core.urlresolvers
import
reverse
from
django.core.urlresolvers
import
reverse
from
mock
import
patch
from
mock
import
patch
from
nose.plugins.attrib
import
attr
from
nose.plugins.attrib
import
attr
from
courseware.tests.tests
import
LoginEnrollmentTestCase
from
courseware.tests.tests
import
LoginEnrollmentTestCase
from
openedx.features.enterprise_support.tests.mixins.enterprise
import
EnterpriseTestConsentRequired
from
openedx.features.enterprise_support.tests.mixins.enterprise
import
EnterpriseTestConsentRequired
from
openedx.tests.util
import
expected_redirect_url
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
@attr
(
shard
=
1
)
@attr
(
shard
=
1
)
@pytest.mark.django111_expected_failure
class
WikiRedirectTestCase
(
EnterpriseTestConsentRequired
,
LoginEnrollmentTestCase
,
ModuleStoreTestCase
):
class
WikiRedirectTestCase
(
EnterpriseTestConsentRequired
,
LoginEnrollmentTestCase
,
ModuleStoreTestCase
):
"""
"""
Tests for wiki course redirection.
Tests for wiki course redirection.
...
@@ -58,7 +57,7 @@ class WikiRedirectTestCase(EnterpriseTestConsentRequired, LoginEnrollmentTestCas
...
@@ -58,7 +57,7 @@ class WikiRedirectTestCase(EnterpriseTestConsentRequired, LoginEnrollmentTestCas
resp
=
self
.
client
.
get
(
destination
,
HTTP_REFERER
=
referer
)
resp
=
self
.
client
.
get
(
destination
,
HTTP_REFERER
=
referer
)
self
.
assertEqual
(
resp
.
status_code
,
302
)
self
.
assertEqual
(
resp
.
status_code
,
302
)
self
.
assertEqual
(
resp
[
'Location'
],
'http://testserver'
+
redirected_to
)
self
.
assertEqual
(
resp
[
'Location'
],
expected_redirect_url
(
redirected_to
)
)
# Now we test that the student will be redirected away from that page if the course doesn't exist
# Now we test that the student will be redirected away from that page if the course doesn't exist
# We do this in the same test because we want to make sure the redirected_to is constructed correctly
# We do this in the same test because we want to make sure the redirected_to is constructed correctly
...
@@ -67,7 +66,7 @@ class WikiRedirectTestCase(EnterpriseTestConsentRequired, LoginEnrollmentTestCas
...
@@ -67,7 +66,7 @@ class WikiRedirectTestCase(EnterpriseTestConsentRequired, LoginEnrollmentTestCas
resp
=
self
.
client
.
get
(
bad_course_wiki_page
,
HTTP_REFERER
=
referer
)
resp
=
self
.
client
.
get
(
bad_course_wiki_page
,
HTTP_REFERER
=
referer
)
self
.
assertEqual
(
resp
.
status_code
,
302
)
self
.
assertEqual
(
resp
.
status_code
,
302
)
self
.
assertEqual
(
resp
[
'Location'
],
'http://testserver'
+
destination
)
self
.
assertEqual
(
resp
[
'Location'
],
expected_redirect_url
(
destination
)
)
@patch.dict
(
"django.conf.settings.FEATURES"
,
{
'ALLOW_WIKI_ROOT_ACCESS'
:
False
})
@patch.dict
(
"django.conf.settings.FEATURES"
,
{
'ALLOW_WIKI_ROOT_ACCESS'
:
False
})
def
test_wiki_no_root_access
(
self
):
def
test_wiki_no_root_access
(
self
):
...
@@ -100,7 +99,7 @@ class WikiRedirectTestCase(EnterpriseTestConsentRequired, LoginEnrollmentTestCas
...
@@ -100,7 +99,7 @@ class WikiRedirectTestCase(EnterpriseTestConsentRequired, LoginEnrollmentTestCas
ending_location
=
resp
.
redirect_chain
[
-
1
][
0
]
ending_location
=
resp
.
redirect_chain
[
-
1
][
0
]
self
.
assertEquals
(
ending_location
,
'http://testserver'
+
course_wiki_page
)
self
.
assertEquals
(
ending_location
,
expected_redirect_url
(
course_wiki_page
)
)
self
.
assertEquals
(
resp
.
status_code
,
200
)
self
.
assertEquals
(
resp
.
status_code
,
200
)
self
.
has_course_navigator
(
resp
)
self
.
has_course_navigator
(
resp
)
...
...
lms/djangoapps/courseware/tests/test_views.py
View file @
aba53517
...
@@ -11,7 +11,6 @@ from urllib import quote, urlencode
...
@@ -11,7 +11,6 @@ from urllib import quote, urlencode
from
uuid
import
uuid4
from
uuid
import
uuid4
import
ddt
import
ddt
import
pytest
from
django.conf
import
settings
from
django.conf
import
settings
from
django.contrib.auth.models
import
AnonymousUser
from
django.contrib.auth.models
import
AnonymousUser
from
django.core.urlresolvers
import
reverse
,
reverse_lazy
from
django.core.urlresolvers
import
reverse
,
reverse_lazy
...
@@ -62,6 +61,7 @@ from openedx.core.djangolib.testing.utils import get_mock_request
...
@@ -62,6 +61,7 @@ from openedx.core.djangolib.testing.utils import get_mock_request
from
openedx.core.lib.gating
import
api
as
gating_api
from
openedx.core.lib.gating
import
api
as
gating_api
from
openedx.features.course_experience
import
COURSE_OUTLINE_PAGE_FLAG
from
openedx.features.course_experience
import
COURSE_OUTLINE_PAGE_FLAG
from
openedx.features.enterprise_support.tests.mixins.enterprise
import
EnterpriseTestConsentRequired
from
openedx.features.enterprise_support.tests.mixins.enterprise
import
EnterpriseTestConsentRequired
from
openedx.tests.util
import
expected_redirect_url
from
student.models
import
CourseEnrollment
from
student.models
import
CourseEnrollment
from
student.tests.factories
import
TEST_PASSWORD
,
AdminFactory
,
CourseEnrollmentFactory
,
UserFactory
from
student.tests.factories
import
TEST_PASSWORD
,
AdminFactory
,
CourseEnrollmentFactory
,
UserFactory
from
util.tests.test_date_utils
import
fake_pgettext
,
fake_ugettext
from
util.tests.test_date_utils
import
fake_pgettext
,
fake_ugettext
...
@@ -115,7 +115,6 @@ class TestJumpTo(ModuleStoreTestCase):
...
@@ -115,7 +115,6 @@ class TestJumpTo(ModuleStoreTestCase):
response
=
self
.
client
.
get
(
jumpto_url
)
response
=
self
.
client
.
get
(
jumpto_url
)
self
.
assertRedirects
(
response
,
expected
,
status_code
=
302
,
target_status_code
=
302
)
self
.
assertRedirects
(
response
,
expected
,
status_code
=
302
,
target_status_code
=
302
)
@pytest.mark.django111_expected_failure
def
test_jumpto_from_section
(
self
):
def
test_jumpto_from_section
(
self
):
course
=
CourseFactory
.
create
()
course
=
CourseFactory
.
create
()
chapter
=
ItemFactory
.
create
(
category
=
'chapter'
,
parent_location
=
course
.
location
)
chapter
=
ItemFactory
.
create
(
category
=
'chapter'
,
parent_location
=
course
.
location
)
...
@@ -132,9 +131,8 @@ class TestJumpTo(ModuleStoreTestCase):
...
@@ -132,9 +131,8 @@ class TestJumpTo(ModuleStoreTestCase):
unicode
(
section
.
location
),
unicode
(
section
.
location
),
)
)
response
=
self
.
client
.
get
(
jumpto_url
)
response
=
self
.
client
.
get
(
jumpto_url
)
self
.
assertRedirects
(
response
,
expected
,
status_code
=
302
,
target_status_code
=
302
)
self
.
assertRedirects
(
response
,
expected
_redirect_url
(
expected
)
,
status_code
=
302
,
target_status_code
=
302
)
@pytest.mark.django111_expected_failure
def
test_jumpto_from_module
(
self
):
def
test_jumpto_from_module
(
self
):
course
=
CourseFactory
.
create
()
course
=
CourseFactory
.
create
()
chapter
=
ItemFactory
.
create
(
category
=
'chapter'
,
parent_location
=
course
.
location
)
chapter
=
ItemFactory
.
create
(
category
=
'chapter'
,
parent_location
=
course
.
location
)
...
@@ -156,7 +154,7 @@ class TestJumpTo(ModuleStoreTestCase):
...
@@ -156,7 +154,7 @@ class TestJumpTo(ModuleStoreTestCase):
unicode
(
module1
.
location
),
unicode
(
module1
.
location
),
)
)
response
=
self
.
client
.
get
(
jumpto_url
)
response
=
self
.
client
.
get
(
jumpto_url
)
self
.
assertRedirects
(
response
,
expected
,
status_code
=
302
,
target_status_code
=
302
)
self
.
assertRedirects
(
response
,
expected
_redirect_url
(
expected
)
,
status_code
=
302
,
target_status_code
=
302
)
expected
=
'courses/{course_id}/courseware/{chapter_id}/{section_id}/2?{activate_block_id}'
.
format
(
expected
=
'courses/{course_id}/courseware/{chapter_id}/{section_id}/2?{activate_block_id}'
.
format
(
course_id
=
unicode
(
course
.
id
),
course_id
=
unicode
(
course
.
id
),
...
@@ -170,9 +168,8 @@ class TestJumpTo(ModuleStoreTestCase):
...
@@ -170,9 +168,8 @@ class TestJumpTo(ModuleStoreTestCase):
unicode
(
module2
.
location
),
unicode
(
module2
.
location
),
)
)
response
=
self
.
client
.
get
(
jumpto_url
)
response
=
self
.
client
.
get
(
jumpto_url
)
self
.
assertRedirects
(
response
,
expected
,
status_code
=
302
,
target_status_code
=
302
)
self
.
assertRedirects
(
response
,
expected
_redirect_url
(
expected
)
,
status_code
=
302
,
target_status_code
=
302
)
@pytest.mark.django111_expected_failure
def
test_jumpto_from_nested_module
(
self
):
def
test_jumpto_from_nested_module
(
self
):
course
=
CourseFactory
.
create
()
course
=
CourseFactory
.
create
()
chapter
=
ItemFactory
.
create
(
category
=
'chapter'
,
parent_location
=
course
.
location
)
chapter
=
ItemFactory
.
create
(
category
=
'chapter'
,
parent_location
=
course
.
location
)
...
@@ -199,7 +196,7 @@ class TestJumpTo(ModuleStoreTestCase):
...
@@ -199,7 +196,7 @@ class TestJumpTo(ModuleStoreTestCase):
unicode
(
module2
.
location
),
unicode
(
module2
.
location
),
)
)
response
=
self
.
client
.
get
(
jumpto_url
)
response
=
self
.
client
.
get
(
jumpto_url
)
self
.
assertRedirects
(
response
,
expected
,
status_code
=
302
,
target_status_code
=
302
)
self
.
assertRedirects
(
response
,
expected
_redirect_url
(
expected
)
,
status_code
=
302
,
target_status_code
=
302
)
def
test_jumpto_id_invalid_location
(
self
):
def
test_jumpto_id_invalid_location
(
self
):
location
=
Location
(
'edX'
,
'toy'
,
'NoSuchPlace'
,
None
,
None
,
None
)
location
=
Location
(
'edX'
,
'toy'
,
'NoSuchPlace'
,
None
,
None
,
None
)
...
...
lms/djangoapps/instructor/tests/test_api.py
View file @
aba53517
...
@@ -2678,7 +2678,7 @@ class TestInstructorAPILevelsDataDump(SharedModuleStoreTestCase, LoginEnrollment
...
@@ -2678,7 +2678,7 @@ class TestInstructorAPILevelsDataDump(SharedModuleStoreTestCase, LoginEnrollment
problem key that the get_problem_responses endpoint can
problem key that the get_problem_responses endpoint can
work with.
work with.
"""
"""
mock_problem_key
=
Mock
(
return_value
=
u''
)
mock_problem_key
=
NonCallable
Mock
(
return_value
=
u''
)
mock_problem_key
.
course_key
=
self
.
course
.
id
mock_problem_key
.
course_key
=
self
.
course
.
id
with
patch
.
object
(
UsageKey
,
'from_string'
)
as
patched_method
:
with
patch
.
object
(
UsageKey
,
'from_string'
)
as
patched_method
:
patched_method
.
return_value
=
mock_problem_key
patched_method
.
return_value
=
mock_problem_key
...
...
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