Acceptance tests for online help.
This commit is contained in:
@@ -1,43 +1,71 @@
|
||||
import ConfigParser
|
||||
from locale import getlocale
|
||||
from django.conf import settings
|
||||
import logging
|
||||
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
# Open and parse the configuration file when the module is initialized
|
||||
config_file = open(settings.REPO_ROOT / "docs" / "config.ini")
|
||||
config = ConfigParser.ConfigParser()
|
||||
config.readfp(config_file)
|
||||
|
||||
|
||||
def doc_url(request=None):
|
||||
"""
|
||||
This function is added in the list of TEMPLATE_CONTEXT_PROCESSORS, which is a django setting for
|
||||
a tuple of callables that take a request object as their argument and return a dictionary of items
|
||||
to be merged into the RequestContext.
|
||||
|
||||
This function returns a dict with get_online_help_info, making it directly available to all mako templates.
|
||||
|
||||
Args:
|
||||
request: Currently not used, but is passed by django to context processors.
|
||||
May be used in the future for determining the language of choice.
|
||||
"""
|
||||
|
||||
def get_online_help_info(page_token):
|
||||
"""
|
||||
Args:
|
||||
page_token: A string that identifies the page for which the help information is requested.
|
||||
It should correspond to an option in the docs/config.ini file. If it doesn't, the "default"
|
||||
option is used instead.
|
||||
|
||||
def get_config_value(section_name, key, default_key="default"):
|
||||
Returns:
|
||||
A dict mapping the following items
|
||||
* "doc_url" - a string with the url corresponding to the online help location for the given page_token.
|
||||
* "pdf_url" - a string with the url corresponding to the location of the PDF help file.
|
||||
"""
|
||||
|
||||
def get_config_value(section_name, option, default_option="default"):
|
||||
try:
|
||||
return config.get(section_name, key)
|
||||
return config.get(section_name, option)
|
||||
except (ConfigParser.NoOptionError, AttributeError):
|
||||
return config.get(section_name, default_key)
|
||||
log.debug("Didn't find a configuration option for '%s' section and '%s' option", section_name, option)
|
||||
return config.get(section_name, default_option)
|
||||
|
||||
def get_page_path(page_token):
|
||||
return get_config_value("pages", page_token)
|
||||
|
||||
def get_langage_path(request):
|
||||
language_code = settings.LANGUAGE_CODE
|
||||
return get_config_value("locales", language_code)
|
||||
|
||||
def get_url(base_option):
|
||||
return "{base_url}/{language}/{version}/{page_path}".format(
|
||||
base_url=config.get("server_settings", base_option),
|
||||
def get_doc_url():
|
||||
return "{url_base}/{language}/{version}/{page_path}".format(
|
||||
url_base=config.get("help_settings", "url_base"),
|
||||
language=language_dir,
|
||||
version=config.get("server_settings", "version"),
|
||||
version=config.get("help_settings", "version"),
|
||||
page_path=page_path,
|
||||
)
|
||||
|
||||
language_dir = get_langage_path(request)
|
||||
page_path = get_page_path(page_token)
|
||||
def get_pdf_url():
|
||||
return "{pdf_base}/{version}/{pdf_file}".format(
|
||||
pdf_base=config.get("pdf_settings", "pdf_base"),
|
||||
version=config.get("help_settings", "version"),
|
||||
pdf_file=config.get("pdf_settings", "pdf_file"),
|
||||
)
|
||||
|
||||
language_dir = get_config_value("locales", settings.LANGUAGE_CODE)
|
||||
page_path = get_config_value("pages", page_token)
|
||||
|
||||
return {
|
||||
"doc_url": get_url("base_url"),
|
||||
"pdf_url": get_url("base_pdf"),
|
||||
"doc_url": get_doc_url(),
|
||||
"pdf_url": get_pdf_url(),
|
||||
}
|
||||
|
||||
return {'get_online_help_info': get_online_help_info}
|
||||
|
||||
@@ -6,11 +6,16 @@ from component_settings_editor_helpers import enter_xml_in_advanced_problem
|
||||
from nose.tools import assert_true, assert_equal
|
||||
|
||||
|
||||
@step('I export the course$')
|
||||
def i_export_the_course(step):
|
||||
@step('I go to the export page$')
|
||||
def i_go_to_the_export_page(step):
|
||||
world.click_tools()
|
||||
link_css = 'li.nav-course-tools-export a'
|
||||
world.css_click(link_css)
|
||||
|
||||
|
||||
@step('I export the course$')
|
||||
def i_export_the_course(step):
|
||||
step.given('I go to the export page')
|
||||
world.css_click('a.action-export')
|
||||
|
||||
|
||||
@@ -30,7 +35,7 @@ def i_enter_bad_xml(step):
|
||||
|
||||
|
||||
@step('I edit and enter an ampersand$')
|
||||
def i_enter_bad_xml(step):
|
||||
def i_enter_an_ampersand(step):
|
||||
enter_xml_in_advanced_problem(step, "<problem>&</problem>")
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import os
|
||||
from lettuce import world
|
||||
from lettuce import world, step
|
||||
from django.conf import settings
|
||||
|
||||
|
||||
@@ -14,7 +14,8 @@ def import_file(filename):
|
||||
world.css_click(outline_css)
|
||||
|
||||
|
||||
def go_to_import():
|
||||
@step('I go to the import page$')
|
||||
def go_to_import(step):
|
||||
menu_css = 'li.nav-course-tools'
|
||||
import_css = 'li.nav-course-tools-import a'
|
||||
world.css_click(menu_css)
|
||||
|
||||
49
cms/djangoapps/contentstore/features/help.feature
Normal file
49
cms/djangoapps/contentstore/features/help.feature
Normal file
@@ -0,0 +1,49 @@
|
||||
@shard_1
|
||||
Feature: CMS.Help
|
||||
As a course author, I am able to access online help
|
||||
|
||||
Scenario: Users can access online help on course listing page
|
||||
Given There are no courses
|
||||
And I am logged into Studio
|
||||
Then I should see online help for "get_started"
|
||||
|
||||
|
||||
Scenario: Users can access online help within a course
|
||||
Given I have opened a new course in Studio
|
||||
|
||||
And I click the course link in My Courses
|
||||
Then I should see online help for "organizing_course"
|
||||
|
||||
And I go to the course updates page
|
||||
Then I should see online help for "updates"
|
||||
|
||||
And I go to the pages page
|
||||
Then I should see online help for "pages"
|
||||
|
||||
And I go to the files and uploads page
|
||||
Then I should see online help for "files"
|
||||
|
||||
And I go to the textbooks page
|
||||
Then I should see online help for "textbooks"
|
||||
|
||||
And I select Schedule and Details
|
||||
Then I should see online help for "setting_up"
|
||||
|
||||
And I am viewing the grading settings
|
||||
Then I should see online help for "grading"
|
||||
|
||||
And I am viewing the course team settings
|
||||
Then I should see online help for "course-team"
|
||||
|
||||
And I select the Advanced Settings
|
||||
Then I should see online help for "index"
|
||||
|
||||
And I select Checklists from the Tools menu
|
||||
Then I should see online help for "checklist"
|
||||
|
||||
And I go to the import page
|
||||
Then I should see online help for "import"
|
||||
|
||||
And I go to the export page
|
||||
Then I should see online help for "export"
|
||||
|
||||
17
cms/djangoapps/contentstore/features/help.py
Normal file
17
cms/djangoapps/contentstore/features/help.py
Normal file
@@ -0,0 +1,17 @@
|
||||
from lettuce import world, step
|
||||
from nose.tools import assert_false
|
||||
|
||||
|
||||
def find_online_help_for(page_name):
|
||||
return world.browser.find_by_xpath(
|
||||
'//li[contains(@class, "nav-account-help")]//a[contains(@href, "{page_name}")]'.format(
|
||||
page_name=page_name
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@step(u'I should see online help for "([^"]*)"$')
|
||||
def see_online_help_for(step, page_name):
|
||||
elements_found = find_online_help_for(page_name)
|
||||
assert_false(elements_found.is_empty())
|
||||
|
||||
@@ -6,7 +6,7 @@ from lettuce import world, step
|
||||
from nose.tools import assert_equal, assert_true # pylint: disable=E0611
|
||||
from common import type_in_codemirror, open_new_course
|
||||
from advanced_settings import change_value
|
||||
from course_import import import_file, go_to_import
|
||||
from course_import import import_file
|
||||
|
||||
DISPLAY_NAME = "Display Name"
|
||||
MAXIMUM_ATTEMPTS = "Maximum Attempts"
|
||||
@@ -218,11 +218,6 @@ def i_have_empty_course(step):
|
||||
open_new_course()
|
||||
|
||||
|
||||
@step(u'I go to the import page')
|
||||
def i_go_to_import(_step):
|
||||
go_to_import()
|
||||
|
||||
|
||||
@step(u'I import the file "([^"]*)"$')
|
||||
def i_import_the_file(_step, filename):
|
||||
import_file(filename)
|
||||
|
||||
@@ -76,9 +76,9 @@ require(["js/models/section", "js/collections/textbook", "js/views/list_textbook
|
||||
<h3 class="title-3">${_("What if my book isn't divided into chapters?")}</h3>
|
||||
<p>${_("If your textbook doesn't have individual chapters, you can upload the entire text as a single chapter and enter a name of your choice in the Chapter Name field.")}</p>
|
||||
<%
|
||||
help_doc_urls = get_online_help_info(online_help_token)
|
||||
help_doc_urls = get_online_help_info(online_help_token())
|
||||
%>
|
||||
<p><a href="${help_doc_urls['doc_url']}" target="_blank">Read More</a></p>
|
||||
<p><a href="${help_doc_urls['doc_url']}" target="_blank">${_("Read More")}</a></p>
|
||||
</div>
|
||||
</aside>
|
||||
</section>
|
||||
|
||||
@@ -1,10 +1,18 @@
|
||||
# below are the server-wide settings for documentation
|
||||
[server_settings]
|
||||
base_url = http://edx.readthedocs.org/projects/edx-partner-course-staff
|
||||
base_pdf = https://media.readthedocs.org/pdf/edx-partner-course-staff
|
||||
[help_settings]
|
||||
url_base = http://edx.readthedocs.org/projects/edx-partner-course-staff
|
||||
version = latest
|
||||
|
||||
|
||||
# below are the pdf settings for the pdf file
|
||||
[pdf_settings]
|
||||
pdf_base = https://media.readthedocs.org/pdf/edx-partner-course-staff
|
||||
pdf_file = edx-partner-course-staff.pdf
|
||||
|
||||
|
||||
# below are the sub-paths to the documentation for the various pages
|
||||
# NOTE: If any of these page settings change, then their corresponding test should be updated
|
||||
# in edx-platform/cms/djangoapps/contentstore/features/help.feature
|
||||
[pages]
|
||||
default = index.html
|
||||
home = getting_started/get_started.html
|
||||
@@ -21,6 +29,7 @@ checklist = building_course/creating_new_course.html#use-the-course-checklist
|
||||
import = building_course/export_import_course.html
|
||||
export = building_course/export_import_course.html
|
||||
|
||||
|
||||
# below are the language directory names for the different locales
|
||||
[locales]
|
||||
default = en
|
||||
|
||||
Reference in New Issue
Block a user