1from scenarios import *
2
3scenario = (
4    # Configure the throttle option with an incorrect value
5    send_stanza("<iq type='set' id='id1' from='{jid_one}/{resource_one}' to='{irc_server_one}'><command xmlns='http://jabber.org/protocol/commands' node='configure' action='execute' /></iq>"),
6    expect_stanza("/iq[@type='result']",
7                  after = save_value("sessionid", extract_attribute("/iq[@type='result']/commands:command[@node='configure']", "sessionid"))),
8    send_stanza("<iq type='set' id='id2' from='{jid_one}/{resource_one}' to='{irc_server_one}'>"
9                "<command xmlns='http://jabber.org/protocol/commands' node='configure' sessionid='{sessionid}' action='next'>"
10                "<x xmlns='jabber:x:data' type='submit'>"
11                "<field var='throttle_limit'><value>bleh</value></field>"
12                "<field var='max_history_length'><value>bleh</value></field>"
13                "</x></command></iq>"),
14    expect_stanza("/iq[@type='result']/commands:command[@node='configure'][@status='completed']"),
15
16    # These options should have their default value
17    send_stanza("<iq type='set' id='id2' from='{jid_one}/{resource_one}' to='{irc_server_one}'><command xmlns='http://jabber.org/protocol/commands' node='configure' action='execute' /></iq>"),
18    expect_stanza("/iq[@type='result']",
19                  "/iq/commands:command/dataform:x[@type='form']/dataform:field[@type='text-single'][@var='throttle_limit']/dataform:value[text()='10']",
20                  "/iq/commands:command/dataform:x[@type='form']/dataform:field[@type='text-single'][@var='max_history_length']/dataform:value[text()='20']"),
21)
22