Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
topydo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
topydo
Commits
f6a38845
Commit
f6a38845
authored
Feb 10, 2017
by
Bram Schoenmakers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for editor selection
parent
16f397f1
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
88 additions
and
6 deletions
+88
-6
test/test_edit_command.py
test/test_edit_command.py
+88
-6
No files found.
test/test_edit_command.py
View file @
f6a38845
...
...
@@ -162,13 +162,12 @@ class EditCommandTest(CommandTest):
self
.
assertEqual
(
self
.
output
,
expected
)
self
.
assertEqual
(
self
.
todolist
.
print_todos
(),
u"Foo id:1
\
n
Fo
\
u00f3
B
\
u0105
\
u017a
\
n
Lazy Cat
\
n
Lazy Dog"
)
@
mock
.
patch
.
dict
(
os
.
environ
,
{
'EDITOR'
:
'vi'
})
@
mock
.
patch
(
'topydo.commands.EditCommand.check_call'
)
def
test_edit_archive
(
self
,
mock_call
):
""" Edit archive file. """
mock_call
.
return_value
=
0
editor
=
'vi'
os
.
environ
[
'EDITOR'
]
=
editor
archive
=
config
().
archive
()
command
=
EditCommand
([
"-d"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
...
...
@@ -176,15 +175,14 @@ class EditCommandTest(CommandTest):
command
.
execute
()
self
.
assertEqual
(
self
.
errors
,
""
)
mock_call
.
assert_called_once_with
([
editor
,
archive
])
mock_call
.
assert_called_once_with
([
'vi'
,
archive
])
@
mock
.
patch
.
dict
(
os
.
environ
,
{
'EDITOR'
:
'vi'
})
@
mock
.
patch
(
'topydo.commands.EditCommand.check_call'
)
def
test_edit_todotxt
(
self
,
mock_call
):
""" Edit todo file. """
mock_call
.
return_value
=
0
editor
=
'vi'
os
.
environ
[
'EDITOR'
]
=
editor
todotxt
=
config
().
todotxt
()
result
=
self
.
todolist
.
print_todos
()
# copy TodoList content *before* executing command
...
...
@@ -194,7 +192,91 @@ class EditCommandTest(CommandTest):
self
.
assertEqual
(
self
.
errors
,
""
)
self
.
assertEqual
(
self
.
todolist
.
print_todos
(),
result
)
mock_call
.
assert_called_once_with
([
editor
,
todotxt
])
mock_call
.
assert_called_once_with
([
'vi'
,
todotxt
])
@
mock
.
patch
.
dict
(
os
.
environ
,
{
'EDITOR'
:
'vi'
})
@
mock
.
patch
.
dict
(
os
.
environ
,
{
'TOPYDO_EDITOR'
:
'nano'
})
@
mock
.
patch
(
'topydo.commands.EditCommand.check_call'
)
def
test_edit_editor1
(
self
,
mock_call
):
""" $TOPYDO_EDITOR overrides $EDITOR """
mock_call
.
return_value
=
0
todotxt
=
config
().
todotxt
()
command
=
EditCommand
([],
self
.
todolist
,
self
.
out
,
self
.
error
,
None
)
command
.
execute
()
self
.
assertEqual
(
self
.
errors
,
""
)
mock_call
.
assert_called_once_with
([
'nano'
,
todotxt
])
@
mock
.
patch
.
dict
(
os
.
environ
,
{
'EDITOR'
:
'vi'
})
@
mock
.
patch
.
dict
(
os
.
environ
,
{
'TOPYDO_EDITOR'
:
'nano'
})
@
mock
.
patch
(
'topydo.commands.EditCommand.check_call'
)
def
test_edit_editor2
(
self
,
mock_call
):
""" $TOPYDO_EDITOR overrides $EDITOR """
mock_call
.
return_value
=
0
todotxt
=
config
().
todotxt
()
command
=
EditCommand
([],
self
.
todolist
,
self
.
out
,
self
.
error
,
None
)
command
.
execute
()
self
.
assertEqual
(
self
.
errors
,
""
)
mock_call
.
assert_called_once_with
([
'nano'
,
todotxt
])
@
mock
.
patch
.
dict
(
os
.
environ
,
{
'EDITOR'
:
'vi'
})
@
mock
.
patch
.
dict
(
os
.
environ
,
{
'TOPYDO_EDITOR'
:
'nano'
})
@
mock
.
patch
(
'topydo.commands.EditCommand.check_call'
)
def
test_edit_editor3
(
self
,
mock_call
):
""" Editor on commandline overrides $TOPYDO_EDITOR """
mock_call
.
return_value
=
0
command
=
EditCommand
([
"-E"
,
"foo"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
None
)
command
.
execute
()
self
.
assertEqual
(
self
.
errors
,
""
)
mock_call
.
assert_called_once_with
([
'foo'
,
config
().
todotxt
()])
@
mock
.
patch
.
dict
(
os
.
environ
,
{
'EDITOR'
:
'vi'
})
@
mock
.
patch
.
dict
(
os
.
environ
,
{
'TOPYDO_EDITOR'
:
'nano'
})
@
mock
.
patch
(
'topydo.commands.EditCommand.check_call'
)
def
test_edit_editor4
(
self
,
mock_call
):
""" Editor in configuration file is overridden by $TOPYDO_EDITOR """
mock_call
.
return_value
=
0
config
(
p_overrides
=
{(
'edit'
,
'editor'
):
'foo'
})
command
=
EditCommand
([],
self
.
todolist
,
self
.
out
,
self
.
error
,
None
)
command
.
execute
()
self
.
assertEqual
(
self
.
errors
,
""
)
mock_call
.
assert_called_once_with
([
'nano'
,
config
().
todotxt
()])
@
mock
.
patch
.
dict
(
os
.
environ
,
{
'EDITOR'
:
'vi'
})
@
mock
.
patch
(
'topydo.commands.EditCommand.check_call'
)
def
test_edit_editor5
(
self
,
mock_call
):
""" Editor in configuration file overrides $EDITOR """
mock_call
.
return_value
=
0
config
(
p_overrides
=
{(
'edit'
,
'editor'
):
'foo'
})
command
=
EditCommand
([],
self
.
todolist
,
self
.
out
,
self
.
error
,
None
)
command
.
execute
()
self
.
assertEqual
(
self
.
errors
,
""
)
mock_call
.
assert_called_once_with
([
'foo'
,
config
().
todotxt
()])
@
mock
.
patch
.
dict
(
os
.
environ
,
{
'EDITOR'
:
''
})
@
mock
.
patch
(
'topydo.commands.EditCommand.check_call'
)
def
test_edit_editor6
(
self
,
mock_call
):
""" Ultimate fallback is vi """
mock_call
.
return_value
=
0
command
=
EditCommand
([],
self
.
todolist
,
self
.
out
,
self
.
error
,
None
)
command
.
execute
()
self
.
assertEqual
(
self
.
errors
,
""
)
mock_call
.
assert_called_once_with
([
'vi'
,
config
().
todotxt
()])
def
test_help
(
self
):
command
=
EditCommand
([
"help"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment