Commit 73275eeb by Nimisha Asthagiri

Updated tests for online help

parent 27ff0db5
......@@ -12,7 +12,7 @@ config = ConfigParser.ConfigParser()
config.readfp(config_file)
def doc_url(request=None):
def doc_url(request=None): # pylint: disable=unused-argument
"""
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
......@@ -25,7 +25,7 @@ def doc_url(request=None):
May be used in the future for determining the language of choice.
"""
def get_online_help_info(page_token):
def get_online_help_info(page_token=None):
"""
Args:
page_token: A string that identifies the page for which the help information is requested.
......@@ -38,7 +38,14 @@ def doc_url(request=None):
* "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"):
def get_config_value_with_default(section_name, option, default_option="default"):
"""
Args:
section_name: name of the section in the configuration from which the option should be found
option: name of the configuration option
default_option: name of the default configuration option whose value should be returned if the
requested option is not found
"""
try:
return config.get(section_name, option)
except (ConfigParser.NoOptionError, AttributeError):
......@@ -46,23 +53,28 @@ def doc_url(request=None):
return config.get(section_name, default_option)
def get_doc_url():
"""
Returns:
The URL for the documentation
"""
return "{url_base}/{language}/{version}/{page_path}".format(
url_base=config.get("help_settings", "url_base"),
language=language_dir,
language=get_config_value_with_default("locales", settings.LANGUAGE_CODE),
version=config.get("help_settings", "version"),
page_path=page_path,
page_path=get_config_value_with_default("pages", page_token),
)
def get_pdf_url():
"""
Returns:
The URL for the PDF document using the pdf_settings and the help_settings (version) in the configuration
"""
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_doc_url(),
"pdf_url": get_pdf_url(),
......
# disable missing docstring
# pylint: disable=C0111
# pylint: disable=W0621
# pylint: disable=W0613
from lettuce import world, step
from component_settings_editor_helpers import enter_xml_in_advanced_problem
......
# pylint: disable=C0111
# pylint: disable=W0621
# pylint: disable=W0613
import os
from lettuce import world, step
from django.conf import settings
......
......@@ -14,12 +14,6 @@ Feature: CMS.Help
And I click the course link in My Courses
Then I should see online help for "organizing_course"
And I click a subsection in the outline
Then I should see the online help for "subsection"
And I click a unit
Then I should see the online help for "unit"
And I go to the course updates page
Then I should see online help for "updates"
......@@ -53,3 +47,15 @@ Feature: CMS.Help
And I go to the export page
Then I should see online help for "export"
Scenario: Users can access online help on the unit page
Given I am in Studio editing a new unit
Then I should see online help for "units"
Scenario: Users can access online help on the subsection page
Given I have opened a new course section in Studio
And I have added a new subsection
And I click on the subsection
Then I should see online help for "subsections"
from lettuce import world, step
from nose.tools import assert_false
# pylint: disable=C0111
# pylint: disable=W0621
# pylint: disable=W0613
from nose.tools import assert_false # pylint: disable=no-name-in-module
from lettuce import step, world
def find_online_help_for(page_name):
return world.browser.find_by_xpath(
@step(u'I should see online help for "([^"]*)"$')
def see_online_help_for(step, page_name):
# make sure the online Help link exists on this page and contains the expected page name
elements_found = 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())
# make sure the PDF link on the sock of this page exists
# for now, the PDF link stays constant for all the pages so we just check for "pdf"
elements_found = world.browser.find_by_xpath(
'//section[contains(@class, "sock")]//li[contains(@class, "js-help-pdf")]//a[contains(@href, "pdf")]'
)
assert_false(elements_found.is_empty())
......@@ -277,7 +277,7 @@
<script type="text/javascript">
require(['js/sock']);
</script>
<%include file="widgets/sock.html" />
<%include file="widgets/sock.html" args="online_help_token=online_help_token" />
% endif
<%include file="widgets/footer.html" />
......
......@@ -275,9 +275,6 @@ require(["domReady!", "jquery", "jquery.form", "js/index"], function(doc, $) {
% endif
</article>
<%
help_doc_urls = get_online_help_info(online_help_token())
%>
<aside class="content-supplementary" role="complimentary">
<div class="bit">
<h3 class="title title-3">${_('New to edX Studio?')}</h3>
......@@ -286,7 +283,7 @@ require(["domReady!", "jquery", "jquery.form", "js/index"], function(doc, $) {
<ol class="list-actions">
<li class="action-item">
<a href="${help_doc_urls['doc_url']}" target="_blank">${_("Getting Started with edX Studio")}</a>
<a href="${get_online_help_info(online_help_token())['doc_url']}" target="_blank">${_("Getting Started with edX Studio")}</a>
</li>
<li class="action-item">
<a href="http://help.edge.edx.org/discussion/new" class="show-tender" title="Use our feedback tool, Tender, to request help">${_('Request help with edX Studio')}</a>
......
......@@ -75,10 +75,7 @@ require(["js/models/section", "js/collections/textbook", "js/views/list_textbook
<div class="bit">
<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())
%>
<p><a href="${help_doc_urls['doc_url']}" target="_blank">${_("Learn More")}</a></p>
<p><a href="${get_online_help_info(online_help_token())['doc_url']}" target="_blank">${_("Learn More")}</a></p>
</div>
</aside>
</section>
......
......@@ -124,13 +124,9 @@
% if user.is_authenticated():
<nav class="nav-account nav-is-signedin nav-dd ui-right">
<h2 class="sr">${_("Help &amp; Account Navigation")}</h2>
<%
help_doc_urls = get_online_help_info(online_help_token)
%>
<ol>
<li class="nav-item nav-account-help">
<h3 class="title"><span class="label"><a href="${help_doc_urls['doc_url']}" title="${_("Contextual Online Help")}" target="${_("_blank")}">${_("Help")}</a></span></h3>
<h3 class="title"><span class="label"><a href="${get_online_help_info(online_help_token)['doc_url']}" title="${_("Contextual Online Help")}" target="${_("_blank")}">${_("Help")}</a></span></h3>
</li>
<li class="nav-item nav-account-user">
......
<%! from django.utils.translation import ugettext as _ %>
<%! from django.core.urlresolvers import reverse %>
<%def name="online_help_token()"><% return "default" %></%def>
<%page args="online_help_token"/>
<div class="wrapper-sock wrapper">
<ul class="list-actions list-cta">
<li class="action-item">
......@@ -22,12 +22,8 @@
</div>
<ul class="list-actions">
<%
help_doc_urls = get_online_help_info(online_help_token())
%>
<li class="action-item">
<a href="${help_doc_urls['pdf_url']}" target="_blank" rel="external" class="action action-primary">${_("Building and Running an edX Course PDF")}</a>
<li class="action-item js-help-pdf">
<a href="${get_online_help_info(online_help_token)['pdf_url']}" target="_blank" rel="external" class="action action-primary">${_("Building and Running an edX Course PDF")}</a>
</li>
<li class="action-item">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment