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
fcf4efc6
Commit
fcf4efc6
authored
Jun 07, 2017
by
Robert Raposa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add unit test for jump_to for course location.
parent
c8accbc3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
40 deletions
+52
-40
lms/djangoapps/courseware/tests/test_views.py
+52
-40
No files found.
lms/djangoapps/courseware/tests/test_views.py
View file @
fcf4efc6
...
...
@@ -2,58 +2,48 @@
"""
Tests courseware views.py
"""
from
urllib
import
urlencode
,
quote
import
ddt
import
json
import
itertools
import
json
import
unittest
from
uuid
import
uuid4
from
datetime
import
datetime
,
timedelta
from
HTMLParser
import
HTMLParser
from
nose.plugins.attrib
import
attr
from
freezegun
import
freeze_time
from
django.conf
import
settings
from
django.contrib.auth.models
import
AnonymousUser
from
django.core.urlresolvers
import
reverse
from
django.http
import
Http404
,
HttpResponseBadRequest
from
django.test
import
TestCase
from
django.test.client
import
RequestFactory
from
django.test.client
import
Client
from
django.test.utils
import
override_settings
from
mock
import
MagicMock
,
patch
,
create_autospec
,
PropertyMock
from
opaque_keys.edx.locations
import
Location
,
SlashSeparatedCourseKey
from
pytz
import
UTC
from
xblock.core
import
XBlock
from
xblock.fields
import
String
,
Scope
from
xblock.fragment
import
Fragment
from
urllib
import
quote
,
urlencode
from
uuid
import
uuid4
from
capa.tests.response_xml_factory
import
MultipleChoiceResponseXMLFactory
from
courseware.model_data
import
FieldDataCache
from
courseware.module_render
import
get_module
import
courseware.views.views
as
views
import
ddt
import
shoppingcart
from
capa.tests.response_xml_factory
import
MultipleChoiceResponseXMLFactory
from
certificates
import
api
as
certs_api
from
certificates.models
import
CertificateStatuses
,
CertificateGenerationConfiguration
from
certificates.tests.factories
import
(
CertificateInvalidationFactory
,
GeneratedCertificateFactory
)
from
certificates.models
import
CertificateGenerationConfiguration
,
CertificateStatuses
from
certificates.tests.factories
import
CertificateInvalidationFactory
,
GeneratedCertificateFactory
from
commerce.models
import
CommerceConfiguration
from
course_modes.models
import
CourseMode
from
course_modes.tests.factories
import
CourseModeFactory
from
courseware.access_utils
import
is_course_open_for_learner
from
courseware.model_data
import
set_score
from
courseware.model_data
import
FieldDataCache
,
set_score
from
courseware.module_render
import
get_module
from
courseware.tests.factories
import
GlobalStaffFactory
,
StudentModuleFactory
from
courseware.testutils
import
RenderXBlockTestMixin
from
courseware.tests.factories
import
StudentModuleFactory
,
GlobalStaffFactory
from
courseware.url_helpers
import
get_redirect_url
from
courseware.user_state_client
import
DjangoXBlockUserStateClient
from
django.conf
import
settings
from
django.contrib.auth.models
import
AnonymousUser
from
django.core.urlresolvers
import
reverse
from
django.http
import
Http404
,
HttpResponseBadRequest
from
django.test
import
TestCase
from
django.test.client
import
Client
,
RequestFactory
from
django.test.utils
import
override_settings
from
freezegun
import
freeze_time
from
lms.djangoapps.commerce.utils
import
EcommerceService
# pylint: disable=import-error
from
lms.djangoapps.grades.config.waffle
import
waffle
as
grades_waffle
,
ASSUME_ZERO_GRADE_IF_ABSENT
from
lms.djangoapps.grades.config.waffle
import
waffle
as
grades_waffle
from
lms.djangoapps.grades.config.waffle
import
ASSUME_ZERO_GRADE_IF_ABSENT
from
milestones.tests.utils
import
MilestonesTestCaseMixin
from
mock
import
MagicMock
,
PropertyMock
,
create_autospec
,
patch
from
nose.plugins.attrib
import
attr
from
opaque_keys.edx.locations
import
Location
,
SlashSeparatedCourseKey
from
openedx.core.djangoapps.catalog.tests.factories
import
CourseFactory
as
CatalogCourseFactory
from
openedx.core.djangoapps.catalog.tests.factories
import
ProgramFactory
,
CourseRun
Factory
from
openedx.core.djangoapps.catalog.tests.factories
import
CourseRunFactory
,
Program
Factory
from
openedx.core.djangoapps.content.course_overviews.models
import
CourseOverview
from
openedx.core.djangoapps.crawlers.models
import
CrawlersConfig
from
openedx.core.djangoapps.credit.api
import
set_credit_requirements
...
...
@@ -62,16 +52,24 @@ from openedx.core.djangoapps.self_paced.models import SelfPacedConfiguration
from
openedx.core.djangolib.testing.utils
import
get_mock_request
from
openedx.core.lib.gating
import
api
as
gating_api
from
openedx.features.enterprise_support.tests.mixins.enterprise
import
EnterpriseTestConsentRequired
from
pytz
import
UTC
from
student.models
import
CourseEnrollment
from
student.tests.factories
import
AdminFactory
,
UserFactory
,
CourseEnrollment
Factory
from
util.tests.test_date_utils
import
fake_
ugettext
,
fake_p
gettext
from
student.tests.factories
import
AdminFactory
,
CourseEnrollmentFactory
,
User
Factory
from
util.tests.test_date_utils
import
fake_
pgettext
,
fake_u
gettext
from
util.url
import
reload_django_url_config
from
util.views
import
ensure_valid_course_key
from
waffle.testutils
import
override_flag
from
xblock.core
import
XBlock
from
xblock.fields
import
Scope
,
String
from
xblock.fragment
import
Fragment
from
xmodule.graders
import
ShowCorrectness
from
xmodule.modulestore
import
ModuleStoreEnum
from
xmodule.modulestore.django
import
modulestore
from
xmodule.modulestore.tests.django_utils
import
TEST_DATA_MIXED_MODULESTORE
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
,
SharedModuleStoreTestCase
from
xmodule.modulestore.tests.django_utils
import
(
TEST_DATA_MIXED_MODULESTORE
,
ModuleStoreTestCase
,
SharedModuleStoreTestCase
)
from
xmodule.modulestore.tests.factories
import
CourseFactory
,
ItemFactory
,
check_mongo_calls
...
...
@@ -521,9 +519,23 @@ class ViewsTestCase(ModuleStoreTestCase):
mock_user
.
is_authenticated
.
return_value
=
False
self
.
assertEqual
(
views
.
user_groups
(
mock_user
),
[])
# TODO: TNL-6546: Remove decorator for unified_course_view
@override_flag
(
'unified_course_view'
,
active
=
True
)
def
test_get_redirect_url
(
self
):
self
.
assertIn
(
'activate_block_id'
,
# test the course location
self
.
assertEqual
(
u'/courses/{course_key}/courseware?{activate_block_id}'
.
format
(
course_key
=
self
.
course_key
.
to_deprecated_string
(),
activate_block_id
=
urlencode
({
'activate_block_id'
:
self
.
course
.
location
.
to_deprecated_string
()})
),
get_redirect_url
(
self
.
course_key
,
self
.
course
.
location
),
)
# test a section location
self
.
assertEqual
(
u'/courses/{course_key}/courseware/Chapter_1/Sequential_1/?{activate_block_id}'
.
format
(
course_key
=
self
.
course_key
.
to_deprecated_string
(),
activate_block_id
=
urlencode
({
'activate_block_id'
:
self
.
section
.
location
.
to_deprecated_string
()})
),
get_redirect_url
(
self
.
course_key
,
self
.
section
.
location
),
)
...
...
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