static-pages.py 1.46 KB
Newer Older
1 2 3 4
#pylint: disable=C0111
#pylint: disable=W0621

from lettuce import world, step
5
from nose.tools import assert_equal  # pylint: disable=E0611
6 7


8
@step(u'I go to the static pages page$')
9
def go_to_static(step):
10
    menu_css = 'li.nav-course-courseware'
11
    static_css = 'li.nav-course-courseware-pages a'
12 13
    world.css_click(menu_css)
    world.css_click(static_css)
14 15


16
@step(u'I add a new page$')
17
def add_page(step):
18
    button_css = 'a.new-button'
19
    world.css_click(button_css)
20 21


22 23 24 25 26
@step(u'I should see a static page named "([^"]*)"$')
def see_a_static_page_named_foo(step, name):
    pages_css = 'section.xmodule_StaticTabModule'
    page_name_html = world.css_html(pages_css)
    assert_equal(page_name_html, '\n    {name}\n'.format(name=name))
27

28

29 30 31 32
@step(u'I should not see any static pages$')
def not_see_any_static_pages(step):
    pages_css = 'section.xmodule_StaticTabModule'
    assert (world.is_css_not_present(pages_css, wait_time=30))
33

34

35 36 37 38
@step(u'I "(edit|delete)" the static page$')
def click_edit_or_delete(step, edit_or_delete):
    button_css = 'div.component-actions a.%s-button' % edit_or_delete
    world.css_click(button_css)
39 40 41


@step(u'I change the name to "([^"]*)"$')
42
def change_name(step, new_name):
43
    settings_css = '#settings-mode a'
44
    world.css_click(settings_css)
45
    input_css = 'input.setting-input'
46 47 48
    world.css_fill(input_css, new_name)
    if world.is_firefox():
        world.trigger_event(input_css)
49
    save_button = 'a.save-button'
50
    world.css_click(save_button)