Exemplo n.º 1
0
def test_edit_command_no_editor():
    """
    check that `keeper edit <filename>` command will raise RuntimeError without available editors
    """
    sys.argv = ["keeper", "edit", "main"]
    settings.EDITOR = 'auto'
    settings.POSSIBLE_EDITORS = []

    with pytest.raises(RuntimeError):
        main.main()
Exemplo n.º 2
0
def test_edit_command_w_filenames(os_system):
    """
    check that `keeper edit <filename>` command will open `~/.keeper/<filename>.todo` file
    """
    sys.argv = ["keeper", "edit", "main", "test"]
    homedir = os.path.expanduser('~')
    settings.EDITOR = 'testeditor'
    main.main()
    os_system.assert_called_once_with('testeditor hotexamples_com/.keeper/main.todo hotexamples_com/.keeper/test.todo'\
                                      .format(**locals()))
Exemplo n.º 3
0
def test_edit_command_default(os_system):
    """
    check that `keeper edit` command will open all `~/.keeper/*.todo` files
    """
    sys.argv = ["keeper", "edit"]
    homedir = os.path.expanduser('~')
    settings.EDITOR = 'testeditor'
    main.main()
    os_system.assert_called_once_with(
        'testeditor hotexamples_com/.keeper/*.todo'.format(**locals()))
Exemplo n.º 4
0
def test_edit_command_w_autoeditor(os_system):
    """
    check that `keeper edit <filename>` will use first of `settings.POSSIBLE_EDITORS` editors
    when `settings.EDITOR = 'auto'`
    """
    settings.EDITOR = 'auto'
    sys.argv = ["keeper", "edit", "main"]
    homedir = os.path.expanduser('~')
    default_editor = settings.POSSIBLE_EDITORS[0]
    main.main()
    os_system.assert_called_once_with(
        '{default_editor} hotexamples_com/.keeper/main.todo'.format(**locals()))