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
bc483eba
Commit
bc483eba
authored
Sep 03, 2014
by
cahrens
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bok choy test for cohort group label in post.
parent
578be6cc
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
201 additions
and
18 deletions
+201
-18
common/test/acceptance/fixtures/__init__.py
+4
-1
common/test/acceptance/pages/lms/discussion.py
+6
-0
common/test/acceptance/tests/discussion/helpers.py
+31
-0
common/test/acceptance/tests/discussion/test_cohorts.py
+157
-0
common/test/acceptance/tests/discussion/test_discussion.py
+3
-17
No files found.
common/test/acceptance/fixtures/__init__.py
View file @
bc483eba
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'
)
...
...
common/test/acceptance/pages/lms/discussion.py
View file @
bc483eba
...
...
@@ -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"
)
...
...
common/test/acceptance/tests/discussion/helpers.py
0 → 100644
View file @
bc483eba
"""
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
)
common/test/acceptance/tests/discussion/test_cohorts.py
0 → 100644
View file @
bc483eba
"""
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
common/test/acceptance/tests/discussion/test_discussion.py
View file @
bc483eba
...
...
@@ -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:
...
...
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