Merge pull request #5063 from edx/christina/cohorts-bok-choy
Christina/cohorts bok choy
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
import os
|
||||
|
||||
# Get the URL of the instance under test
|
||||
# Get the URL of the Studio instance under test
|
||||
STUDIO_BASE_URL = os.environ.get('studio_url', 'http://localhost:8031')
|
||||
|
||||
# Get the URL of the LMS instance under test
|
||||
LMS_BASE_URL = os.environ.get('lms_url', 'http://localhost:8003')
|
||||
|
||||
# Get the URL of the XQueue stub used in the test
|
||||
XQUEUE_STUB_URL = os.environ.get('xqueue_url', 'http://localhost:8040')
|
||||
|
||||
|
||||
@@ -60,6 +60,12 @@ class DiscussionThreadPage(PageObject, DiscussionPageMixin):
|
||||
"Secondary action menu closed"
|
||||
).fulfill()
|
||||
|
||||
def get_group_visibility_label(self):
|
||||
"""
|
||||
Returns the group visibility label shown for the thread.
|
||||
"""
|
||||
return self._get_element_text(".group-visibility-label")
|
||||
|
||||
def get_response_total_text(self):
|
||||
"""Returns the response count text, or None if not present"""
|
||||
return self._get_element_text(".response-count")
|
||||
|
||||
31
common/test/acceptance/tests/discussion/helpers.py
Normal file
31
common/test/acceptance/tests/discussion/helpers.py
Normal file
@@ -0,0 +1,31 @@
|
||||
"""
|
||||
Helper functions and classes for discussion tests.
|
||||
"""
|
||||
|
||||
from uuid import uuid4
|
||||
|
||||
from ...fixtures.discussion import (
|
||||
SingleThreadViewFixture,
|
||||
Thread,
|
||||
Response,
|
||||
)
|
||||
|
||||
|
||||
class BaseDiscussionMixin(object):
|
||||
"""
|
||||
A mixin containing methods common to discussion tests.
|
||||
"""
|
||||
def setup_thread(self, num_responses, **thread_kwargs):
|
||||
"""
|
||||
Create a test thread with the given number of responses, passing all
|
||||
keyword arguments through to the Thread fixture, then invoke
|
||||
setup_thread_page.
|
||||
"""
|
||||
thread_id = "test_thread_{}".format(uuid4().hex)
|
||||
thread_fixture = SingleThreadViewFixture(
|
||||
Thread(id=thread_id, commentable_id=self.discussion_id, **thread_kwargs)
|
||||
)
|
||||
for i in range(num_responses):
|
||||
thread_fixture.addResponse(Response(id=str(i), body=str(i)))
|
||||
thread_fixture.push()
|
||||
self.setup_thread_page(thread_id)
|
||||
157
common/test/acceptance/tests/discussion/test_cohorts.py
Normal file
157
common/test/acceptance/tests/discussion/test_cohorts.py
Normal file
@@ -0,0 +1,157 @@
|
||||
"""
|
||||
Tests related to the cohorting feature.
|
||||
"""
|
||||
from uuid import uuid4
|
||||
|
||||
from helpers import BaseDiscussionMixin
|
||||
from ...pages.lms.auto_auth import AutoAuthPage
|
||||
from ..helpers import UniqueCourseTest
|
||||
from ...fixtures.course import (CourseFixture, XBlockFixtureDesc)
|
||||
from ...fixtures import LMS_BASE_URL
|
||||
|
||||
from ...pages.lms.discussion import (DiscussionTabSingleThreadPage, InlineDiscussionThreadPage, InlineDiscussionPage)
|
||||
from ...pages.lms.courseware import CoursewarePage
|
||||
|
||||
from nose.plugins.attrib import attr
|
||||
|
||||
|
||||
class NonCohortedDiscussionTestMixin(BaseDiscussionMixin):
|
||||
"""
|
||||
Mixin for tests of non-cohorted courses.
|
||||
"""
|
||||
def setup_cohorts(self):
|
||||
"""
|
||||
No cohorts are desired for this mixin.
|
||||
"""
|
||||
pass
|
||||
|
||||
def test_non_cohort_visibility_label(self):
|
||||
self.setup_thread(1)
|
||||
self.assertEquals(self.thread_page.get_group_visibility_label(), "This post is visible to everyone.")
|
||||
|
||||
|
||||
class CohortedDiscussionTestMixin(BaseDiscussionMixin):
|
||||
"""
|
||||
Mixin for tests of cohorted courses.
|
||||
"""
|
||||
def add_cohort(self, name):
|
||||
"""
|
||||
Adds a cohort group by name, returning the ID for the group.
|
||||
"""
|
||||
url = LMS_BASE_URL + "/courses/" + self.course_fixture._course_key + '/cohorts/add'
|
||||
data = {"name": name}
|
||||
response = self.course_fixture.session.post(url, data=data, headers=self.course_fixture.headers)
|
||||
self.assertTrue(response.ok, "Failed to create cohort")
|
||||
return response.json()['cohort']['id']
|
||||
|
||||
def setup_cohorts(self):
|
||||
"""
|
||||
Sets up the course to use cohorting with a single defined cohort group.
|
||||
"""
|
||||
self.course_fixture._update_xblock(self.course_fixture._course_location, {
|
||||
"metadata": {
|
||||
u"cohort_config": {
|
||||
"auto_cohort_groups": [],
|
||||
"auto_cohort": False,
|
||||
"cohorted_discussions": [],
|
||||
"cohorted": True
|
||||
},
|
||||
},
|
||||
})
|
||||
self.cohort_1_name = "Cohort Group 1"
|
||||
self.cohort_1_id = self.add_cohort(self.cohort_1_name)
|
||||
|
||||
def test_cohort_visibility_label(self):
|
||||
self.setup_thread(1, group_id=self.cohort_1_id)
|
||||
self.assertEquals(
|
||||
self.thread_page.get_group_visibility_label(),
|
||||
"This post is visible only to {}.".format(self.cohort_1_name)
|
||||
)
|
||||
|
||||
|
||||
class DiscussionTabSingleThreadTest(UniqueCourseTest):
|
||||
"""
|
||||
Tests for the discussion page displaying a single thread.
|
||||
"""
|
||||
def setUp(self):
|
||||
super(DiscussionTabSingleThreadTest, self).setUp()
|
||||
self.discussion_id = "test_discussion_{}".format(uuid4().hex)
|
||||
# Create a course to register for
|
||||
self.course_fixture = CourseFixture(**self.course_info).install()
|
||||
self.setup_cohorts()
|
||||
AutoAuthPage(self.browser, course_id=self.course_id).visit()
|
||||
|
||||
def setup_thread_page(self, thread_id):
|
||||
self.thread_page = DiscussionTabSingleThreadPage(self.browser, self.course_id, thread_id) # pylint:disable=W0201
|
||||
self.thread_page.visit()
|
||||
|
||||
|
||||
@attr('shard_1')
|
||||
class CohortedDiscussionTabSingleThreadTest(DiscussionTabSingleThreadTest, CohortedDiscussionTestMixin):
|
||||
"""
|
||||
Tests for the discussion page displaying a single cohorted thread.
|
||||
"""
|
||||
# Actual test method(s) defined in CohortedDiscussionTestMixin.
|
||||
pass
|
||||
|
||||
|
||||
@attr('shard_1')
|
||||
class NonCohortedDiscussionTabSingleThreadTest(DiscussionTabSingleThreadTest, NonCohortedDiscussionTestMixin):
|
||||
"""
|
||||
Tests for the discussion page displaying a single non-cohorted thread.
|
||||
"""
|
||||
# Actual test method(s) defined in NonCohortedDiscussionTestMixin.
|
||||
pass
|
||||
|
||||
|
||||
class InlineDiscussionTest(UniqueCourseTest):
|
||||
"""
|
||||
Tests for inline discussions
|
||||
"""
|
||||
def setUp(self):
|
||||
super(InlineDiscussionTest, self).setUp()
|
||||
self.discussion_id = "test_discussion_{}".format(uuid4().hex)
|
||||
self.course_fixture = CourseFixture(**self.course_info).add_children(
|
||||
XBlockFixtureDesc("chapter", "Test Section").add_children(
|
||||
XBlockFixtureDesc("sequential", "Test Subsection").add_children(
|
||||
XBlockFixtureDesc("vertical", "Test Unit").add_children(
|
||||
XBlockFixtureDesc(
|
||||
"discussion",
|
||||
"Test Discussion",
|
||||
metadata={"discussion_id": self.discussion_id}
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
).install()
|
||||
self.setup_cohorts()
|
||||
|
||||
self.user_id = AutoAuthPage(self.browser, course_id=self.course_id).visit().get_user_id()
|
||||
|
||||
self.courseware_page = CoursewarePage(self.browser, self.course_id)
|
||||
self.courseware_page.visit()
|
||||
self.discussion_page = InlineDiscussionPage(self.browser, self.discussion_id)
|
||||
|
||||
def setup_thread_page(self, thread_id):
|
||||
self.discussion_page.expand_discussion()
|
||||
self.assertEqual(self.discussion_page.get_num_displayed_threads(), 1)
|
||||
self.thread_page = InlineDiscussionThreadPage(self.browser, thread_id) # pylint:disable=W0201
|
||||
self.thread_page.expand()
|
||||
|
||||
|
||||
@attr('shard_1')
|
||||
class CohortedInlineDiscussionTest(InlineDiscussionTest, CohortedDiscussionTestMixin):
|
||||
"""
|
||||
Tests for cohorted inline discussions.
|
||||
"""
|
||||
# Actual test method(s) defined in CohortedDiscussionTestMixin.
|
||||
pass
|
||||
|
||||
|
||||
@attr('shard_1')
|
||||
class NonCohortedInlineDiscussionTest(InlineDiscussionTest, NonCohortedDiscussionTestMixin):
|
||||
"""
|
||||
Tests for non-cohorted inline discussions.
|
||||
"""
|
||||
# Actual test method(s) defined in NonCohortedDiscussionTestMixin.
|
||||
pass
|
||||
@@ -29,28 +29,14 @@ from ...fixtures.discussion import (
|
||||
SearchResult,
|
||||
)
|
||||
|
||||
from helpers import BaseDiscussionMixin
|
||||
|
||||
class DiscussionResponsePaginationTestMixin(object):
|
||||
|
||||
class DiscussionResponsePaginationTestMixin(BaseDiscussionMixin):
|
||||
"""
|
||||
A mixin containing tests for response pagination for use by both inline
|
||||
discussion and the discussion tab
|
||||
"""
|
||||
|
||||
def setup_thread(self, num_responses, **thread_kwargs):
|
||||
"""
|
||||
Create a test thread with the given number of responses, passing all
|
||||
keyword arguments through to the Thread fixture, then invoke
|
||||
setup_thread_page.
|
||||
"""
|
||||
thread_id = "test_thread_{}".format(uuid4().hex)
|
||||
thread_fixture = SingleThreadViewFixture(
|
||||
Thread(id=thread_id, commentable_id=self.discussion_id, **thread_kwargs)
|
||||
)
|
||||
for i in range(num_responses):
|
||||
thread_fixture.addResponse(Response(id=str(i), body=str(i)))
|
||||
thread_fixture.push()
|
||||
self.setup_thread_page(thread_id)
|
||||
|
||||
def assert_response_display_correct(self, response_total, displayed_responses):
|
||||
"""
|
||||
Assert that various aspects of the display of responses are all correct:
|
||||
|
||||
Reference in New Issue
Block a user