Exemple #1
0
def test_check_classes_added_for_images(web_fixture):
    """A Widget can be supplied to be used caption for an added image."""
    carousel = Carousel(web_fixture.view, 'my_carousel_id')

    img_widget = Img(web_fixture.view)
    carousel.add_slide(img_widget)
    assert img_widget.get_attribute('class') == 'd-block w-100'
Exemple #2
0
def test_active_state_of_items(web_fixture, carousel_fixture):
    """The first item added is marked as active, and also its corresponding indicator."""

    fixture = carousel_fixture

    carousel = Carousel(web_fixture.view, 'my_carousel_id')
    carousel.add_slide(Img(web_fixture.view))
    carousel.add_slide(Img(web_fixture.view))

    main_div = fixture.get_main_div_for(carousel)
    [indicator_list, carousel_inner, left_control,
     right_control] = main_div.children

    #only the first item is active
    [carousel_item_1, carousel_item_2] = carousel_inner.children
    assert carousel_item_1.get_attribute('class') == 'active carousel-item'
    assert carousel_item_2.get_attribute('class') == 'carousel-item'

    #only the first indicator is active
    [indicator_0, indicator_1] = fixture.get_indicator_list_for(carousel)

    assert indicator_0.get_attribute('class') == 'active'
    assert not indicator_1.has_attribute('class')
    assert indicator_0.get_attribute('data-slide-to') == '0'
    assert indicator_1.get_attribute('data-slide-to') == '1'
Exemple #3
0
def test_adding_items_to_carousel(web_fixture, carousel_fixture):
    """Images can be added to a Carousel."""

    fixture = carousel_fixture

    carousel = Carousel(web_fixture.view,
                        'my_carousel_id',
                        show_indicators=True)
    main_div = fixture.get_main_div_for(carousel)
    [indicator_list, carousel_inner, left_control,
     right_control] = main_div.children

    # Initially, no items or indicators are present
    assert carousel_inner.children == []
    assert fixture.carousel_indicators_present(carousel)
    assert fixture.get_indicator_list_for(carousel) == []

    image = Img(web_fixture.view)
    added_item = carousel.add_slide(image)

    # A carousel item was added for the image
    [carousel_item] = carousel_inner.children
    assert carousel_item is added_item
    assert 'carousel-item' in carousel_item.get_attribute('class')

    [actual_image] = carousel_item.children
    assert actual_image is image

    # An indicator was added for the item
    [indicator] = fixture.get_indicator_list_for(carousel)

    assert indicator.get_attribute('data-target') == '#my_carousel_id'
    assert indicator.get_attribute('data-slide-to') == '0'
Exemple #4
0
def item_indicators_are_optional(fixture):
    """With show_indicators=False, indicators are not added when adding items."""
    carousel = Carousel(fixture.view, 'my_carousel_id', show_indicators=False)

    vassert(not fixture.carousel_indicators_present(carousel))

    carousel.add_slide(Img(fixture.view))

    #after adding the item, indicators shouldn't appear
    vassert(not fixture.carousel_indicators_present(carousel))
Exemple #5
0
def test_item_indicators_are_optional(web_fixture, carousel_fixture):
    """With show_indicators=False, indicators are not added when adding items."""
    fixture = carousel_fixture

    carousel = Carousel(web_fixture.view, 'my_carousel_id', show_indicators=False)

    assert not fixture.carousel_indicators_present(carousel)

    carousel.add_slide(Img(web_fixture.view))

    #after adding the item, indicators shouldn't appear
    assert not fixture.carousel_indicators_present(carousel)
Exemple #6
0
def test_adding_items_with_captions(web_fixture):
    """A Widget can be supplied to be used caption for an added image."""

    carousel = Carousel(web_fixture.view, 'my_carousel_id')

    caption_widget = Widget(web_fixture.view)
    carousel_item = carousel.add_slide(Img(web_fixture.view), caption_widget=caption_widget)

    [image, div_containing_caption] = carousel_item.children
    assert div_containing_caption.get_attribute('class') == 'carousel-caption'

    [actual_caption_widget] = div_containing_caption.children
    assert actual_caption_widget is caption_widget