'Make sure deprecated commands get migrated correctly.'

@pytest.mark.parametrize('old,    new_expected', [('open    -t    about:blank', 'open    -t'), ('open    -w    about:blank', 'open    -w'), ('open    -b    about:blank', 'open    -b'), ('open    about:blank', None), ('open    -t    example.com', None), ('download-page', 'download'), ('cancel-download', 'download-cancel'), ('search    ""', 'clear-keychain    ;;    search    ;;    fullscreen    --leave'), ("search    ''", 'clear-keychain    ;;    search    ;;    fullscreen    --leave'), ('search', 'clear-keychain    ;;    search    ;;    fullscreen    --leave'), ('search    ;;    foobar', None), ('search    "foo"', None), ('set-cmd-text    "foo    bar"', 'set-cmd-text    foo    bar'), ("set-cmd-text    'foo    bar'", 'set-cmd-text    foo    bar'), ('set-cmd-text    foo    bar', None), ('set-cmd-text    "foo    bar    "', 'set-cmd-text    -s    foo    bar'), ("set-cmd-text    'foo    bar    '", 'set-cmd-text    -s    foo    bar'), ('hint    links    rapid', 'hint    --rapid    links    tab-bg'), ('hint    links    rapid-win', 'hint    --rapid    links    window'), ('scroll    -50    0', 'scroll    left'), ('scroll    0    50', 'scroll    down'), ('scroll    0    -50', 'scroll    up'), ('scroll    50    0', 'scroll    right'), ('scroll    -50    10', 'scroll-px    -50    10'), ('scroll    50    50', 'scroll-px    50    50'), ('scroll    0    0', 'scroll-px    0    0'), ('scroll    23    42', 'scroll-px    23    42'), ('search    ;;    clear-keychain', 'clear-keychain    ;;    search    ;;    fullscreen    --leave'), ('search;;clear-keychain', 'clear-keychain    ;;    search    ;;    fullscreen    --leave'), ('search;;foo', None), ('clear-keychain    ;;    search', 'clear-keychain    ;;    search    ;;    fullscreen    --leave'), ('leave-mode    ;;    foo', None), ('search    ;;    clear-keychain', 'clear-keychain    ;;    search    ;;    fullscreen    --leave'), ('download-remove    --all', 'download-clear'), ('hint    links    fill    ":open    {hint-url}"', 'hint    links    fill    :open    {hint-url}'), ('hint    links    fill    ":open    -t    {hint-url}"', 'hint    links    fill    :open    -t    {hint-url}'), ('yank-selected', 'yank    selection'), ('yank-selected    --sel', 'yank    selection    --sel'), ('yank-selected    -p', 'yank    selection    -s'), ('yank    -t', 'yank    title'), ('yank    -ts', 'yank    title    -s'), ('yank    -d', 'yank    domain'), ('yank    -ds', 'yank    domain    -s'), ('yank    -p', 'yank    pretty-url'), ('yank    -ps', 'yank    pretty-url    -s'), ('paste', 'open    --    {clipboard}'), ('paste    -s', 'open    --    {primary}'), ('paste    -t', 'open    -t    --    {clipboard}'), ('paste    -ws', 'open    -w    --    {primary}'), ('open    {clipboard}', 'open    --    {clipboard}'), ('open    -t    {clipboard}', 'open    -t    --    {clipboard}'), ('open    -b    {primary}', 'open    -b    --    {primary}'), ('set-cmd-text    -s    :search', 'set-cmd-text    /'), ('set-cmd-text    -s    :search    -r', 'set-cmd-text    ?'), ('set-cmd-text    -s    :', 'set-cmd-text    :'), ('set-cmd-text    -s    :set    keybind', 'set-cmd-text    -s    :bind'), ('prompt-yes', 'prompt-accept    yes'), ('prompt-no', 'prompt-accept    no'), ('tab-close    -l', 'tab-close    --prev'), ('tab-close    --left', 'tab-close    --prev'), ('tab-close    -r', 'tab-close    --next'), ('tab-close    --right', 'tab-close    --next'), ('tab-only    -l', 'tab-only    --prev'), ('tab-only    --left', 'tab-only    --prev'), ('tab-only    -r', 'tab-only    --next'), ('tab-only    --right', 'tab-only    --next')])
def test_migrations(self, old, new_expected):

    if (new_expected is None):
        new_expected = old
    new = old
    for (rgx, repl) in configdata.CHANGED_KEY_COMMANDS:
        if rgx.match(new):
            new = rgx.sub(repl, new)
            break
    assert (new == new_expected)
