test_unit_page.py 2.71 KB
Newer Older
1 2 3 4 5 6 7
"""
Unit tests for the unit page.
"""

from contentstore.views.tests.utils import StudioPageTestCase
from xmodule.modulestore.django import modulestore
from xmodule.modulestore.tests.factories import ItemFactory
8
from xmodule.x_module import STUDENT_VIEW
9 10 11 12 13 14 15 16 17 18 19 20 21


class UnitPageTestCase(StudioPageTestCase):
    """
    Unit tests for the unit page.
    """

    def setUp(self):
        super(UnitPageTestCase, self).setUp()
        self.vertical = ItemFactory.create(parent_location=self.sequential.location,
                                           category='vertical', display_name='Unit')
        self.video = ItemFactory.create(parent_location=self.vertical.location,
                                        category="video", display_name="My Video")
22
        self.store = modulestore()
23 24 25 26 27

    def test_public_component_preview_html(self):
        """
        Verify that a public xblock's preview returns the expected HTML.
        """
28
        published_video = self.store.publish(self.video.location, self.user.id)
29
        self.validate_preview_html(self.video, STUDENT_VIEW, can_add=False)
30 31 32 33 34

    def test_draft_component_preview_html(self):
        """
        Verify that a draft xblock's preview returns the expected HTML.
        """
35
        self.validate_preview_html(self.video, STUDENT_VIEW, can_add=False)
36 37 38 39 40 41 42 43 44 45

    def test_public_child_container_preview_html(self):
        """
        Verify that a public child container rendering on the unit page (which shows a View arrow
        to the container page) returns the expected HTML.
        """
        child_container = ItemFactory.create(parent_location=self.vertical.location,
                                             category='split_test', display_name='Split Test')
        ItemFactory.create(parent_location=child_container.location,
                           category='html', display_name='grandchild')
46
        published_child_container = self.store.publish(child_container.location, self.user.id)
47
        self.validate_preview_html(published_child_container, STUDENT_VIEW, can_add=False)
48 49 50 51 52 53 54 55 56 57

    def test_draft_child_container_preview_html(self):
        """
        Verify that a draft child container rendering on the unit page (which shows a View arrow
        to the container page) returns the expected HTML.
        """
        child_container = ItemFactory.create(parent_location=self.vertical.location,
                                             category='split_test', display_name='Split Test')
        ItemFactory.create(parent_location=child_container.location,
                           category='html', display_name='grandchild')
58
        draft_child_container = self.store.get_item(child_container.location)
59
        self.validate_preview_html(draft_child_container, STUDENT_VIEW, can_add=False)