Example #1
0
def test_parse_command():
    """ Test screenshot._parse_command() function.

    Tests cases where the command completes successfully. Cases in which
    exceptions are raised are handled separately.
    """
    # Test 'click' action with no options.
    arg_str = 'selector click'
    expected_output = {'selector': 'selector', 'action': 'click', 'options': []}
    actual_output = screenshot._parse_command(arg_str)
    assert_equal(expected_output, actual_output)

    # Test 'submit' action with no options.
    arg_str = 'selector submit'
    expected_output = {'selector': 'selector', 'action': 'submit', 'options': []}
    actual_output = screenshot._parse_command(arg_str)
    assert_equal(expected_output, actual_output)

    # Test 'send_keys' action with no options.
    arg_str = 'selector send_keys'
    expected_output = {'selector': 'selector', 'action': 'send_keys', 'options': []}
    actual_output = screenshot._parse_command(arg_str)
    assert_equal(expected_output, actual_output)

    # Test 'send_keys' action with few options.
    arg_str = 'selector send_keys keystroke1 keystroke2'
    expected_output = {'selector': 'selector', 'action': 'send_keys', 'options': ['keystroke1', 'keystroke2']}
    actual_output = screenshot._parse_command(arg_str)
    assert_equal(expected_output, actual_output)
Example #2
0
def test_parse_command_option_error():
    """ Test OptionError(s) raised by screenshot._parse_command() function.
    """
    # Test 'click' action with options, should thrown an exception.
    arg_str = 'selector click options'
    screenshot._parse_command(arg_str)

    # Test 'submit' action with options, should thrown an exception.
    arg_str = 'selector click options'
    screenshot._parse_command(arg_str)
Example #3
0
def test_parse_command_action_error():
    """ Test ActionError(s) raised by screenshot._parse_command() function.
    """
    # Test with an invalid action, should thrown an exception.
    arg_str = 'selector invalid_action'
    screenshot._parse_command(arg_str)