Commit 204d1477 by Jonathan Piacenti

Merge branch 'mcka_master' into oc_master_merge

parents e7a6c95c a71e71b7
......@@ -44,6 +44,7 @@ htmlcov/
.cache
nosetests.xml
coverage.xml
tests.integration.*
# Translations
*.mo
......
......@@ -5,9 +5,16 @@ before_install:
- "export DISPLAY=:99"
- "sh -e /etc/init.d/xvfb start"
install:
- "sh install_test_deps.sh"
- "pip install -e git://github.com/edx/xblock-sdk.git#egg=xblock-sdk"
- "cd $VIRTUAL_ENV/src/xblock-sdk/"
- "pip install -r $VIRTUAL_ENV/src/xblock-sdk/requirements/base.txt"
- "pip install -r $VIRTUAL_ENV/src/xblock-sdk/requirements/test.txt"
- "cd -"
- "pip install -r requirements.txt"
- "mkdir var"
script: pep8 poll --max-line-length=120 && pylint poll && python run_tests.py --with-coverage --cover-package=poll
notifications:
email: false
addons:
firefox: "36.0"
# Installs xblock-sdk and dependencies needed to run the tests suite.
# Run this script inside a fresh virtual environment.
pip install -e git://github.com/edx/xblock-sdk.git#egg=xblock-sdk
cd $VIRTUAL_ENV/src/xblock-sdk/ && { pip install -r requirements.txt; cd -; }
pip install -r $VIRTUAL_ENV/src/xblock-sdk/test-requirements.txt
pip install -r requirements.txt
/* CSS for PollBlock Student View */
.poll-answer {
.poll-answer-text {
margin-left: 1em;
margin-bottom: 0;
font-weight: bold;
display: inline-block;
vertical-align: middle;
}
.percentage-gauge {
display: inline-block;
background-color: #e5ebee;
position: relative;
z-index: 1;
position: absolute;
top: 0;
left: 0;
height: 100%;
}
.poll-result-input-container {
......@@ -31,6 +35,7 @@
display: inline-block;
width: 65%;
vertical-align: middle;
position: relative;
background-color: #fafbfc;
}
......@@ -40,11 +45,10 @@ ul.poll-answers, ul.poll-answers-results {
}
li.poll-answer {
display: block;
display: table-row;
border-bottom-width: .5em;
vertical-align: middle;
margin-top: 5px;
margin-bottom: 5px;
}
li.poll-spacer {
......@@ -63,16 +67,20 @@ div.poll-block ul.poll-results li.poll-result {
display: inline-block;
margin-bottom: 5px;
margin-top: 5px;
white-space: nowrap;
position: relative;
}
.poll-image {
width: 25%;
display: inline-block;
display: table-cell;
vertical-align: middle;
margin-left: .5em;
}
.poll-image.result-image {
background-color: #fafbfc;
}
li.poll-result .poll-image {
width: 22%;
display: inline-block;
......@@ -190,11 +198,17 @@ th.survey-answer {
}
/* Counteract Markdown's wrapping in paragraphs */
.poll-answer p, .survey-question p, .poll-answer-label p{
margin: 0;
.survey-question p, div.percentage-gauge-container label.poll-answer-label p{
margin-bottom: 0;
padding: 0;
}
/* Keep the paragraph spacing, but make the spacing vertically even. */
li.poll-answer label.poll-answer-text p {
margin-bottom: .5em;
margin-top: .5em;
}
.poll-voting-thanks span {
margin-top: .25em;
margin-bottom: .25em;
......@@ -220,3 +234,10 @@ th.survey-answer {
.poll-block-form-wrapper {
display: none;
}
.poll-input-container {
display: table-cell;
vertical-align: middle;
height: 100%;
padding-right: .5em;
}
......@@ -17,9 +17,8 @@
</div><div class="percentage-gauge-background"></div>
{{~/if~}}
<div class="percentage-gauge-container">
<div class="percentage-gauge" style="width:{{percent}}%;">
<label class="poll-answer-label" for="answer-{{key}}">{{{answer}}}</label>
</div>
<div class="percentage-gauge" style="width:{{percent}}%;"></div>
<label class="poll-answer-label" for="answer-{{key}}">{{{answer}}}</label>
</div>
<div class="poll-percent-container">
<span class="poll-percent-display{{#if first}} poll-top-choice{{/if}}">{{percent}}%</span>
......
{{ js_template|safe }}
<div class="poll-block themed-xblock" data-private="{% if private_results %}1{% endif %}" data-can-vote="{% if can_vote %}1{% endif %}">
<div class="poll-block-form-wrapper">
<h3 class="poll-header">{{display_name}}</h3>
<form>
<div class="poll-question-container">
{{question|safe}}
</div>
<ul class="poll-answers">
{% for key, value in answers %}
<li class="poll-answer">
<input type="radio" name="choice" id="{{url_name}}-answer-{{key}}" value="{{key}}" {% if choice == key %}checked{% endif %}/>
{% if value.img %}
<div class="poll-image">
<label for="{{url_name}}-answer-{{key}}" class="poll-image-label">
<img src="{{value.img}}" alt="{{value.img_alt|default_if_none:''}}"/>
</label>
</div>
{% endif %}
<label class="poll-answer" for="{{url_name}}-answer-{{key}}">{{value.label|safe}}</label>
</li>
{% endfor %}
</ul>
<input class="input-main" type="button" name="poll-submit" value="{% if choice %}Resubmit{% else %}Submit{% endif %}" disabled />
</form>
<div class="poll-voting-thanks{% if not choice or can_vote %} poll-hidden{% endif %}"><span>Thank you for your submission!</span></div>
<div class="poll-submissions-count poll-hidden">
You have used <span class="poll-current-count">{{ submissions_count }}</span>
out of <span class="poll-max-submissions">{{ max_submissions }}</span> submissions.
</div>
{% if feedback %}
<div class="poll-feedback-container{% if not choice %} poll-hidden{% endif %}">
<hr />
<h3 class="poll-header">Feedback</h3>
<div class="poll-feedback">
{{feedback|safe}}
</div>
</div>
{% endif %}
<div class="poll-block-form-wrapper">
<h3 class="poll-header">{{display_name}}</h3>
<form>
<div class="poll-question-container">
{{question|safe}}
</div>
<ul class="poll-answers">
{% for key, value in answers %}
<li class="poll-answer">
<div class="poll-input-container">
<input type="radio" name="choice" id="{{url_name}}-answer-{{key}}" value="{{key}}" {% if choice == key %}checked{% endif %}/>
</div>
{% if any_img %}
<div class="poll-image">
<label for="{{url_name}}-answer-{{key}}" class="poll-image-label">
{% if value.img %}
<img src="{{value.img}}" />
{% endif %}
</label>
</div>
{% endif %}
<label class="poll-answer-text" for="{{url_name}}-answer-{{key}}">{{value.label|safe}}</label>
</li>
{% endfor %}
</ul>
<input class="input-main" type="button" name="poll-submit" value="{% if choice %}Resubmit{% else %}Submit{% endif %}" disabled />
</form>
<div class="poll-voting-thanks{% if not choice or can_vote %} poll-hidden{% endif %}"><span>Thank you for your submission!</span></div>
<div class="poll-submissions-count poll-hidden">
You have used <span class="poll-current-count">{{ submissions_count }}</span>
out of <span class="poll-max-submissions">{{ max_submissions }}</span> submissions.
</div>
{% if feedback %}
<div class="poll-feedback-container{% if not choice %} poll-hidden{% endif %}">
<hr />
<h3 class="poll-header">Feedback</h3>
<div class="poll-feedback">
{{feedback|safe}}
</div>
</div>
{% endif %}
{% if can_view_private_results %}
<div class="view-results-button-wrapper"><button class="view-results-button">View results</button></div>
......
markdown
-e git://github.com/edx/xblock-utils.git@213a97a50276d6a2504d8133650b2930ead357a0#egg=xblock-utils
-e git://github.com/edx/xblock-utils.git#egg=xblock-utils
-e git://github.com/nosedjango/nosedjango.git@ed7d7f9aa969252ff799ec159f828eaa8c1cbc5a#egg=nosedjango-dev
ddt
mock
selenium==2.47.3 # 2.48 is not working atm
-e .
......@@ -55,7 +55,7 @@ ddt_scenarios = [
False
],
[
"Poll Markdown", "label.poll-answer", "<p>I <em>feel</em> like this test will <strong>pass</strong><code>test</code>.</p>",
"Poll Markdown", "label.poll-answer-text", "<p>I <em>feel</em> like this test will <strong>pass</strong><code>test</code>.</p>",
True, False
],
[
......
......@@ -28,7 +28,7 @@ ddt_scenarios = [
'Poll Studio',
'answer',
4,
'label.poll-answer'
'label.poll-answer-text'
],
[
'Survey Studio',
......
......@@ -24,10 +24,10 @@
Tests a realistic, configured Poll to make sure that everything works as it
should.
"""
from selenium.common.exceptions import NoSuchElementException
import time
from .base_test import PollBaseTest
ANSWER_SELECTOR = 'label.poll-answer-text'
class TestPollFunctions(PollBaseTest):
def test_first_load(self):
......@@ -38,7 +38,7 @@ class TestPollFunctions(PollBaseTest):
not showing, and that the submit button is disabled.
"""
self.go_to_page('Poll Functions')
answer_elements = self.browser.find_elements_by_css_selector('label.poll-answer')
answer_elements = self.browser.find_elements_by_css_selector(ANSWER_SELECTOR)
answers = [element.text for element in answer_elements]
self.assertEqual(['A very long time', 'Not very long', 'I shall not say', 'Longer than you'], answers)
......@@ -52,7 +52,7 @@ class TestPollFunctions(PollBaseTest):
Makes sure the submit button is enabled when selecting an answer.
"""
self.go_to_page('Poll Functions')
answer_elements = self.browser.find_elements_by_css_selector('label.poll-answer')
answer_elements = self.browser.find_elements_by_css_selector(ANSWER_SELECTOR)
answer_elements[0].click()
# When an answer is selected, make sure submit is enabled.
......@@ -65,7 +65,7 @@ class TestPollFunctions(PollBaseTest):
Also check that feedback is displayed afterward.
"""
self.go_to_page('Poll Functions')
answer_elements = self.browser.find_elements_by_css_selector('label.poll-answer')
answer_elements = self.browser.find_elements_by_css_selector(ANSWER_SELECTOR)
# 'Not very long'
answer_elements[1].click()
......@@ -88,7 +88,7 @@ class TestPollFunctions(PollBaseTest):
"""
self.go_to_page('Poll Functions')
answer_elements = self.browser.find_elements_by_css_selector('label.poll-answer')
answer_elements = self.browser.find_elements_by_css_selector(ANSWER_SELECTOR)
# Not very long
answer_elements[1].click()
......
......@@ -25,44 +25,49 @@
Test to make sure the layout for results is sane when taking images into
account.
"""
from ddt import ddt, unpack, data
from tests.integration.base_test import PollBaseTest
@ddt
class TestLayout(PollBaseTest):
"""
Do tests to verify that the layout of elements makes sense depeneding on
the number of images.
"""
def test_all_images(self):
@unpack
@data(('Poll All Pictures', 4), ('Poll One Picture', 4), ('Poll No Pictures', 0))
def test_images(self, scenario, count):
"""
Verify img tags are created for answers when they're all set.
Verify the poll-image divs only appear when they need to.
"""
self.go_to_page('Poll All Pictures')
self.go_to_page(scenario)
pics = self.browser.find_elements_by_css_selector('.poll-image')
self.assertEqual(len(pics), 4)
self.assertEqual(len(pics), count)
# Pics should be within labels.
pics[0].find_element_by_css_selector('img').click()
if not count:
self.browser.find_element_by_css_selector('.poll-answer-text').click()
else:
# Pics should be within labels.
self.browser.find_element_by_css_selector('.poll-image img').click()
self.get_submit().click()
self.wait_until_exists('.poll-image')
self.wait_until_exists('.percentage-gauge')
self.assertEqual(len(self.browser.find_elements_by_css_selector('.poll-image')), 4)
self.assertEqual(len(self.browser.find_elements_by_css_selector('.poll-image')), count)
def test_one_image(self):
"""
Verify layout is sane when only one answer has an image.
"""
self.go_to_page('Poll One Picture')
pics = self.browser.find_elements_by_css_selector('.poll-image')
# On the polling page, there should only be one pics div.
self.assertEqual(len(pics), 1)
pics[0].find_element_by_css_selector('img').click()
@data('Poll Size Check', 'Poll Size Check Image')
def test_poll_size(self, scenario):
self.go_to_page(scenario)
width = self.browser.get_window_size()['width']
poll = self.browser.find_element_by_css_selector('.poll-block')
self.assertLess(poll.get_attribute('width'), width)
self.browser.find_element_by_css_selector('.poll-answer-text').click()
self.get_submit().click()
self.wait_until_exists('.poll-image.result-image')
# ...But on the results page, we need four, for table layout.
self.assertEqual(len(self.browser.find_elements_by_css_selector('.poll-image')), 4)
self.wait_until_exists('.percentage-gauge')
poll = self.browser.find_element_by_css_selector('.poll-block')
self.assertLess(poll.get_attribute('width'), width)
\ No newline at end of file
<poll tally="{'red': 20, 'fennec': 29, 'kit': 15, 'arctic' : 35}"
question="## What is your favorite kind of fox?"
answers='[["red", {"label": "Red Fox", "img": null}], ["fennec", {"label": "Fennec Fox", "img": null}], ["kit", {"label": "Kit Fox", "img": null}], ["arctic", {"label": "Arctic fox", "img": null}]]' />
<poll tally="{'red': 20, 'fennec': 29, 'kit': 15, 'arctic' : 35}"
question="## What is your favorite kind of fox?"
answers='[["red", {"label": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris sollicitudin tellus in urna porttitor vulputate. Fusce efficitur sit amet sem quis sagittis. Quisque eget volutpat ipsum. Cras augue tellus, venenatis sed lectus quis, pellentesque fringilla sem. Pellentesque urna tortor, sodales at sem ut, finibus sodales tellus. Nulla nec vestibulum nunc. Sed vel tempor est. Quisque nunc ligula, convallis at arcu et, elementum interdum nulla. Nulla tempor commodo varius. Nunc accumsan ex vel erat condimentum sagittis. Vivamus dictum leo ligula. Curabitur feugiat ultrices accumsan. Vivamus quis urna facilisis magna tincidunt tempor.", "img": null}], ["fennec", {"label": "Fennec Fox", "img": null}], ["kit", {"label": "Kit Fox", "img": null}], ["arctic", {"label": "Arctic fox", "img": null}]]' />
<poll tally="{'red': 20, 'fennec': 29, 'kit': 15, 'arctic' : 35}"
question="## What is your favorite kind of fox?"
answers='[["red", {"label": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris sollicitudin tellus in urna porttitor vulputate. Fusce efficitur sit amet sem quis sagittis. Quisque eget volutpat ipsum. Cras augue tellus, venenatis sed lectus quis, pellentesque fringilla sem. Pellentesque urna tortor, sodales at sem ut, finibus sodales tellus. Nulla nec vestibulum nunc. Sed vel tempor est. Quisque nunc ligula, convallis at arcu et, elementum interdum nulla. Nulla tempor commodo varius. Nunc accumsan ex vel erat condimentum sagittis. Vivamus dictum leo ligula. Curabitur feugiat ultrices accumsan. Vivamus quis urna facilisis magna tincidunt tempor.", "img": "../img/red_fox.png"}], ["fennec", {"label": "Fennec Fox", "img": null}], ["kit", {"label": "Kit Fox", "img": null}], ["arctic", {"label": "Arctic fox", "img": null}]]' />
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