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
ad84b8d4
Commit
ad84b8d4
authored
Apr 03, 2017
by
Robert Raposa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor more tests to use course home page.
parent
e2c81835
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
58 additions
and
27 deletions
+58
-27
common/test/acceptance/pages/lms/course_home.py
+33
-8
common/test/acceptance/pages/lms/courseware.py
+1
-1
common/test/acceptance/tests/lms/test_library.py
+4
-1
common/test/acceptance/tests/lms/test_lms_courseware.py
+2
-3
common/test/acceptance/tests/studio/test_studio_outline.py
+18
-14
No files found.
common/test/acceptance/pages/lms/course_home.py
View file @
ad84b8d4
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
LMS Course Home page object
LMS Course Home page object
"""
"""
from
collections
import
OrderedDict
from
bok_choy.page_object
import
PageObject
from
bok_choy.page_object
import
PageObject
from
.bookmarks
import
BookmarksPage
from
.bookmarks
import
BookmarksPage
...
@@ -81,7 +82,7 @@ class CourseOutlinePage(PageObject):
...
@@ -81,7 +82,7 @@ class CourseOutlinePage(PageObject):
You can use these titles in `go_to_section` to navigate to the section.
You can use these titles in `go_to_section` to navigate to the section.
"""
"""
# Dict to store the result
# Dict to store the result
outline_dict
=
d
ict
()
outline_dict
=
OrderedD
ict
()
section_titles
=
self
.
_section_titles
()
section_titles
=
self
.
_section_titles
()
...
@@ -89,7 +90,7 @@ class CourseOutlinePage(PageObject):
...
@@ -89,7 +90,7 @@ class CourseOutlinePage(PageObject):
for
sec_index
,
sec_title
in
enumerate
(
section_titles
):
for
sec_index
,
sec_title
in
enumerate
(
section_titles
):
if
len
(
section_titles
)
<
1
:
if
len
(
section_titles
)
<
1
:
self
.
warning
(
"Could not find subsections for '{0}'"
.
format
(
sec_title
))
raise
ValueError
(
"Could not find subsections for '{0}'"
.
format
(
sec_title
))
else
:
else
:
# Add one to convert list index (starts at 0) to CSS index (starts at 1)
# Add one to convert list index (starts at 0) to CSS index (starts at 1)
outline_dict
[
sec_title
]
=
self
.
_subsection_titles
(
sec_index
+
1
)
outline_dict
[
sec_title
]
=
self
.
_subsection_titles
(
sec_index
+
1
)
...
@@ -123,7 +124,7 @@ class CourseOutlinePage(PageObject):
...
@@ -123,7 +124,7 @@ class CourseOutlinePage(PageObject):
def
go_to_section
(
self
,
section_title
,
subsection_title
):
def
go_to_section
(
self
,
section_title
,
subsection_title
):
"""
"""
Go to the section in the courseware.
Go to the section
/subsection
in the courseware.
Every section must have at least one subsection, so specify
Every section must have at least one subsection, so specify
both the section and subsection title.
both the section and subsection title.
...
@@ -132,14 +133,14 @@ class CourseOutlinePage(PageObject):
...
@@ -132,14 +133,14 @@ class CourseOutlinePage(PageObject):
"""
"""
section_index
=
self
.
_section_title_to_index
(
section_title
)
section_index
=
self
.
_section_title_to_index
(
section_title
)
if
section_index
is
None
:
if
section_index
is
None
:
r
eturn
r
aise
ValueError
(
"Could not find section '{0}'"
.
format
(
section_title
))
try
:
try
:
subsection_index
=
self
.
_subsection_titles
(
section_index
+
1
)
.
index
(
subsection_title
)
subsection_index
=
self
.
_subsection_titles
(
section_index
+
1
)
.
index
(
subsection_title
)
except
ValueError
:
except
ValueError
:
msg
=
"Could not find subsection '{0}' in section '{1}'"
.
format
(
subsection_title
,
section_title
)
raise
ValueError
(
"Could not find subsection '{0}' in section '{1}'"
.
format
(
self
.
warning
(
msg
)
subsection_title
,
section_title
return
))
# Convert list indices (start at zero) to CSS indices (start at 1)
# Convert list indices (start at zero) to CSS indices (start at 1)
subsection_css
=
self
.
SUBSECTION_SELECTOR
.
format
(
section_index
+
1
,
subsection_index
+
1
)
subsection_css
=
self
.
SUBSECTION_SELECTOR
.
format
(
section_index
+
1
,
subsection_index
+
1
)
...
@@ -149,6 +150,30 @@ class CourseOutlinePage(PageObject):
...
@@ -149,6 +150,30 @@ class CourseOutlinePage(PageObject):
self
.
_wait_for_course_section
(
section_title
,
subsection_title
)
self
.
_wait_for_course_section
(
section_title
,
subsection_title
)
def
go_to_section_by_index
(
self
,
section_index
,
subsection_index
):
"""
Go to the section/subsection in the courseware.
Every section must have at least one subsection, so specify both the
section and subsection indices.
Arguments:
section_index: A 0-based index of the section to navigate to.
subsection_index: A 0-based index of the subsection to navigate to.
"""
try
:
section_title
=
self
.
_section_titles
()[
section_index
]
except
IndexError
:
raise
ValueError
(
"Section index '{0}' is out of range."
.
format
(
section_index
))
try
:
subsection_title
=
self
.
_subsection_titles
(
section_index
+
1
)[
subsection_index
]
except
IndexError
:
raise
ValueError
(
"Subsection index '{0}' in section index '{1}' is out of range."
.
format
(
subsection_index
,
section_index
))
self
.
go_to_section
(
section_title
,
subsection_title
)
def
_section_title_to_index
(
self
,
section_title
):
def
_section_title_to_index
(
self
,
section_title
):
"""
"""
Get the section title index given the section title.
Get the section title index given the section title.
...
@@ -156,7 +181,7 @@ class CourseOutlinePage(PageObject):
...
@@ -156,7 +181,7 @@ class CourseOutlinePage(PageObject):
try
:
try
:
section_index
=
self
.
_section_titles
()
.
index
(
section_title
)
section_index
=
self
.
_section_titles
()
.
index
(
section_title
)
except
ValueError
:
except
ValueError
:
self
.
warning
(
"Could not find section '{0}'"
.
format
(
section_title
))
raise
ValueError
(
"Could not find section '{0}'"
.
format
(
section_title
))
return
section_index
return
section_index
...
...
common/test/acceptance/pages/lms/courseware.py
View file @
ad84b8d4
...
@@ -580,7 +580,7 @@ class CourseNavPage(PageObject):
...
@@ -580,7 +580,7 @@ class CourseNavPage(PageObject):
"""
"""
return
self
.
REMOVE_SPAN_TAG_RE
.
search
(
element
.
get_attribute
(
'innerHTML'
))
.
groups
()[
0
]
.
strip
()
return
self
.
REMOVE_SPAN_TAG_RE
.
search
(
element
.
get_attribute
(
'innerHTML'
))
.
groups
()[
0
]
.
strip
()
# TODO: TNL-6546: Remove
from here and move to course_home.py:CourseOutlinePage
# TODO: TNL-6546: Remove
. This is no longer needed.
@property
@property
def
active_subsection_url
(
self
):
def
active_subsection_url
(
self
):
"""
"""
...
...
common/test/acceptance/tests/lms/test_library.py
View file @
ad84b8d4
...
@@ -10,6 +10,7 @@ from common.test.acceptance.tests.helpers import UniqueCourseTest, TestWithSearc
...
@@ -10,6 +10,7 @@ from common.test.acceptance.tests.helpers import UniqueCourseTest, TestWithSearc
from
common.test.acceptance.pages.studio.auto_auth
import
AutoAuthPage
from
common.test.acceptance.pages.studio.auto_auth
import
AutoAuthPage
from
common.test.acceptance.pages.studio.overview
import
CourseOutlinePage
as
StudioCourseOutlinePage
from
common.test.acceptance.pages.studio.overview
import
CourseOutlinePage
as
StudioCourseOutlinePage
from
common.test.acceptance.pages.studio.library
import
StudioLibraryContentEditor
,
StudioLibraryContainerXBlockWrapper
from
common.test.acceptance.pages.studio.library
import
StudioLibraryContentEditor
,
StudioLibraryContainerXBlockWrapper
from
common.test.acceptance.pages.lms.course_home
import
CourseHomePage
from
common.test.acceptance.pages.lms.courseware
import
CoursewarePage
from
common.test.acceptance.pages.lms.courseware
import
CoursewarePage
from
common.test.acceptance.pages.lms.library
import
LibraryContentXBlockWrapper
from
common.test.acceptance.pages.lms.library
import
LibraryContentXBlockWrapper
from
common.test.acceptance.pages.common.logout
import
LogoutPage
from
common.test.acceptance.pages.common.logout
import
LogoutPage
...
@@ -128,7 +129,9 @@ class LibraryContentTestBase(UniqueCourseTest):
...
@@ -128,7 +129,9 @@ class LibraryContentTestBase(UniqueCourseTest):
self
.
courseware_page
.
visit
()
self
.
courseware_page
.
visit
()
paragraphs
=
self
.
courseware_page
.
q
(
css
=
'.course-content p'
)
.
results
paragraphs
=
self
.
courseware_page
.
q
(
css
=
'.course-content p'
)
.
results
if
not
paragraphs
:
if
not
paragraphs
:
self
.
courseware_page
.
q
(
css
=
'.menu-item a'
)
.
results
[
0
]
.
click
()
course_home_page
=
CourseHomePage
(
self
.
browser
,
self
.
course_id
)
course_home_page
.
visit
()
course_home_page
.
outline
.
go_to_section_by_index
(
0
,
0
)
block_id
=
block_id
if
block_id
is
not
None
else
self
.
lib_block
.
locator
block_id
=
block_id
if
block_id
is
not
None
else
self
.
lib_block
.
locator
#pylint: disable=attribute-defined-outside-init
#pylint: disable=attribute-defined-outside-init
self
.
library_content_page
=
LibraryContentXBlockWrapper
(
self
.
browser
,
block_id
)
self
.
library_content_page
=
LibraryContentXBlockWrapper
(
self
.
browser
,
block_id
)
...
...
common/test/acceptance/tests/lms/test_lms_courseware.py
View file @
ad84b8d4
...
@@ -624,11 +624,10 @@ class CoursewareMultipleVerticalsTest(CoursewareMultipleVerticalsTestBase):
...
@@ -624,11 +624,10 @@ class CoursewareMultipleVerticalsTest(CoursewareMultipleVerticalsTestBase):
self
.
course_home_page
.
visit
()
self
.
course_home_page
.
visit
()
self
.
course_home_page
.
outline
.
go_to_section
(
'Test Section 1'
,
'Test Subsection 1,1'
)
self
.
course_home_page
.
outline
.
go_to_section
(
'Test Section 1'
,
'Test Subsection 1,1'
)
subsection_url
=
self
.
courseware_page
.
nav
.
active_subsection
_url
subsection_url
=
self
.
browser
.
current
_url
url_part_list
=
subsection_url
.
split
(
'/'
)
url_part_list
=
subsection_url
.
split
(
'/'
)
self
.
assertEqual
(
len
(
url_part_list
),
9
)
course_id
=
url_part_list
[
4
]
course_id
=
url_part_list
[
-
5
]
chapter_id
=
url_part_list
[
-
3
]
chapter_id
=
url_part_list
[
-
3
]
subsection_id
=
url_part_list
[
-
2
]
subsection_id
=
url_part_list
[
-
2
]
problem1_page
=
CoursewareSequentialTabPage
(
problem1_page
=
CoursewareSequentialTabPage
(
...
...
common/test/acceptance/tests/studio/test_studio_outline.py
View file @
ad84b8d4
...
@@ -730,19 +730,21 @@ class StaffLockTest(CourseOutlineTest):
...
@@ -730,19 +730,21 @@ class StaffLockTest(CourseOutlineTest):
Given I have a course with two sections
Given I have a course with two sections
When I enable explicit staff lock on one section
When I enable explicit staff lock on one section
And I click the View Live button to switch to staff view
And I click the View Live button to switch to staff view
Then I see two sections in the sidebar
And I visit the course home with the outline
Then I see two sections in the outline
And when I switch the view mode to student view
And when I switch the view mode to student view
Then I see one section in the
sidebar
Then I see one section in the
outline
"""
"""
self
.
course_outline_page
.
visit
()
self
.
course_outline_page
.
visit
()
self
.
course_outline_page
.
add_section_from_top_button
()
self
.
course_outline_page
.
add_section_from_top_button
()
self
.
course_outline_page
.
section_at
(
1
)
.
set_staff_lock
(
True
)
self
.
course_outline_page
.
section_at
(
1
)
.
set_staff_lock
(
True
)
self
.
course_outline_page
.
view_live
()
self
.
course_outline_page
.
view_live
()
courseware
=
CoursewarePage
(
self
.
browser
,
self
.
course_id
)
courseware
.
wait_for_page
()
course_home_page
=
CourseHomePage
(
self
.
browser
,
self
.
course_id
)
self
.
assertEqual
(
courseware
.
num_sections
,
2
)
course_home_page
.
visit
()
StaffCoursewarePage
(
self
.
browser
,
self
.
course_id
)
.
set_staff_view_mode
(
'Student'
)
self
.
assertEqual
(
course_home_page
.
outline
.
num_sections
,
2
)
self
.
assertEqual
(
courseware
.
num_sections
,
1
)
course_home_page
.
preview
.
set_staff_view_mode
(
'Student'
)
self
.
assertEqual
(
course_home_page
.
outline
.
num_sections
,
1
)
def
test_locked_subsections_do_not_appear_in_lms
(
self
):
def
test_locked_subsections_do_not_appear_in_lms
(
self
):
"""
"""
...
@@ -750,18 +752,20 @@ class StaffLockTest(CourseOutlineTest):
...
@@ -750,18 +752,20 @@ class StaffLockTest(CourseOutlineTest):
Given I have a course with two subsections
Given I have a course with two subsections
When I enable explicit staff lock on one subsection
When I enable explicit staff lock on one subsection
And I click the View Live button to switch to staff view
And I click the View Live button to switch to staff view
Then I see two subsections in the sidebar
And I visit the course home with the outline
Then I see two subsections in the outline
And when I switch the view mode to student view
And when I switch the view mode to student view
Then I see one s
ection in the sidebar
Then I see one s
ubsection in the outline
"""
"""
self
.
course_outline_page
.
visit
()
self
.
course_outline_page
.
visit
()
self
.
course_outline_page
.
section_at
(
0
)
.
subsection_at
(
1
)
.
set_staff_lock
(
True
)
self
.
course_outline_page
.
section_at
(
0
)
.
subsection_at
(
1
)
.
set_staff_lock
(
True
)
self
.
course_outline_page
.
view_live
()
self
.
course_outline_page
.
view_live
()
courseware
=
CoursewarePage
(
self
.
browser
,
self
.
course_id
)
courseware
.
wait_for_page
()
course_home_page
=
CourseHomePage
(
self
.
browser
,
self
.
course_id
)
self
.
assertEqual
(
courseware
.
num_subsections
,
2
)
course_home_page
.
visit
()
StaffCoursewarePage
(
self
.
browser
,
self
.
course_id
)
.
set_staff_view_mode
(
'Student'
)
self
.
assertEqual
(
course_home_page
.
outline
.
num_subsections
,
2
)
self
.
assertEqual
(
courseware
.
num_subsections
,
1
)
course_home_page
.
preview
.
set_staff_view_mode
(
'Student'
)
self
.
assertEqual
(
course_home_page
.
outline
.
num_subsections
,
1
)
def
test_toggling_staff_lock_on_section_does_not_publish_draft_units
(
self
):
def
test_toggling_staff_lock_on_section_does_not_publish_draft_units
(
self
):
"""
"""
...
...
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