Merge pull request #4548 from edx/benmcmorran/refactor-studio-tests
Refactor studio tests to use StudioCourseTest
This commit is contained in:
47
common/test/acceptance/tests/base_studio_test.py
Normal file
47
common/test/acceptance/tests/base_studio_test.py
Normal file
@@ -0,0 +1,47 @@
|
||||
from ..pages.studio.auto_auth import AutoAuthPage
|
||||
from ..fixtures.course import CourseFixture
|
||||
from acceptance.tests.helpers import UniqueCourseTest
|
||||
|
||||
|
||||
class StudioCourseTest(UniqueCourseTest):
|
||||
"""
|
||||
Base class for all Studio course tests.
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
"""
|
||||
Install a course with no content using a fixture.
|
||||
"""
|
||||
super(StudioCourseTest, self).setUp()
|
||||
|
||||
self.course_fixture = CourseFixture(
|
||||
self.course_info['org'],
|
||||
self.course_info['number'],
|
||||
self.course_info['run'],
|
||||
self.course_info['display_name']
|
||||
)
|
||||
self.populate_course_fixture(self.course_fixture)
|
||||
self.course_fixture.install()
|
||||
self.user = self.course_fixture.user
|
||||
self.log_in(self.user)
|
||||
|
||||
def populate_course_fixture(self, course_fixture):
|
||||
"""
|
||||
Populate the children of the test course fixture.
|
||||
"""
|
||||
pass
|
||||
|
||||
def log_in(self, user, is_staff=False):
|
||||
"""
|
||||
Log in as the user that created the course. The user will be given instructor access
|
||||
to the course and enrolled in it. By default the user will not have staff access unless
|
||||
is_staff is passed as True.
|
||||
"""
|
||||
self.auth_page = AutoAuthPage(
|
||||
self.browser,
|
||||
staff=is_staff,
|
||||
username=user.get('username'),
|
||||
email=user.get('email'),
|
||||
password=user.get('password')
|
||||
)
|
||||
self.auth_page.visit()
|
||||
@@ -2,18 +2,18 @@
|
||||
Acceptance tests for Studio related to the container page.
|
||||
"""
|
||||
|
||||
from ..pages.studio.auto_auth import AutoAuthPage
|
||||
from ..pages.studio.overview import CourseOutlinePage
|
||||
from ..fixtures.course import CourseFixture, XBlockFixtureDesc
|
||||
from ..fixtures.course import XBlockFixtureDesc
|
||||
|
||||
from .helpers import UniqueCourseTest
|
||||
from ..pages.studio.component_editor import ComponentEditorView
|
||||
from ..pages.studio.utils import add_discussion
|
||||
|
||||
from unittest import skip
|
||||
|
||||
from acceptance.tests.base_studio_test import StudioCourseTest
|
||||
|
||||
class ContainerBase(UniqueCourseTest):
|
||||
|
||||
class ContainerBase(StudioCourseTest):
|
||||
"""
|
||||
Base class for tests that do operations on the container page.
|
||||
"""
|
||||
@@ -33,21 +33,6 @@ class ContainerBase(UniqueCourseTest):
|
||||
self.course_info['run']
|
||||
)
|
||||
|
||||
self.setup_fixtures()
|
||||
|
||||
self.auth_page = AutoAuthPage(
|
||||
self.browser,
|
||||
staff=False,
|
||||
username=self.user.get('username'),
|
||||
email=self.user.get('email'),
|
||||
password=self.user.get('password')
|
||||
)
|
||||
|
||||
self.auth_page.visit()
|
||||
|
||||
def setup_fixtures(self):
|
||||
pass
|
||||
|
||||
def go_to_container_page(self, make_draft=False):
|
||||
"""
|
||||
Go to the test container page.
|
||||
@@ -110,10 +95,10 @@ class ContainerBase(UniqueCourseTest):
|
||||
class NestedVerticalTest(ContainerBase):
|
||||
__test__ = False
|
||||
|
||||
"""
|
||||
Sets up a course structure with nested verticals.
|
||||
"""
|
||||
def setup_fixtures(self):
|
||||
def populate_course_fixture(self, course_fixture):
|
||||
"""
|
||||
Sets up a course structure with nested verticals.
|
||||
"""
|
||||
self.container_title = ""
|
||||
self.group_a = "Expand or Collapse\nGroup A"
|
||||
self.group_b = "Expand or Collapse\nGroup B"
|
||||
@@ -137,14 +122,7 @@ class NestedVerticalTest(ContainerBase):
|
||||
self.duplicate_label = "Duplicate of '{0}'"
|
||||
self.discussion_label = "Discussion"
|
||||
|
||||
course_fix = CourseFixture(
|
||||
self.course_info['org'],
|
||||
self.course_info['number'],
|
||||
self.course_info['run'],
|
||||
self.course_info['display_name']
|
||||
)
|
||||
|
||||
course_fix.add_children(
|
||||
course_fixture.add_children(
|
||||
XBlockFixtureDesc('chapter', 'Test Section').add_children(
|
||||
XBlockFixtureDesc('sequential', 'Test Subsection').add_children(
|
||||
XBlockFixtureDesc('vertical', 'Test Unit').add_children(
|
||||
@@ -162,9 +140,7 @@ class NestedVerticalTest(ContainerBase):
|
||||
)
|
||||
)
|
||||
)
|
||||
).install()
|
||||
|
||||
self.user = course_fix.user
|
||||
)
|
||||
|
||||
|
||||
class DragAndDropTest(NestedVerticalTest):
|
||||
|
||||
@@ -22,9 +22,9 @@ from ..pages.studio.settings_advanced import AdvancedSettingsPage
|
||||
from ..pages.studio.settings_graders import GradingPage
|
||||
from ..pages.studio.signup import SignupPage
|
||||
from ..pages.studio.textbooks import TextbooksPage
|
||||
from ..fixtures.course import CourseFixture, XBlockFixtureDesc
|
||||
from ..fixtures.course import XBlockFixtureDesc
|
||||
|
||||
from .helpers import UniqueCourseTest
|
||||
from acceptance.tests.base_studio_test import StudioCourseTest
|
||||
|
||||
|
||||
class LoggedOutTest(WebAppTest):
|
||||
@@ -65,7 +65,7 @@ class LoggedInPagesTest(WebAppTest):
|
||||
self.dashboard_page.visit()
|
||||
|
||||
|
||||
class CoursePagesTest(UniqueCourseTest):
|
||||
class CoursePagesTest(StudioCourseTest):
|
||||
"""
|
||||
Tests that verify the pages in Studio that you can get to when logged
|
||||
in and have a course.
|
||||
@@ -79,27 +79,6 @@ class CoursePagesTest(UniqueCourseTest):
|
||||
"""
|
||||
super(CoursePagesTest, self).setUp()
|
||||
|
||||
course_fix = CourseFixture(
|
||||
self.course_info['org'],
|
||||
self.course_info['number'],
|
||||
self.course_info['run'],
|
||||
self.course_info['display_name']
|
||||
)
|
||||
|
||||
course_fix.install()
|
||||
|
||||
# Log in as the user that created the course, and also make it
|
||||
# so that they are no longer global staff.
|
||||
# They will have been given instructor access to the course
|
||||
# and enrolled in it when they created it.
|
||||
self.auth_page = AutoAuthPage(
|
||||
self.browser,
|
||||
staff=False,
|
||||
username=course_fix.user.get('username'),
|
||||
email=course_fix.user.get('email'),
|
||||
password=course_fix.user.get('password')
|
||||
)
|
||||
|
||||
self.pages = [
|
||||
clz(self.browser, self.course_info['org'], self.course_info['number'], self.course_info['run'])
|
||||
for clz in [
|
||||
@@ -116,8 +95,6 @@ class CoursePagesTest(UniqueCourseTest):
|
||||
Rather than fire up the browser just to check each url,
|
||||
do them all sequentially in this testcase.
|
||||
"""
|
||||
# Log in
|
||||
self.auth_page.visit()
|
||||
|
||||
# In the real workflow you will be at the dashboard page
|
||||
# after you log in. This test was intermittently failing on the
|
||||
@@ -132,7 +109,7 @@ class CoursePagesTest(UniqueCourseTest):
|
||||
page.visit()
|
||||
|
||||
|
||||
class CourseSectionTest(UniqueCourseTest):
|
||||
class CourseSectionTest(StudioCourseTest):
|
||||
"""
|
||||
Tests that verify the sections name editable only inside headers in Studio Course Outline that you can get to
|
||||
when logged in and have a course.
|
||||
@@ -145,21 +122,17 @@ class CourseSectionTest(UniqueCourseTest):
|
||||
Install a course with no content using a fixture.
|
||||
"""
|
||||
super(CourseSectionTest, self).setUp()
|
||||
self.auth_page = AutoAuthPage(self.browser, staff=True).visit()
|
||||
self.course_outline_page = CourseOutlinePage(
|
||||
self.browser, self.course_info['org'], self.course_info['number'], self.course_info['run']
|
||||
)
|
||||
# Install a course with sections/problems, tabs, updates, and handouts
|
||||
course_fix = CourseFixture(
|
||||
self.course_info['org'], self.course_info['number'],
|
||||
self.course_info['run'], self.course_info['display_name']
|
||||
)
|
||||
course_fix.add_children(
|
||||
XBlockFixtureDesc('chapter', 'Test Section')
|
||||
).install()
|
||||
|
||||
self.course_outline_page.visit()
|
||||
|
||||
def populate_course_fixture(self, course_fixture):
|
||||
""" Populates the course fixture with a test section """
|
||||
course_fixture.add_children(
|
||||
XBlockFixtureDesc('chapter', 'Test Section')
|
||||
)
|
||||
|
||||
def test_section_name_editable_in_course_outline(self):
|
||||
"""
|
||||
Check that section name is editable on course outline page.
|
||||
@@ -182,15 +155,29 @@ class CourseSectionTest(UniqueCourseTest):
|
||||
section_name_edit_form = self.course_outline_page.section_name_edit_form_present(parent_css)
|
||||
self.assertFalse(section_name_edit_form)
|
||||
|
||||
class DiscussionPreviewTest(UniqueCourseTest):
|
||||
|
||||
class DiscussionPreviewTest(StudioCourseTest):
|
||||
"""
|
||||
Tests that Inline Discussions are rendered with a custom preview in Studio
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
super(DiscussionPreviewTest, self).setUp()
|
||||
cop = CourseOutlinePage(
|
||||
self.browser,
|
||||
self.course_info['org'],
|
||||
self.course_info['number'],
|
||||
self.course_info['run']
|
||||
)
|
||||
cop.visit()
|
||||
self.unit = cop.section('Test Section').subsection('Test Subsection').toggle_expand().unit('Test Unit')
|
||||
self.unit.go_to()
|
||||
|
||||
course_fix = CourseFixture(**self.course_info).add_children(
|
||||
def populate_course_fixture(self, course_fixture):
|
||||
"""
|
||||
Return a test course fixture containing a discussion component.
|
||||
"""
|
||||
course_fixture.add_children(
|
||||
XBlockFixtureDesc("chapter", "Test Section").add_children(
|
||||
XBlockFixtureDesc("sequential", "Test Subsection").add_children(
|
||||
XBlockFixtureDesc("vertical", "Test Unit").add_children(
|
||||
@@ -203,27 +190,6 @@ class DiscussionPreviewTest(UniqueCourseTest):
|
||||
)
|
||||
)
|
||||
|
||||
course_fix.install()
|
||||
|
||||
self.auth_page = AutoAuthPage(
|
||||
self.browser,
|
||||
staff=False,
|
||||
username=course_fix.user.get('username'),
|
||||
email=course_fix.user.get('email'),
|
||||
password=course_fix.user.get('password')
|
||||
)
|
||||
self.auth_page.visit()
|
||||
|
||||
cop = CourseOutlinePage(
|
||||
self.browser,
|
||||
self.course_info['org'],
|
||||
self.course_info['number'],
|
||||
self.course_info['run']
|
||||
)
|
||||
cop.visit()
|
||||
self.unit = cop.section('Test Section').subsection('Test Subsection').toggle_expand().unit('Test Unit')
|
||||
self.unit.go_to()
|
||||
|
||||
def test_is_preview(self):
|
||||
"""
|
||||
Ensure that the preview version of the discussion is rendered.
|
||||
|
||||
@@ -10,14 +10,15 @@ from unittest import skip, skipUnless
|
||||
from xmodule.partitions.partitions import Group, UserPartition
|
||||
from bok_choy.promise import Promise
|
||||
|
||||
from ..fixtures.course import CourseFixture, XBlockFixtureDesc
|
||||
from ..fixtures.course import XBlockFixtureDesc
|
||||
from ..pages.studio.component_editor import ComponentEditorView
|
||||
from ..pages.studio.settings_advanced import AdvancedSettingsPage
|
||||
from ..pages.studio.settings_group_configurations import GroupConfigurationsPage
|
||||
from ..pages.studio.auto_auth import AutoAuthPage
|
||||
from ..pages.studio.utils import add_advanced_component
|
||||
from ..pages.xblock.utils import wait_for_xblock_initialization
|
||||
from .helpers import UniqueCourseTest
|
||||
|
||||
from acceptance.tests.base_studio_test import StudioCourseTest
|
||||
|
||||
from test_studio_container import ContainerBase
|
||||
|
||||
|
||||
@@ -68,15 +69,9 @@ class SplitTest(ContainerBase, SplitTestMixin):
|
||||
"""
|
||||
__test__ = True
|
||||
|
||||
def setup_fixtures(self):
|
||||
course_fix = CourseFixture(
|
||||
self.course_info['org'],
|
||||
self.course_info['number'],
|
||||
self.course_info['run'],
|
||||
self.course_info['display_name']
|
||||
)
|
||||
|
||||
course_fix.add_advanced_settings(
|
||||
def populate_course_fixture(self, course_fixture):
|
||||
""" Populates the course """
|
||||
course_fixture.add_advanced_settings(
|
||||
{
|
||||
u"advanced_modules": {"value": ["split_test"]},
|
||||
u"user_partitions": {"value": [
|
||||
@@ -86,17 +81,13 @@ class SplitTest(ContainerBase, SplitTestMixin):
|
||||
}
|
||||
)
|
||||
|
||||
course_fix.add_children(
|
||||
course_fixture.add_children(
|
||||
XBlockFixtureDesc('chapter', 'Test Section').add_children(
|
||||
XBlockFixtureDesc('sequential', 'Test Subsection').add_children(
|
||||
XBlockFixtureDesc('vertical', 'Test Unit')
|
||||
)
|
||||
)
|
||||
).install()
|
||||
|
||||
self.course_fix = course_fix
|
||||
|
||||
self.user = course_fix.user
|
||||
)
|
||||
|
||||
def create_poorly_configured_split_instance(self):
|
||||
"""
|
||||
@@ -110,7 +101,7 @@ class SplitTest(ContainerBase, SplitTestMixin):
|
||||
container.edit()
|
||||
component_editor = ComponentEditorView(self.browser, container.locator)
|
||||
component_editor.set_select_value_and_save('Group Configuration', 'Configuration alpha,beta')
|
||||
self.course_fix.add_advanced_settings(
|
||||
self.course_fixture.add_advanced_settings(
|
||||
{
|
||||
u"user_partitions": {"value": [
|
||||
UserPartition(0, 'Configuration alpha,beta', 'first',
|
||||
@@ -118,7 +109,7 @@ class SplitTest(ContainerBase, SplitTestMixin):
|
||||
]}
|
||||
}
|
||||
)
|
||||
self.course_fix._add_advanced_settings()
|
||||
self.course_fixture._add_advanced_settings()
|
||||
return self.go_to_container_page()
|
||||
|
||||
def test_create_and_select_group_configuration(self):
|
||||
@@ -178,26 +169,13 @@ class SplitTest(ContainerBase, SplitTestMixin):
|
||||
|
||||
|
||||
@skipUnless(os.environ.get('FEATURE_GROUP_CONFIGURATIONS'), 'Tests Group Configurations feature')
|
||||
class SettingsMenuTest(UniqueCourseTest):
|
||||
class SettingsMenuTest(StudioCourseTest):
|
||||
"""
|
||||
Tests that Setting menu is rendered correctly in Studio
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
super(SettingsMenuTest, self).setUp()
|
||||
|
||||
course_fix = CourseFixture(**self.course_info)
|
||||
course_fix.install()
|
||||
|
||||
self.auth_page = AutoAuthPage(
|
||||
self.browser,
|
||||
staff=False,
|
||||
username=course_fix.user.get('username'),
|
||||
email=course_fix.user.get('email'),
|
||||
password=course_fix.user.get('password')
|
||||
)
|
||||
self.auth_page.visit()
|
||||
|
||||
self.advanced_settings = AdvancedSettingsPage(
|
||||
self.browser,
|
||||
self.course_info['org'],
|
||||
@@ -246,24 +224,6 @@ class GroupConfigurationsTest(ContainerBase, SplitTestMixin):
|
||||
"""
|
||||
__test__ = True
|
||||
|
||||
def setup_fixtures(self):
|
||||
course_fix = CourseFixture(**self.course_info)
|
||||
course_fix.add_advanced_settings({
|
||||
u"advanced_modules": {"value": ["split_test"]},
|
||||
})
|
||||
course_fix.add_children(
|
||||
XBlockFixtureDesc('chapter', 'Test Section').add_children(
|
||||
XBlockFixtureDesc('sequential', 'Test Subsection').add_children(
|
||||
XBlockFixtureDesc('vertical', 'Test Unit')
|
||||
)
|
||||
)
|
||||
).install()
|
||||
|
||||
self.course_fix = course_fix
|
||||
|
||||
self.course_fix = course_fix
|
||||
self.user = course_fix.user
|
||||
|
||||
def setUp(self):
|
||||
super(GroupConfigurationsTest, self).setUp()
|
||||
self.page = GroupConfigurationsPage(
|
||||
@@ -302,6 +262,18 @@ class GroupConfigurationsTest(ContainerBase, SplitTestMixin):
|
||||
# Collapse the configuration
|
||||
config.toggle()
|
||||
|
||||
def populate_course_fixture(self, course_fixture):
|
||||
course_fixture.add_advanced_settings({
|
||||
u"advanced_modules": {"value": ["split_test"]},
|
||||
})
|
||||
course_fixture.add_children(
|
||||
XBlockFixtureDesc('chpater', 'Test Section').add_children(
|
||||
XBlockFixtureDesc('sequential', 'Test Subsection').add_children(
|
||||
XBlockFixtureDesc('vertical', 'Test Unit')
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
def test_no_group_configurations_added(self):
|
||||
"""
|
||||
Scenario: Ensure that message telling me to create a new group configuration is
|
||||
@@ -330,7 +302,7 @@ class GroupConfigurationsTest(ContainerBase, SplitTestMixin):
|
||||
Then I see `description` and `groups` appear and also have correct values
|
||||
And I do the same checks for the second group configuration
|
||||
"""
|
||||
self.course_fix.add_advanced_settings({
|
||||
self.course_fixture.add_advanced_settings({
|
||||
u"user_partitions": {
|
||||
"value": [
|
||||
UserPartition(0, 'Name of the Group Configuration', 'Description of the group configuration.', [Group("0", 'Group 0'), Group("1", 'Group 1')]).to_json(),
|
||||
@@ -338,7 +310,7 @@ class GroupConfigurationsTest(ContainerBase, SplitTestMixin):
|
||||
],
|
||||
},
|
||||
})
|
||||
self.course_fix._add_advanced_settings()
|
||||
self.course_fixture._add_advanced_settings()
|
||||
|
||||
self.page.visit()
|
||||
|
||||
@@ -524,7 +496,7 @@ class GroupConfigurationsTest(ContainerBase, SplitTestMixin):
|
||||
And I click button 'Cancel'
|
||||
Then I see that new changes were discarded
|
||||
"""
|
||||
self.course_fix.add_advanced_settings({
|
||||
self.course_fixture.add_advanced_settings({
|
||||
u"user_partitions": {
|
||||
"value": [
|
||||
UserPartition(0, 'Name of the Group Configuration', 'Description of the group configuration.', [Group("0", 'Group 0'), Group("1", 'Group 1')]).to_json(),
|
||||
@@ -532,7 +504,7 @@ class GroupConfigurationsTest(ContainerBase, SplitTestMixin):
|
||||
],
|
||||
},
|
||||
})
|
||||
self.course_fix._add_advanced_settings()
|
||||
self.course_fixture._add_advanced_settings()
|
||||
self.page.visit()
|
||||
|
||||
config = self.page.group_configurations()[0]
|
||||
|
||||
Reference in New Issue
Block a user