Commit de80f892 by Andy Armstrong Committed by cahrens

Clean up coverage and code quality issues

parent e20a7fc5
...@@ -124,14 +124,19 @@ class ContainerViewTestCase(CourseTestCase): ...@@ -124,14 +124,19 @@ class ContainerViewTestCase(CourseTestCase):
Verify that an xblock returns the expected HTML for a container preview Verify that an xblock returns the expected HTML for a container preview
""" """
# First verify that the behavior is correct with a published container # First verify that the behavior is correct with a published container
self._test_preview_html(self.vertical)
self._test_preview_html(self.child_vertical) self._test_preview_html(self.child_vertical)
# Now make the unit and its children into a draft and validate the preview again # Now make the unit and its children into a draft and validate the preview again
modulestore('draft').convert_to_draft(self.vertical.location) draft_unit = modulestore('draft').convert_to_draft(self.vertical.location)
draft_container = modulestore('draft').convert_to_draft(self.child_vertical.location) draft_container = modulestore('draft').convert_to_draft(self.child_vertical.location)
self._test_preview_html(draft_unit)
self._test_preview_html(draft_container) self._test_preview_html(draft_container)
def _test_preview_html(self, xblock): def _test_preview_html(self, xblock):
"""
Verify that the specified xblock has the expected HTML elements for container preview
"""
locator = loc_mapper().translate_location(self.course.id, xblock.location, published=False) locator = loc_mapper().translate_location(self.course.id, xblock.location, published=False)
publish_state = compute_publish_state(xblock) publish_state = compute_publish_state(xblock)
preview_url = '/xblock/{locator}/container_preview'.format(locator=locator) preview_url = '/xblock/{locator}/container_preview'.format(locator=locator)
......
...@@ -4,6 +4,7 @@ import json ...@@ -4,6 +4,7 @@ import json
from contentstore.views import tabs from contentstore.views import tabs
from contentstore.tests.utils import CourseTestCase from contentstore.tests.utils import CourseTestCase
from django.test import TestCase from django.test import TestCase
from xmodule.modulestore.django import loc_mapper
from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory
from courseware.courses import get_course_by_id from courseware.courses import get_course_by_id
from xmodule.tabs import CourseTabList, WikiTab from xmodule.tabs import CourseTabList, WikiTab
...@@ -22,7 +23,7 @@ class TabsPageTests(CourseTestCase): ...@@ -22,7 +23,7 @@ class TabsPageTests(CourseTestCase):
self.url = self.course_locator.url_reverse('tabs') self.url = self.course_locator.url_reverse('tabs')
# add a static tab to the course, for code coverage # add a static tab to the course, for code coverage
ItemFactory.create( self.test_tab = ItemFactory.create(
parent_location=self.course_location, parent_location=self.course_location,
category="static_tab", category="static_tab",
display_name="Static_1" display_name="Static_1"
...@@ -172,6 +173,25 @@ class TabsPageTests(CourseTestCase): ...@@ -172,6 +173,25 @@ class TabsPageTests(CourseTestCase):
) )
self.check_invalid_tab_id_response(resp) self.check_invalid_tab_id_response(resp)
def test_tab_preview_html(self):
"""
Verify that the static tab renders itself with the correct HTML
"""
locator = loc_mapper().translate_location(self.course.id, self.test_tab.location)
preview_url = '/xblock/{locator}/student_view'.format(locator=locator)
resp = self.client.get(preview_url, HTTP_ACCEPT='application/json')
self.assertEqual(resp.status_code, 200)
resp_content = json.loads(resp.content)
html = resp_content['html']
# Verify that the HTML contains the expected elements
self.assertIn('<span class="action-button-text">Edit</span>', html)
self.assertIn('<span class="sr">Duplicate this component</span>', html)
self.assertIn('<span class="sr">Delete this component</span>', html)
self.assertIn('<span data-tooltip="Drag to reorder" class="drag-handle"></span>', html)
class PrimitiveTabEdit(TestCase): class PrimitiveTabEdit(TestCase):
"""Tests for the primitive tab edit data manipulations""" """Tests for the primitive tab edit data manipulations"""
......
...@@ -8,7 +8,7 @@ define([ "jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/view_helpers ...@@ -8,7 +8,7 @@ define([ "jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/view_helpers
describe("Supports reordering components", function () { describe("Supports reordering components", function () {
var model, containerView, mockContainerHTML, respondWithMockXBlockFragment, init, getComponent, var model, containerView, mockContainerHTML, respondWithMockXBlockFragment, init, getComponent,
getDragHandle, dragComponentVertically, dragComponentToY, dragComponentAbove, dragComponentBelow, getDragHandle, dragComponentVertically, dragComponentToY, dragComponentAbove,
verifyRequest, verifyNumReorderCalls, respondToRequest, verifyRequest, verifyNumReorderCalls, respondToRequest,
rootLocator = 'testCourse/branch/draft/split_test/splitFFF', rootLocator = 'testCourse/branch/draft/split_test/splitFFF',
...@@ -93,11 +93,6 @@ define([ "jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/view_helpers ...@@ -93,11 +93,6 @@ define([ "jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/view_helpers
dragComponentToY(sourceLocator, targetElement.offset().top + 1); dragComponentToY(sourceLocator, targetElement.offset().top + 1);
}; };
dragComponentBelow = function (sourceLocator, targetLocator) {
var targetElement = containerView.$('[data-locator="' + targetLocator + '"]');
dragComponentToY(sourceLocator, targetElement.offset().top + targetElement.height() - 1);
};
verifyRequest = function (requests, reorderCallIndex, expectedURL, expectedChildren) { verifyRequest = function (requests, reorderCallIndex, expectedURL, expectedChildren) {
var actualIndex, request, children, i; var actualIndex, request, children, i;
// 0th call is the response to the initial render call to get HTML. // 0th call is the response to the initial render call to get HTML.
......
...@@ -59,7 +59,7 @@ class ContainerPage(PageObject): ...@@ -59,7 +59,7 @@ class ContainerPage(PageObject):
action = ActionChains(self.browser) action = ActionChains(self.browser)
action.click_and_hold(source).perform() # pylint: disable=protected-access action.click_and_hold(source).perform() # pylint: disable=protected-access
action.move_to_element_with_offset( action.move_to_element_with_offset(
target, 0, target.size['height']/2 if after else 0 target, 0, target.size['height'] / 2 if after else 0
).perform() # pylint: disable=protected-access ).perform() # pylint: disable=protected-access
action.release().perform() action.release().perform()
# TODO: should wait for "Saving" to go away so we know the operation is complete? # TODO: should wait for "Saving" to go away so we know the operation is complete?
......
...@@ -10,6 +10,7 @@ from ..pages.studio.overview import CourseOutlinePage ...@@ -10,6 +10,7 @@ from ..pages.studio.overview import CourseOutlinePage
from ..pages.xblock.acid import AcidView from ..pages.xblock.acid import AcidView
from ..fixtures.course import CourseFixture, XBlockFixtureDesc from ..fixtures.course import CourseFixture, XBlockFixtureDesc
class XBlockAcidBase(WebAppTest): class XBlockAcidBase(WebAppTest):
""" """
Base class for tests that verify that XBlock integration is working correctly Base class for tests that verify that XBlock integration is working correctly
......
...@@ -131,11 +131,11 @@ class DiscussionPreviewTest(UniqueCourseTest): ...@@ -131,11 +131,11 @@ class DiscussionPreviewTest(UniqueCourseTest):
AutoAuthPage(self.browser, staff=True).visit() AutoAuthPage(self.browser, staff=True).visit()
cop = CourseOutlinePage( cop = CourseOutlinePage(
self.browser, self.browser,
self.course_info['org'], self.course_info['org'],
self.course_info['number'], self.course_info['number'],
self.course_info['run'] self.course_info['run']
) )
cop.visit() cop.visit()
self.unit = cop.section('Test Section').subsection('Test Subsection').toggle_expand().unit('Test Unit') self.unit = cop.section('Test Section').subsection('Test Subsection').toggle_expand().unit('Test Unit')
self.unit.go_to() self.unit.go_to()
......
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