Commit bbace860 authored by Jacek Sowiński's avatar Jacek Sowiński

Merge branch 'master' into column-ui

parents 393d4d03 0c7a3aa3
[run]
source = topydo
branch = True
[report]
exclude_lines =
......@@ -11,5 +12,5 @@ exclude_lines =
if __name__ == .__main__.:
omit =
topydo/lib/ExitCommand.py
topydo/commands/ExitCommand.py
topydo/lib/Version.py
*.pyc
*.py[cod]
*.sw?
install
.coverage
......@@ -11,6 +11,7 @@ build/
develop-eggs/
dist/
eggs/
htmlcov/
lib/
lib64/
parts/
......@@ -19,6 +20,9 @@ var/
*.egg-info/
.installed.cfg
*.egg
.eggs/
# Sublime Text
*.sublime-*
!/topydo/lib/
sudo: false # run on new infrastructure
language: python
python:
- "2.7"
- "3.2"
- "3.3"
- "3.4"
- "3.5"
- "pypy3"
install:
- "python -m pip install pip --upgrade"
- "pip install ."
- "pip install urwid"
- "pip install icalendar"
- "pip install .[ical]"
- "pip install .[prompt-toolkit]"
- "pip install .[test]"
- "pip install pylint"
script: "./run-tests.sh"
- "pip install codecov"
script:
- "green -vvr"
- "python -m pylint --errors-only topydo test"
# Cache Dependencies
after_script:
- codecov
cache:
directories:
- $HOME/travis/.cache/pip
......
Main author / maintainer: Bram Schoenmakers (@bram85)
For a list of contributors, please refer to the Contributors page on
[Github](https://github.com/bram85/topydo/graphs/contributors).
0.9
---
* Dropped support for Python 2.7.
* Add ability to filter on creation/completion dates:
topydo ls created:today
topydo ls completed:today
topydo -t done.txt completed:today # if auto-archiving is set
* `ls -F` supports `%P` that expands to a single space when no priority is set,
in contrast to `%p` which expands to an empty string (thanks to @MinchinWeb).
* `ls -N` prints enough todo items such that it fits on one screen (thanks to
@MinchinWeb).
* Aliases can have a `{}` placeholder which is substituted with the alias'
arguments (thanks to @mruwek).
* `pri` accepts priorities in lowercase (thanks to @MinchinWeb).
* Several bugfixes for `dep gc`.
* Various test/CI improvements.
0.8
---
* `do -d` understands relative dates.
* Introduced `yesterday` as a relative date (abbrev. `yes`).
* `tag` command understands relative dates when setting due or t tags.
* Fix install of wheels (unnecessarily installed dependencies). Issue #79.
* Bugfix: the negation of ordinal tag filters did not work.
* Some improvements in test coverage (a.o. thanks to @mruwek).
0.7
---
A big release with many new features. Many thanks to Jacek Sowiński (@mruwek)
for the majority of these new features.
* `ls` output can be customized with a -F flag or a configuration option:
[ls]
list_format = |%I| %x %{(}p{)} %c %s %k %{due:}d %{t:}t
or `ls -F "%{(}p{)} %s %{due:}d"`.
See `help ls` for all placeholders. Each placeholder can optionally be
surrounded by optional texts that are only printed when the placeholder is
expanded to a value.
The format string may contain a tab character: all text that follows is
aligned to the right.
(thanks to @mruwek)
* New subcommand: `revert`. Revert the last executed command(s). The number of
revisions can be tuned in the configuration file:
[topydo]
backup_count = 25
Set to 0 to disable this feature. (thanks to @mruwek)
* New feature: aliases. Aliases can be defined in the configuration file:
[aliases]
showall = ls -x
(thanks to @mruwek)
* Filter based on priorities (thanks to @mruwek)
ls (A)
ls (<A)
* `ls` has a `-n` flag to limit the number of todo items (similar to the
list_limit option in the configuration file:
ls -n 5
* `ls` has a `-i` flag to select displaying todo items based on their ID. This
can be useful to have a 'clean' default view, and to gather more details for
a certain todo item using aliases and formatting.
* Prompt mode no longer warns about background modifications to todo.txt when a
read-only command is entered (e.g. `ls`).
* Removed restriction in `edit` mode that requires keeping the same amount of
lines in the todo.txt file.
* `edit` only processes the todo items when edits were actually made in the
editor (thanks to @mruwek)
* When entering today's day of the week as a relative date, it will use next
week's date instead of today.
* Bugfix: not all tags were properly hidden with the `hide_tags` configuration
option.
* Better PEP8 compliance (thanks to @MinchinWeb)
* Various test/CI improvements (thanks to @MinchinWeb)
* Support for Python 3.2 removed.
* Many other minor improvements (a.o. thanks to @MinchinWeb)
0.6
---
......@@ -16,7 +113,9 @@
---
* Remove 'ical' subcommand in favor of 'topydo ls -f ical'
* Remove options highlight_projects_colors in favor of colorscheme options. In case you wish to disable the project/context colors, assign an empty value in the configuration file:
* Remove options highlight_projects_colors in favor of colorscheme options. In
case you wish to disable the project/context colors, assign an empty value in
the configuration file:
[colorscheme]
project_color =
......
......@@ -5,11 +5,9 @@ smoothly into topydo.
### General
* This Github page defaults to the **stable** branch which is for **bug fixes
only**. If you would like to add a new feature, make sure to make a Pull
Request on the `master` branch.
* Use descriptive commit messages.
* Use descriptive commit messages. The post
[How to write a commit message](http://chris.beams.io/posts/git-commit/) by
Chris Beams has some good guidelines.
### Coding style
......@@ -17,37 +15,63 @@ smoothly into topydo.
possible. I won't be very picky about long lines, but please try to avoid
them.
* I strongly prefer simple and short functions, doing only one thing. I'll
request you to refactor functions with massive indentation or don't fit
ask you to refactor functions with massive indentation or don't fit
otherwise on a screen.
### Testing
* Run tests with:
* First make sure to have the prerequisites installed to perform the tests:
pip install .[test]
./run-tests.sh [python2|python3]
* Then, run the tests with:
green -r
Obviously, I won't accept anything that makes the tests fail. When you submit
a Pull Request, Travis CI will automatically run all tests for various Python
versions, but it's better if you run the tests locally first.
* Travis CI will also run `pylint` and fail when new errors are introduced. You
may want to add a `pre-push` script to your topydo clone before pushing to
Github (.git/hooks/pre-push):
#!/bin/sh
remote="$1"
if [ $remote = "origin" ]; then
if ! green; then
exit 1
fi
if ! python2 -m pylint --errors-only topydo test; then
exit 1
fi
if ! python3 -m pylint --errors-only topydo test; then
exit 1
fi
fi
exit 0
Make sure to run `chmod +x .git/hooks/pre-push` to activate the hook.
Make sure you have the `mock` package installed if you test on a Python
version older than 3.3.
* Add tests for your change(s):
* Bugfixes: add a testcase that covers your bugfix, so the bug won't happen
* Bugfixes: add a test case that covers your bugfix, so the bug won't happen
ever again.
* Features: add testcases that checks various inputs and outputs of your
* Features: add test cases that checks various inputs and outputs of your
feature. Be creative in trying to break the feature you've just implemented.
* Check the test coverage of your contributed code, in particular if you
touched code in the topydo.lib or topydo.command packages:
* Check the test coverage of your contributed code, in particular if you touched
code in the topydo.lib or topydo.command packages:
pip install coverage
coverage run setup.py test
coverage report
coverage report -m
Or alternatively, for a more friendly output, run:
coverage html
Which will generate annotated files in the *htmlcov* folder. The new code
which will generate annotated files in the *htmlcov* folder. The new code
should be marked green (i.e. covered).
When you create a Pull Request, code coverage will be automatically checked
and reported by [Codecov.io](https://codecov.io/github/bram85/topydo).
topydo
======
[![Build Status](https://travis-ci.org/bram85/topydo.svg?branch=master)](https://travis-ci.org/bram85/topydo) [![Join the chat at https://gitter.im/bram85/topydo](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/bram85/topydo?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Flattr this git repo](http://api.flattr.com/button/flattr-badge-large.png)](https://flattr.com/submit/auto?user_id=bram85&url=https://github.com/bram85/topydo&title=topydo&language=&tags=github&category=software)
[![Build Status](https://travis-ci.org/bram85/topydo.svg?branch=master)](https://travis-ci.org/bram85/topydo) [![codecov.io](https://codecov.io/github/bram85/topydo/coverage.svg?branch=master)](https://codecov.io/github/bram85/topydo?branch=master) [![Join the chat at https://gitter.im/bram85/topydo](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/bram85/topydo?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Flattr this git repo](http://api.flattr.com/button/flattr-badge-large.png)](https://flattr.com/submit/auto?user_id=bram85&url=https://github.com/bram85/topydo&title=topydo&language=&tags=github&category=software)
topydo is a todo list application using the [todo.txt format][1]. It is heavily
inspired by the [todo.txt CLI][2] by Gina Trapani. This tool is actually a
......@@ -28,10 +28,20 @@ Simply install with:
### Optional dependencies
* icalendar : To print your todo.txt file as an iCalendar file
(not supported for Python 3.2).
* prompt-toolkit : For topydo's _prompt_ mode, which offers a shell-like
interface with auto-completion.
* [icalendar][7] : To print your todo.txt file as an iCalendar file
(not supported for Python 3.2).
* [prompt-toolkit][6] : For topydo's _prompt_ mode, which offers a shell-like
interface with auto-completion.
* [arrow][8] : Used to turn dates into a human readable version.
* [backports.shutil_get_terminal_size][9] : Used to determine your terminal
window size. This function was
added to the standard library in
Python 3.3 and so is only
required in older versions of
Python.
* [python-dateutil][10]: A dependency of *arrow*.
* [mock][11] : Used for testing. This was added to the standard
library in Python 3.3.
Demo
----
......@@ -43,4 +53,10 @@ Demo
[2]: https://github.com/ginatrapani/todo.txt-cli
[3]: https://github.com/bram85/todo.txt-tools
[4]: https://github.com/bram85/topydo/wiki
[5]: https://raw.githubusercontent.com/bram85/topydo/stable/doc/topydo.gif
[5]: https://raw.githubusercontent.com/bram85/topydo/master/doc/topydo.gif
[6]: https://github.com/jonathanslenders/python-prompt-toolkit
[7]: https://github.com/collective/icalendar
[8]: https://github.com/crsmithdev/arrow
[9]: https://github.com/chrippa/backports.shutil_get_terminal_size
[10]: https://dateutil.readthedocs.org/
[11]: https://github.com/testing-cabal/mock
#!/bin/bash
if [ "$1" = "python2" ] || [ "$1" = "python3" ]; then
PYTHON=$1
else
# run whatever is active
PYTHON=python
fi
# Run normal tests
if ! $PYTHON setup.py test; then
exit 1
fi
# pylint is not supported on 3.2, so skip the test there
if $PYTHON --version 2>&1 | grep 'Python 3\.2' > /dev/null; then
exit 0
fi
if ! $PYTHON -m pylint --errors-only topydo test; then
exit 1
fi
exit 0
[bdist_wheel]
universal = 1
......@@ -20,12 +20,6 @@ def find_version(*file_paths):
return version_match.group(1)
raise RuntimeError("Unable to find version string.")
conditional_dependencies = {
"colorama>=0.2.5": "win32" in sys.platform,
}
setup(
name = "topydo",
packages = find_packages(exclude=["test"]),
......@@ -35,13 +29,16 @@ setup(
author_email = "me@bramschoenmakers.nl",
url = "https://github.com/bram85/topydo",
install_requires = [
'six >= 1.9.0',
] + [p for p, cond in conditional_dependencies.items() if cond],
'arrow >= 0.7.0',
],
extras_require = {
':sys_platform=="win32"': ['colorama>=0.2.5'],
':python_version=="3.2"': ['backports.shutil_get_terminal_size>=1.0.0'],
'ical': ['icalendar'],
'prompt-toolkit': ['prompt-toolkit >= 0.47'],
'urwid': ['urwid >= 1.3.0'],
'edit-cmd-tests': ['mock'],
'prompt-toolkit': ['prompt-toolkit >= 0.53'],
'test': ['coverage', 'freezegun', 'green', ],
'test:python_version=="3.2"': ['mock'],
},
entry_points= {
'console_scripts': ['topydo = topydo.cli.UILoader:main'],
......@@ -52,10 +49,12 @@ setup(
"Intended Audience :: End Users/Desktop",
"License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)",
"Natural Language :: English",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3.2",
"Programming Language :: Python :: 3.3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: Utilities",
],
long_description = """\
......
# Topydo - A todo.txt client written in Python.
# Copyright (C) 2014 Bram Schoenmakers <me@bramschoenmakers.nl>
# Copyright (C) 2014 - 2015 Bram Schoenmakers <me@bramschoenmakers.nl>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......@@ -14,10 +14,9 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import unittest
from test.topydo_testcase import TopydoTest
from topydo.lib.Utils import escape_ansi
from test.TopydoTest import TopydoTest
class CommandTest(TopydoTest):
def __init__(self, *args, **kwargs):
......@@ -32,6 +31,3 @@ class CommandTest(TopydoTest):
def error(self, p_error):
if p_error:
self.errors += escape_ansi(p_error + "\n")
if __name__ == '__main__':
unittest.main()
[topydo]
colors = junk
[add]
auto_creation_date = junk
[ls]
indent = junk
list_limit = junk
human_readable_dates = junk
[sort]
keep_sorted = junk
ignore_weekends = junk
[dep]
append_parent_projects = junk
append_parent_contexts = junk
[colorscheme]
priority_colors = junk
project_color = junk
context_color = junk
metadata_color = junk
link_color = junk
[colorscheme]
; priority_colors = junk
; project_color = junk
; context_color = junk
; metadata_color = junk
; link_color = junk
[{"completed": false, "completion_date": null, "contexts": ["Context2"], "creation_date": null, "priority": "C", "projects": ["Project1"], "source": "(C) Foo @Context2 Not@Context +Project1 Not+Project", "tags": [], "text": "Foo @Context2 Not@Context +Project1 Not+Project"}, {"completed": false, "completion_date": null, "contexts": [], "creation_date": null, "priority": "C", "projects": [], "source": "(C) Drink beer @ home", "tags": [], "text": "Drink beer @ home"}, {"completed": false, "completion_date": null, "contexts": [], "creation_date": null, "priority": "C", "projects": [], "source": "(C) 13 + 29 = 42", "tags": [], "text": "13 + 29 = 42"}, {"completed": false, "completion_date": null, "contexts": ["Context1"], "creation_date": null, "priority": "D", "projects": ["Project2"], "source": "(D) Bar @Context1 +Project2 p:1", "tags": [["p", "1"]], "text": "Bar @Context1 +Project2"}]
[{"completed": false, "completion_date": null, "contexts": ["Context2"], "creation_date": "2015-11-05", "priority": "C", "projects": ["Project1"], "source": "(C) 2015-11-05 Foo @Context2 Not@Context +Project1 Not+Project", "tags": [], "text": "Foo @Context2 Not@Context +Project1 Not+Project"}, {"completed": false, "completion_date": null, "contexts": [], "creation_date": null, "priority": "C", "projects": [], "source": "(C) Drink beer @ home", "tags": [], "text": "Drink beer @ home"}, {"completed": false, "completion_date": null, "contexts": [], "creation_date": null, "priority": "C", "projects": [], "source": "(C) 13 + 29 = 42", "tags": [], "text": "13 + 29 = 42"}, {"completed": false, "completion_date": null, "contexts": ["Context1"], "creation_date": null, "priority": "D", "projects": ["Project2"], "source": "(D) Bar @Context1 +Project2 p:1", "tags": [["p", "1"]], "text": "Bar @Context1 +Project2"}]
(C) Foo @Context2 Not@Context +Project1 Not+Project
(C) 2015-11-05 Foo @Context2 Not@Context +Project1 Not+Project
(D) Bar @Context1 +Project2 p:1
(C) Baz @Context1 +Project1 key:value id:1
(C) Drink beer @ home
......
(A) item 1
(B) item 2
(C) item 3
(D) item 4
(E) item 5
(F) item 6
(G) item 7
(H) item 8
(I) item 9
(J) item 10
(K) item 11
(L) item 12
(M) item 13
(N) item 14
(O) item 15
(P) item 16
(Q) item 17
(R) item 18
(S) item 19
(T) item 20
(U) item 21
(V) item 22
(W) item 23
(X) item 24
(Y) item 25
(Z) item 26
(A) item 27
(B) item 28
(C) item 29
(D) item 30
(E) item 31
(F) item 32
(G) item 33
(H) item 34
(I) item 35
(J) item 36
(K) item 37
(L) item 38
(M) item 39
(N) item 40
(O) item 41
(P) item 42
(Q) item 43
(R) item 44
(S) item 45
(T) item 46
(U) item 47
(V) item 48
(W) item 49
(X) item 50
(D) 2015-08-31 Bar @Context1 +Project2 due:2015-09-30 t:2015-09-29
(Z) 2015-11-06 Lorem ipsum dolorem sit amet. Red @fox +jumped over the lazy:bar and jar due:2015-11-08 t:2015-11-07
(C) 2015-07-12 Foo @Context2 Not@Context +Project1 Not+Project
(C) Baz @Context1 +Project1 key:value
Drink beer @ home id:1 p:2 ical:foobar
x 2014-12-12 Completed but with date:2014-12-12
Todo item with +project3 @context1
Todo item with +Project2 @Context2
Todo item with +project1 @context3
Todo item with +project1 @context3
Todo item with +Project2 @Context2
Todo item with +project3 @context1
Todo item with +Project2 @Context2
Todo item with +project1 @context3
Todo item with +project3 @context1
[aliases]
foo = rm -f test
baz = FooBar
format = ls -F "|I| x c d {(}p{)} s k" -n 25
smile = ls
star = tag {} star 1
[ls]
list_format = |%I| %x %{(}p{)} %c %S\t%K
# Topydo - A todo.txt client written in Python.
# Copyright (C) 2014 Bram Schoenmakers <me@bramschoenmakers.nl>
# Copyright (C) 2014 - 2015 Bram Schoenmakers <me@bramschoenmakers.nl>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......@@ -19,6 +19,7 @@ from topydo.lib.Todo import Todo
from topydo.lib.TodoFile import TodoFile
from topydo.lib.TodoList import TodoList
def load_file(p_filename):
"""
Loads a todo file from the given filename and returns a list of todos.
......@@ -26,6 +27,7 @@ def load_file(p_filename):
todolist = load_file_to_raw_list(p_filename)
return [Todo(src) for src in todolist]
def load_file_to_raw_list(p_filename):
"""
Loads a todo file from the given filename and returns a list of todo
......@@ -34,6 +36,7 @@ def load_file_to_raw_list(p_filename):
todofile = TodoFile(p_filename)
return todofile.read()
def load_file_to_todolist(p_filename):
"""
Loads a todo file to a TodoList instance.
......@@ -41,10 +44,12 @@ def load_file_to_todolist(p_filename):
todolist = load_file_to_raw_list(p_filename)
return TodoList(todolist)
def todolist_to_string(p_list):
""" Converts a todo list to a single string. """
return '\n'.join([t.source() for t in p_list])
def print_view(p_view):
printer = PrettyPrinter()
return printer.print_list(p_view.todos)
# Topydo - A todo.txt client written in Python.
# Copyright (C) 2014 Bram Schoenmakers <me@bramschoenmakers.nl>
# Copyright (C) 2014 - 2015 Bram Schoenmakers <me@bramschoenmakers.nl>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......@@ -16,10 +16,11 @@
import unittest
from test.command_testcase import CommandTest
from topydo.commands.AppendCommand import AppendCommand
from test.CommandTest import CommandTest
from topydo.lib.TodoList import TodoList
class AppendCommandTest(CommandTest):
def setUp(self):
super(AppendCommandTest, self).setUp()
......@@ -27,14 +28,16 @@ class AppendCommandTest(CommandTest):
self.todolist.add("Foo")
def test_append1(self):
command = AppendCommand([1, "Bar"], self.todolist, self.out, self.error)
command = AppendCommand([1, "Bar"], self.todolist, self.out,
self.error)
command.execute()
self.assertEqual(self.output, "| 1| Foo Bar\n")
self.assertEqual(self.errors, "")
def test_append2(self):
command = AppendCommand([2, "Bar"], self.todolist, self.out, self.error)
command = AppendCommand([2, "Bar"], self.todolist, self.out,
self.error)
command.execute()
self.assertEqual(self.output, "")
......@@ -55,7 +58,8 @@ class AppendCommandTest(CommandTest):
self.assertEqual(self.errors, command.usage() + "\n")
def test_append5(self):
command = AppendCommand([1, "Bar", "Baz"], self.todolist, self.out, self.error)
command = AppendCommand([1, "Bar", "Baz"], self.todolist, self.out,
self.error)
command.execute()
self.assertEqual(self.output, "| 1| Foo Bar Baz\n")
......@@ -80,7 +84,8 @@ class AppendCommandTest(CommandTest):
command.execute()
self.assertEqual(self.output, "")
self.assertEqual(self.errors, command.usage() + "\n\n" + command.help() + "\n")
self.assertEqual(self.errors,
command.usage() + "\n\n" + command.help() + "\n")
if __name__ == '__main__':
unittest.main()
# Topydo - A todo.txt client written in Python.
# Copyright (C) 2014 Bram Schoenmakers <me@bramschoenmakers.nl>
# Copyright (C) 2014 - 2015 Bram Schoenmakers <me@bramschoenmakers.nl>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......@@ -16,11 +16,12 @@
import unittest
from test.command_testcase import CommandTest
from test.facilities import load_file_to_todolist
from topydo.commands.ArchiveCommand import ArchiveCommand
from test.CommandTest import CommandTest
from test.TestFacilities import load_file_to_todolist
from topydo.lib.TodoList import TodoList
class ArchiveCommandTest(CommandTest):
def test_archive(self):
todolist = load_file_to_todolist("test/data/ArchiveCommandTest.txt")
......@@ -36,4 +37,3 @@ class ArchiveCommandTest(CommandTest):
if __name__ == '__main__':
unittest.main()
# Topydo - A todo.txt client written in Python.
# Copyright (C) 2014 Bram Schoenmakers <me@bramschoenmakers.nl>
# Copyright (C) 2014 - 2015 Bram Schoenmakers <me@bramschoenmakers.nl>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......@@ -17,9 +17,11 @@
""" Tests for the colorscheme functionality. """
import unittest
from topydo.lib.Colors import Colors, NEUTRAL_COLOR
from test.topydo_testcase import TopydoTest
from topydo.lib.Colors import NEUTRAL_COLOR, Colors
from topydo.lib.Config import config
from test.TopydoTest import TopydoTest
class ColorsTest(TopydoTest):
def test_project_color1(self):
......@@ -69,7 +71,7 @@ class ColorsTest(TopydoTest):
color = Colors().get_context_color()
self.assertEqual(color, NEUTRAL_COLOR)
def test_metadata_color1(self):
config(p_overrides={('colorscheme', 'metadata_color'): '128'})
color = Colors().get_metadata_color()
......@@ -150,7 +152,7 @@ class ColorsTest(TopydoTest):
self.assertEqual(color['A'], NEUTRAL_COLOR)
self.assertEqual(color['B'], NEUTRAL_COLOR)
self.assertEqual(color['C'], NEUTRAL_COLOR)
self.assertEqual(color['C'], NEUTRAL_COLOR)
def test_empty_color_values(self):
config("test/data/ColorsTest5.conf")
......@@ -183,3 +185,6 @@ class ColorsTest(TopydoTest):
self.assertEqual(context_color, '\033[1;35m')
self.assertEqual(link_color, '\033[4;36m')
self.assertEqual(metadata_color, '\033[1;32m')
if __name__ == '__main__':
unittest.main()
# Topydo - A todo.txt client written in Python.
# Copyright (C) 2014 - 2015 Bram Schoenmakers <me@bramschoenmakers.nl>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import unittest
from unittest import skip
from test.topydo_testcase import TopydoTest
from topydo.lib.Config import config
class ConfigTest(TopydoTest):
def test_config01(self):
self.assertEqual(config("test/data/ConfigTest1.conf").default_command(), 'do')
def test_config02(self):
self.assertNotEqual(config("").default_command(), 'do')
def test_config03(self):
self.assertTrue(config("test/data/ConfigTest2.conf").ignore_weekends())
def test_config04(self):
""" Test that value in file is overridden by parameter. """
overrides = {
('topydo', 'default_command'): 'edit'
}
self.assertEqual(config("test/data/ConfigTest1.conf",
p_overrides=overrides).default_command(),
'edit')
def test_config05(self):
""" Bad colour switch value. """
# boolean settings must first be typecast to integers, because all
# strings evaulate to 'True'
self.assertEqual(config("test/data/ConfigTest4.conf").colors(),
bool(int(config().defaults["topydo"]["colors"])))
def test_config06(self):
""" Bad auto creation date switch value. """
self.assertEqual(config("test/data/ConfigTest4.conf").auto_creation_date(),
bool(int(config().defaults["add"]["auto_creation_date"])))
def test_config07(self):
""" Bad indent value. """
self.assertEqual(config("test/data/ConfigTest4.conf").list_indent(),
int(config().defaults["ls"]["indent"]))
def test_config08(self):
""" Bad list limit value. """
self.assertEqual(config("test/data/ConfigTest4.conf").list_limit(),
int(config().defaults["ls"]["list_limit"]))
def test_config10(self):
""" Bad keep sorted switch value. """
self.assertEqual(config("test/data/ConfigTest4.conf").keep_sorted(),
bool(int(config().defaults["sort"]["keep_sorted"])))
def test_config11(self):
""" Bad ignore weekends switch value. """
self.assertEqual(config("test/data/ConfigTest4.conf").ignore_weekends(),
bool(int(config().defaults["sort"]["ignore_weekends"])))
def test_config12(self):
""" Bad append parent projects switch value. """
self.assertEqual(config("test/data/ConfigTest4.conf").append_parent_projects(),
bool(int(config().defaults["dep"]["append_parent_projects"])))
def test_config13(self):
""" Bad append parent project contexts switch value. """
self.assertEqual(config("test/data/ConfigTest4.conf").append_parent_contexts(),
bool(int(config().defaults["dep"]["append_parent_contexts"])))
@skip("Error checking not yet implemented")
def test_config14(self):
""" Bad priority color value. """
self.assertEqual(config("test/data/ConfigTest4.conf").priority_colors(),
config().defaults["colorscheme"]["priority_colors"])
@skip("Error checking not yet implemented")
def test_config15(self):
""" Bad project color value. """
self.assertEqual(config("test/data/ConfigTest4.conf").project_color(),
config().defaults["colorscheme"]["project_color"])
@skip("Error checking not yet implemented")
def test_config16(self):
""" Bad context color value. """
self.assertEqual(config("test/data/ConfigTest4.conf").context_color(),
config().defaults["colorscheme"]["context_color"])
@skip("Error checking not yet implemented")
def test_config17(self):
""" Bad metadata color value. """
self.assertEqual(config("test/data/ConfigTest4.conf").metadata_color(),
config().defaults["colorscheme"]["metadata_color"])
@skip("Error checking not yet implemented")
def test_config18(self):
""" Bad link color value. """
self.assertEqual(config("test/data/ConfigTest4.conf").link_color(),
config().defaults["colorscheme"]["link_color"])
@skip("Test not yet implemented")
# the test needs to be of the internal function _str_to_dict
def test_config19(self):
""" No priority color value. """
self.assertEqual(config("test/data/ConfigTest4.conf").priority_colors(),
config().defaults["colorscheme"]["priority_colors"])
def test_config20(self):
""" No project color value. """
self.assertEqual(config("test/data/ConfigTest5.conf").project_color(),
config().defaults["colorscheme"]["project_color"])
def test_config21(self):
""" No context color value. """
self.assertEqual(config("test/data/ConfigTest5.conf").context_color(),
config().defaults["colorscheme"]["context_color"])
def test_config22(self):
""" No metadata color value. """
self.assertEqual(config("test/data/ConfigTest5.conf").metadata_color(),
config().defaults["colorscheme"]["metadata_color"])
def test_config23(self):
""" No link color value. """
self.assertEqual(config("test/data/ConfigTest5.conf").link_color(),
config().defaults["colorscheme"]["link_color"])
if __name__ == '__main__':
unittest.main()
......@@ -15,20 +15,22 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import unittest
from six import u
from test.CommandTest import CommandTest
from topydo.lib.Config import config
from test.command_testcase import CommandTest
from topydo.commands.DeleteCommand import DeleteCommand
from topydo.lib.Config import config
from topydo.lib.TodoList import TodoList
from topydo.lib.TodoListBase import InvalidTodoException
def _yes_prompt(self):
return "y"
def _no_prompt(self):
return "n"
class DeleteCommandTest(CommandTest):
def setUp(self):
super(DeleteCommandTest, self).setUp()
......@@ -42,7 +44,8 @@ class DeleteCommandTest(CommandTest):
self.todolist = TodoList(todos)
def test_del1(self):
command = DeleteCommand(["1"], self.todolist, self.out, self.error, _no_prompt)
command = DeleteCommand(["1"], self.todolist, self.out, self.error,
_no_prompt)
command.execute()
self.assertTrue(self.todolist.is_dirty())
......@@ -51,7 +54,8 @@ class DeleteCommandTest(CommandTest):
self.assertEqual(self.errors, "")
def test_del1_regex(self):
command = DeleteCommand(["Foo"], self.todolist, self.out, self.error, _no_prompt)
command = DeleteCommand(["Foo"], self.todolist, self.out, self.error,
_no_prompt)
command.execute()
self.assertTrue(self.todolist.is_dirty())
......@@ -60,29 +64,33 @@ class DeleteCommandTest(CommandTest):
self.assertEqual(self.errors, "")
def test_del2(self):
command = DeleteCommand(["1"], self.todolist, self.out, self.error, _yes_prompt)
command = DeleteCommand(["1"], self.todolist, self.out, self.error,
_yes_prompt)
command.execute()
self.assertTrue(self.todolist.is_dirty())
self.assertEqual(self.todolist.count(), 2)
self.assertEqual(self.output, "| 2| Bar p:1\nRemoved: Bar\nRemoved: Foo\n")
self.assertEqual(self.output,
"| 2| Bar p:1\nRemoved: Bar\nRemoved: Foo\n")
self.assertEqual(self.errors, "")
def test_del3(self):
command = DeleteCommand(["-f", "1"], self.todolist, self.out, self.error, _yes_prompt)
command = DeleteCommand(["-f", "1"], self.todolist, self.out,
self.error, _yes_prompt)
command.execute()
self.assertTrue(self.todolist.is_dirty())
self.assertEqual(self.todolist.count(), 3) # force won't delete subtasks
self.assertEqual(self.todolist.count(), 3) # force won't delete subtasks
self.assertEqual(self.output, "| 2| Bar p:1\nRemoved: Foo id:1\n")
self.assertEqual(self.errors, "")
def test_del4(self):
command = DeleteCommand(["--force", "1"], self.todolist, self.out, self.error, _yes_prompt)
command = DeleteCommand(["--force", "1"], self.todolist, self.out,
self.error, _yes_prompt)
command.execute()
self.assertTrue(self.todolist.is_dirty())
self.assertEqual(self.todolist.count(), 3) # force won't delete subtasks
self.assertEqual(self.todolist.count(), 3) # force won't delete subtasks
self.assertEqual(self.output, "| 2| Bar p:1\nRemoved: Foo id:1\n")
self.assertEqual(self.errors, "")
......@@ -125,7 +133,8 @@ class DeleteCommandTest(CommandTest):
def test_multi_del1(self):
""" Test deletion of multiple items. """
command = DeleteCommand(["1", "2"], self.todolist, self.out, self.error, _no_prompt)
command = DeleteCommand(["1", "2"], self.todolist, self.out,
self.error, _no_prompt)
command.execute()
result = "a @test with due:2015-06-03\na @test with +project"
......@@ -135,7 +144,8 @@ class DeleteCommandTest(CommandTest):
def test_multi_del2(self):
""" Test deletion of multiple items. """
command = DeleteCommand(["1", "2"], self.todolist, self.out, self.error, _yes_prompt)
command = DeleteCommand(["1", "2"], self.todolist, self.out,
self.error, _yes_prompt)
command.execute()
result = "a @test with due:2015-06-03\na @test with +project"
......@@ -145,7 +155,8 @@ class DeleteCommandTest(CommandTest):
def test_multi_del3(self):
""" Fail if any of supplied todo numbers is invalid. """
command = DeleteCommand(["99", "2"], self.todolist, self.out, self.error, _yes_prompt)
command = DeleteCommand(["99", "2"], self.todolist, self.out,
self.error, _yes_prompt)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -154,7 +165,8 @@ class DeleteCommandTest(CommandTest):
def test_multi_del4(self):
""" Check output when all supplied todo numbers are invalid. """
command = DeleteCommand(["99", "A"], self.todolist, self.out, self.error, _yes_prompt)
command = DeleteCommand(["99", "A"], self.todolist, self.out,
self.error, _yes_prompt)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -162,16 +174,21 @@ class DeleteCommandTest(CommandTest):
self.assertEqual(self.errors, "Invalid todo number given: 99.\nInvalid todo number given: A.\n")
def test_multi_del5(self):
""" Throw an error with invalid argument containing special characters. """
command = DeleteCommand([u("Fo\u00d3B\u0105r"), "Bar"], self.todolist, self.out, self.error, None)
"""
Throw an error with invalid argument containing special characters.
"""
command = DeleteCommand([u"Fo\u00d3B\u0105r", "Bar"], self.todolist,
self.out, self.error, None)
command.execute()
self.assertFalse(self.todolist.is_dirty())
self.assertEqual(self.output, "")
self.assertEqual(self.errors, u("Invalid todo number given: Fo\u00d3B\u0105r.\n"))
self.assertEqual(self.errors,
u"Invalid todo number given: Fo\u00d3B\u0105r.\n")
def test_expr_del1(self):
command = DeleteCommand(["-e", "@test"], self.todolist, self.out, self.error, None)
command = DeleteCommand(["-e", "@test"], self.todolist, self.out,
self.error, None)
command.execute()
result = "Removed: a @test with due:2015-06-03\nRemoved: a @test with +project\n"
......@@ -182,7 +199,8 @@ class DeleteCommandTest(CommandTest):
self.assertEqual(self.errors, "")
def test_expr_del2(self):
command = DeleteCommand(["-e", "@test", "due:2015-06-03"], self.todolist, self.out, self.error, None)
command = DeleteCommand(["-e", "@test", "due:2015-06-03"],
self.todolist, self.out, self.error, None)
command.execute()
self.assertTrue(self.todolist.is_dirty())
......@@ -190,14 +208,16 @@ class DeleteCommandTest(CommandTest):
self.assertEqual(self.errors, "")
def test_expr_del3(self):
command = DeleteCommand(["-e", "@test", "due:2015-06-03", "+project"], self.todolist, self.out, self.error, None)
command = DeleteCommand(["-e", "@test", "due:2015-06-03", "+project"],
self.todolist, self.out, self.error, None)
command.execute()
self.assertFalse(self.todolist.is_dirty())
def test_expr_del4(self):
""" Remove only relevant todo items. """
command = DeleteCommand(["-e", ""], self.todolist, self.out, self.error, None)
command = DeleteCommand(["-e", ""], self.todolist, self.out,
self.error, None)
command.execute()
result = "Foo"
......@@ -208,7 +228,8 @@ class DeleteCommandTest(CommandTest):
def test_expr_del5(self):
""" Force deleting unrelevant items with additional -x flag. """
command = DeleteCommand(["-xe", ""], self.todolist, self.out, self.error, _yes_prompt)
command = DeleteCommand(["-xe", ""], self.todolist, self.out,
self.error, _yes_prompt)
command.execute()
self.assertTrue(self.todolist.is_dirty())
......@@ -227,7 +248,8 @@ class DeleteCommandTest(CommandTest):
command.execute()
self.assertEqual(self.output, "")
self.assertEqual(self.errors, command.usage() + "\n\n" + command.help() + "\n")
self.assertEqual(self.errors,
command.usage() + "\n\n" + command.help() + "\n")
if __name__ == '__main__':
unittest.main()
# Topydo - A todo.txt client written in Python.
# Copyright (C) 2014 Bram Schoenmakers <me@bramschoenmakers.nl>
# Copyright (C) 2014 - 2015 Bram Schoenmakers <me@bramschoenmakers.nl>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......@@ -16,10 +16,11 @@
import unittest
from test.command_testcase import CommandTest
from topydo.commands.DepCommand import DepCommand
from test.CommandTest import CommandTest
from topydo.lib.TodoList import TodoList
class DepCommandTest(CommandTest):
def setUp(self):
super(DepCommandTest, self).setUp()
......@@ -35,7 +36,8 @@ class DepCommandTest(CommandTest):
self.todolist = TodoList(todos)
def test_add1(self):
command = DepCommand(["add", "1", "to", "4"], self.todolist, self.out, self.error)
command = DepCommand(["add", "1", "to", "4"], self.todolist, self.out,
self.error)
command.execute()
self.assertTrue(self.todolist.is_dirty())
......@@ -44,7 +46,8 @@ class DepCommandTest(CommandTest):
self.assertEqual(self.errors, "")
def test_add2(self):
command = DepCommand(["add", "1", "4"], self.todolist, self.out, self.error)
command = DepCommand(["add", "1", "4"], self.todolist, self.out,
self.error)
command.execute()
self.assertTrue(self.todolist.is_dirty())
......@@ -53,7 +56,8 @@ class DepCommandTest(CommandTest):
self.assertEqual(self.errors, "")
def test_add3(self):
command = DepCommand(["add", "99", "3"], self.todolist, self.out, self.error)
command = DepCommand(["add", "99", "3"], self.todolist, self.out,
self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -61,7 +65,8 @@ class DepCommandTest(CommandTest):
self.assertEqual(self.errors, "Invalid todo number given.\n")
def test_add4(self):
command = DepCommand(["add", "A", "3"], self.todolist, self.out, self.error)
command = DepCommand(["add", "A", "3"], self.todolist, self.out,
self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -77,7 +82,8 @@ class DepCommandTest(CommandTest):
self.assertEqual(self.errors, command.usage() + "\n")
def test_add6(self):
command = DepCommand(["add", "1", "after", "4"], self.todolist, self.out, self.error)
command = DepCommand(["add", "1", "after", "4"], self.todolist,
self.out, self.error)
command.execute()
self.assertTrue(self.todolist.is_dirty())
......@@ -86,7 +92,8 @@ class DepCommandTest(CommandTest):
self.assertEqual(self.errors, "")
def test_add7(self):
command = DepCommand(["add", "1", "before", "4"], self.todolist, self.out, self.error)
command = DepCommand(["add", "1", "before", "4"], self.todolist,
self.out, self.error)
command.execute()
self.assertTrue(self.todolist.is_dirty())
......@@ -95,7 +102,8 @@ class DepCommandTest(CommandTest):
self.assertEqual(self.errors, "")
def test_add8(self):
command = DepCommand(["add", "1", "partof", "4"], self.todolist, self.out, self.error)
command = DepCommand(["add", "1", "partof", "4"], self.todolist,
self.out, self.error)
command.execute()
self.assertTrue(self.todolist.is_dirty())
......@@ -104,7 +112,8 @@ class DepCommandTest(CommandTest):
self.assertEqual(self.errors, "")
def test_add9(self):
command = DepCommand(["add", "Foo", "to", "4"], self.todolist, self.out, self.error)
command = DepCommand(["add", "Foo", "to", "4"], self.todolist,
self.out, self.error)
command.execute()
self.assertTrue(self.todolist.is_dirty())
......@@ -117,7 +126,6 @@ class DepCommandTest(CommandTest):
Helper function that checks the removal of the dependency from todo 1
to todo 3.
"""
command = DepCommand(p_args, self.todolist, self.out, self.error)
command.execute()
......@@ -131,16 +139,17 @@ class DepCommandTest(CommandTest):
self.rm_helper(["rm", "1", "to", "3"])
def test_rm2(self):
self.rm_helper(["rm", "1", "3"])
self.rm_helper(["rm", "1", "3"])
def test_del1(self):
self.rm_helper(["del", "1", "to", "3"])
def test_del2(self):
self.rm_helper(["del", "1", "3"])
self.rm_helper(["del", "1", "3"])
def test_rm3(self):
command = DepCommand(["rm", "99", "3"], self.todolist, self.out, self.error)
command = DepCommand(["rm", "99", "3"], self.todolist, self.out,
self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -148,7 +157,8 @@ class DepCommandTest(CommandTest):
self.assertEqual(self.errors, "Invalid todo number given.\n")
def test_rm4(self):
command = DepCommand(["rm", "A", "3"], self.todolist, self.out, self.error)
command = DepCommand(["rm", "A", "3"], self.todolist, self.out,
self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -164,7 +174,8 @@ class DepCommandTest(CommandTest):
self.assertEqual(self.errors, command.usage() + "\n")
def test_ls1(self):
command = DepCommand(["ls", "1", "to"], self.todolist, self.out, self.error)
command = DepCommand(["ls", "1", "to"], self.todolist, self.out,
self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -172,7 +183,8 @@ class DepCommandTest(CommandTest):
self.assertEqual(self.errors, "")
def test_ls2(self):
command = DepCommand(["ls", "99", "to"], self.todolist, self.out, self.error)
command = DepCommand(["ls", "99", "to"], self.todolist, self.out,
self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -180,7 +192,8 @@ class DepCommandTest(CommandTest):
self.assertEqual(self.errors, "Invalid todo number given.\n")
def test_ls3(self):
command = DepCommand(["ls", "to", "3"], self.todolist, self.out, self.error)
command = DepCommand(["ls", "to", "3"], self.todolist, self.out,
self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -188,7 +201,8 @@ class DepCommandTest(CommandTest):
self.assertEqual(self.errors, "")
def test_ls4(self):
command = DepCommand(["ls", "to", "99"], self.todolist, self.out, self.error)
command = DepCommand(["ls", "to", "99"], self.todolist, self.out,
self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -212,7 +226,8 @@ class DepCommandTest(CommandTest):
self.assertEqual(self.errors, command.usage() + "\n")
def test_ls7(self):
command = DepCommand(["ls", "top", "99"], self.todolist, self.out, self.error)
command = DepCommand(["ls", "top", "99"], self.todolist, self.out,
self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -220,7 +235,8 @@ class DepCommandTest(CommandTest):
self.assertEqual(self.errors, command.usage() + "\n")
def gc_helper(self, p_subcommand):
command = DepCommand([p_subcommand], self.todolist, self.out, self.error)
command = DepCommand([p_subcommand], self.todolist, self.out,
self.error)
command.execute()
self.assertTrue(self.todolist.is_dirty())
......@@ -255,7 +271,8 @@ class DepCommandTest(CommandTest):
command.execute()
self.assertEqual(self.output, "")
self.assertEqual(self.errors, command.usage() + "\n\n" + command.help() + "\n")
self.assertEqual(self.errors,
command.usage() + "\n\n" + command.help() + "\n")
if __name__ == '__main__':
unittest.main()
# Topydo - A todo.txt client written in Python.
# Copyright (C) 2014 Bram Schoenmakers <me@bramschoenmakers.nl>
# Copyright (C) 2014 - 2015 Bram Schoenmakers <me@bramschoenmakers.nl>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......@@ -15,12 +15,12 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import unittest
from six import u
from test.command_testcase import CommandTest
from topydo.commands.DepriCommand import DepriCommand
from test.CommandTest import CommandTest
from topydo.lib.TodoList import TodoList
class DepriCommandTest(CommandTest):
def setUp(self):
super(DepriCommandTest, self).setUp()
......@@ -63,7 +63,8 @@ class DepriCommandTest(CommandTest):
self.assertEqual(self.errors, "")
def test_depri4(self):
command = DepriCommand(["1","Baz"], self.todolist, self.out, self.error)
command = DepriCommand(["1", "Baz"], self.todolist, self.out,
self.error)
command.execute()
self.assertTrue(self.todolist.is_dirty())
......@@ -73,10 +74,10 @@ class DepriCommandTest(CommandTest):
self.assertEqual(self.errors, "")
def test_expr_depri1(self):
command = DepriCommand(["-e", "@test"], self.todolist, self.out, self.error, None)
command = DepriCommand(["-e", "@test"], self.todolist, self.out,
self.error, None)
command.execute()
result = "Priority removed.\n| 4| a @test with due:2015-06-03\nPriority removed.\n| 5| a @test with +project p:1\n"
self.assertTrue(self.todolist.is_dirty())
......@@ -84,7 +85,8 @@ class DepriCommandTest(CommandTest):
self.assertEqual(self.errors, "")
def test_expr_depri2(self):
command = DepriCommand(["-e", "@test", "due:2015-06-03"], self.todolist, self.out, self.error, None)
command = DepriCommand(["-e", "@test", "due:2015-06-03"],
self.todolist, self.out, self.error, None)
command.execute()
result = "Priority removed.\n| 4| a @test with due:2015-06-03\n"
......@@ -94,29 +96,30 @@ class DepriCommandTest(CommandTest):
self.assertEqual(self.errors, "")
def test_expr_depri3(self):
command = DepriCommand(["-e", "@test", "due:2015-06-03", "+project"], self.todolist, self.out, self.error, None)
command = DepriCommand(["-e", "@test", "due:2015-06-03", "+project"],
self.todolist, self.out, self.error, None)
command.execute()
self.assertFalse(self.todolist.is_dirty())
def test_expr_depri4(self):
""" Don't remove priority from unrelevant todo items. """
command = DepriCommand(["-e", "Bax"], self.todolist, self.out, self.error, None)
command = DepriCommand(["-e", "Bax"], self.todolist, self.out,
self.error, None)
command.execute()
self.assertFalse(self.todolist.is_dirty())
def test_expr_depri5(self):
""" Force unprioritizing unrelevant items with additional -x flag. """
command = DepriCommand(["-xe", "Bax"], self.todolist, self.out, self.error, None)
command = DepriCommand(["-xe", "Bax"], self.todolist, self.out,
self.error, None)
command.execute()
self.assertTrue(self.todolist.is_dirty())
self.assertEqual(self.output, "Priority removed.\n| 6| Bax id:1\n")
self.assertEqual(self.errors, "")
def test_invalid1(self):
command = DepriCommand(["99"], self.todolist, self.out, self.error)
command.execute()
......@@ -126,7 +129,8 @@ class DepriCommandTest(CommandTest):
self.assertEqual(self.errors, "Invalid todo number given.\n")
def test_invalid2(self):
command = DepriCommand(["99", "1"], self.todolist, self.out, self.error)
command = DepriCommand(["99", "1"], self.todolist, self.out,
self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -134,7 +138,8 @@ class DepriCommandTest(CommandTest):
self.assertEqual(self.errors, "Invalid todo number given: 99.\n")
def test_invalid3(self):
command = DepriCommand(["99", "FooBar"], self.todolist, self.out, self.error)
command = DepriCommand(["99", "FooBar"], self.todolist, self.out,
self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -142,13 +147,17 @@ class DepriCommandTest(CommandTest):
self.assertEqual(self.errors, "Invalid todo number given: 99.\nInvalid todo number given: FooBar.\n")
def test_invalid4(self):
""" Throw an error with invalid argument containing special characters. """
command = DepriCommand([u("Fo\u00d3B\u0105r"), "Bar"], self.todolist, self.out, self.error, None)
"""
Throw an error with invalid argument containing special characters.
"""
command = DepriCommand([u"Fo\u00d3B\u0105r", "Bar"], self.todolist,
self.out, self.error, None)
command.execute()
self.assertFalse(self.todolist.is_dirty())
self.assertFalse(self.output)
self.assertEqual(self.errors, u("Invalid todo number given: Fo\u00d3B\u0105r.\n"))
self.assertEqual(self.errors,
u"Invalid todo number given: Fo\u00d3B\u0105r.\n")
def test_empty(self):
command = DepriCommand([], self.todolist, self.out, self.error)
......@@ -163,7 +172,8 @@ class DepriCommandTest(CommandTest):
command.execute()
self.assertEqual(self.output, "")
self.assertEqual(self.errors, command.usage() + "\n\n" + command.help() + "\n")
self.assertEqual(self.errors,
command.usage() + "\n\n" + command.help() + "\n")
if __name__ == '__main__':
unittest.main()
This diff is collapsed.
# Topydo - A todo.txt client written in Python.
# Copyright (C) 2014 - 2015 Bram Schoenmakers <me@bramschoenmakers.nl>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import unittest
from test.topydo_testcase import TopydoTest
from topydo.Commands import get_subcommand
from topydo.commands.AddCommand import AddCommand
from topydo.commands.DeleteCommand import DeleteCommand
from topydo.commands.ListCommand import ListCommand
from topydo.commands.ListProjectCommand import ListProjectCommand
from topydo.commands.TagCommand import TagCommand
from topydo.lib.Config import config
class GetSubcommandTest(TopydoTest):
def test_normal_cmd(self):
args = ["add"]
real_cmd, final_args = get_subcommand(args)
self.assertTrue(issubclass(real_cmd, AddCommand))
def test_cmd_help(self):
args = ["help", "add"]
real_cmd, final_args = get_subcommand(args)
self.assertTrue(issubclass(real_cmd, AddCommand))
self.assertEqual(final_args, ["help"])
def test_alias01(self):
config("test/data/aliases.conf")
args = ["foo"]
real_cmd, final_args = get_subcommand(args)
self.assertTrue(issubclass(real_cmd, DeleteCommand))
self.assertEqual(final_args, ["-f", "test"])
def test_alias02(self):
config("test/data/aliases.conf")
args = ["format"]
real_cmd, final_args = get_subcommand(args)
self.assertTrue(issubclass(real_cmd, ListCommand))
self.assertEqual(final_args, ["-F", "|I| x c d {(}p{)} s k", "-n", "25"])
def test_alias03(self):
config("test/data/aliases.conf")
args = ["smile"]
real_cmd, final_args = get_subcommand(args)
self.assertTrue(issubclass(real_cmd, ListCommand))
self.assertEqual(final_args, [u"\u263b"])
def test_alias04(self):
config("test/data/aliases.conf")
args = ["star", "foo"]
real_cmd, final_args = get_subcommand(args)
self.assertTrue(issubclass(real_cmd, TagCommand))
self.assertEqual(final_args, ["foo", "star", "1"])
def test_default_cmd01(self):
args = ["bar"]
real_cmd, final_args = get_subcommand(args)
self.assertTrue(issubclass(real_cmd, ListCommand))
self.assertEqual(final_args, ["bar"])
def test_default_cmd02(self):
args = []
real_cmd, final_args = get_subcommand(args)
self.assertTrue(issubclass(real_cmd, ListCommand))
self.assertEqual(final_args, [])
def test_alias_default_cmd01(self):
config("test/data/aliases.conf", {('topydo', 'default_command'): 'foo'})
args = ["bar"]
real_cmd, final_args = get_subcommand(args)
self.assertTrue(issubclass(real_cmd, DeleteCommand))
self.assertEqual(final_args, ["-f", "test", "bar"])
def test_alias_default_cmd02(self):
config("test/data/aliases.conf", {('topydo', 'default_command'): 'foo'})
args = []
real_cmd, final_args = get_subcommand(args)
self.assertTrue(issubclass(real_cmd, DeleteCommand))
self.assertEqual(final_args, ["-f", "test"])
def test_alias_default_cmd03(self):
config("test/data/aliases.conf", {('topydo', 'default_command'): 'nonexisting_default'})
args = ['nonexisting']
real_cmd, final_args = get_subcommand(args)
self.assertFalse(real_cmd)
self.assertEqual(final_args, ['nonexisting'])
def test_alias_default_cmd04(self):
config("test/data/aliases.conf", {('topydo', 'default_command'): 'nonexisting_default'})
args = []
real_cmd, final_args = get_subcommand(args)
self.assertFalse(real_cmd)
self.assertEqual(final_args, [])
def test_wrong_alias(self):
config("test/data/aliases.conf")
args = ["baz"]
real_cmd, final_args = get_subcommand(args)
self.assertEqual(real_cmd, None)
def test_help(self):
real_cmd, final_args = get_subcommand(['help', 'nonexisting'])
self.assertFalse(real_cmd)
self.assertEqual(final_args, ['help', 'nonexisting'])
if __name__ == '__main__':
unittest.main()
# Topydo - A todo.txt client written in Python.
# Copyright (C) 2014 Bram Schoenmakers <me@bramschoenmakers.nl>
# Copyright (C) 2014 - 2015 Bram Schoenmakers <me@bramschoenmakers.nl>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......@@ -16,8 +16,9 @@
import unittest
from test.topydo_testcase import TopydoTest
from topydo.lib.Graph import DirectedGraph
from test.TopydoTest import TopydoTest
class GraphTest(TopydoTest):
def setUp(self):
......@@ -63,7 +64,8 @@ class GraphTest(TopydoTest):
self.assertEqual(self.graph.incoming_neighbors(1, True), set())
def test_incoming_neighbors4(self):
self.assertEqual(self.graph.incoming_neighbors(5, True), set([1, 2, 3, 4, 6]))
self.assertEqual(self.graph.incoming_neighbors(5, True),
set([1, 2, 3, 4, 6]))
def test_outgoing_neighbors1(self):
self.assertEqual(self.graph.outgoing_neighbors(1), set([2, 3]))
......@@ -72,7 +74,8 @@ class GraphTest(TopydoTest):
self.assertEqual(self.graph.outgoing_neighbors(2), set([4]))
def test_outgoing_neighbors3(self):
self.assertEqual(self.graph.outgoing_neighbors(1, True), set([2, 3, 4, 5, 6]))
self.assertEqual(self.graph.outgoing_neighbors(1, True),
set([2, 3, 4, 5, 6]))
def test_outgoing_neighbors4(self):
self.assertEqual(self.graph.outgoing_neighbors(3), set([5]))
......
# Topydo - A todo.txt client written in Python.
# Copyright (C) 2014 Bram Schoenmakers <me@bramschoenmakers.nl>
# Copyright (C) 2014 - 2015 Bram Schoenmakers <me@bramschoenmakers.nl>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......@@ -14,31 +14,47 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from datetime import date
import unittest
from datetime import date, timedelta
from freezegun import freeze_time
from test.topydo_testcase import TopydoTest
from topydo.lib.Config import config
from topydo.lib.Importance import importance
from topydo.lib.Todo import Todo
from test.TopydoTest import TopydoTest
@freeze_time("2015, 11, 06")
class ImportanceTest(TopydoTest):
def test_importance1(self):
def test_importance01(self):
todo = Todo("Foo")
self.assertEqual(importance(todo), 2)
def test_importance2(self):
def test_importance02(self):
todo = Todo("(A) Foo")
self.assertEqual(importance(todo), 5)
def test_importance3(self):
def test_importance03(self):
todo = Todo("(A) Foo " + config().tag_star() + ":1")
self.assertEqual(importance(todo), 6)
def test_importance4(self):
def test_importance04(self):
today_str = date.today().isoformat()
todo = Todo("(C) Foo " + config().tag_due() + ":" + today_str)
self.assertEqual(importance(todo), 8)
def test_importance05(self):
todo = Todo("(C) Foo " + config().tag_due() + ":" + "2015-11-14")
self.assertEqual(importance(todo), 4)
def test_importance06(self):
todo = Todo("(C) Foo " + config().tag_due() + ":" + "2015-11-10")
self.assertEqual(importance(todo), 5)
def test_importance07(self):
config(p_overrides={('sort', 'ignore_weekends'): '1'})
todo = Todo("(C) Foo " + config().tag_due() + ":" + "2015-11-09")
self.assertEqual(importance(todo), 6)
if __name__ == '__main__':
unittest.main()
......@@ -14,15 +14,19 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import unittest
from test.topydo_testcase import TopydoTest
from topydo.lib.JsonPrinter import JsonPrinter
from topydo.lib.Todo import Todo
from test.TopydoTest import TopydoTest
class JsonPrinterTest(TopydoTest):
"""
Tests the functionality of printing a single todo item. Printing a list is
already covered by the ListCommand tests.
"""
def test_json(self):
""" Print a single todo item. """
printer = JsonPrinter()
......@@ -31,3 +35,6 @@ class JsonPrinterTest(TopydoTest):
result = printer.print_todo(todo)
self.assertEqual(result, '{"completed": false, "completion_date": null, "contexts": [], "creation_date": "2015-06-06", "priority": null, "projects": [], "source": "2015-06-06 Foo due:2015-05-32", "tags": [["due", "2015-05-32"]], "text": "Foo"}')
if __name__ == '__main__':
unittest.main()
# Topydo - A todo.txt client written in Python.
# Copyright (C) 2014 Bram Schoenmakers <me@bramschoenmakers.nl>
# Copyright (C) 2014 - 2015 Bram Schoenmakers <me@bramschoenmakers.nl>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......@@ -16,9 +16,10 @@
import unittest
from test.command_testcase import CommandTest
from test.facilities import load_file_to_todolist
from topydo.commands.ListContextCommand import ListContextCommand
from test.CommandTest import CommandTest
from test.TestFacilities import load_file_to_todolist
class ListContextCommandTest(CommandTest):
def test_contexts1(self):
......@@ -26,7 +27,7 @@ class ListContextCommandTest(CommandTest):
command = ListContextCommand([""], todolist, self.out, self.error)
command.execute()
self.assertEqual(self.output,"Context1\nContext2\n")
self.assertEqual(self.output, "Context1\nContext2\n")
self.assertFalse(self.errors)
def test_contexts2(self):
......@@ -34,7 +35,7 @@ class ListContextCommandTest(CommandTest):
command = ListContextCommand(["aaa"], todolist, self.out, self.error)
command.execute()
self.assertEqual(self.output,"Context1\nContext2\n")
self.assertEqual(self.output, "Context1\nContext2\n")
self.assertFalse(self.errors)
def test_help(self):
......@@ -42,7 +43,8 @@ class ListContextCommandTest(CommandTest):
command.execute()
self.assertEqual(self.output, "")
self.assertEqual(self.errors, command.usage() + "\n\n" + command.help() + "\n")
self.assertEqual(self.errors,
command.usage() + "\n\n" + command.help() + "\n")
if __name__ == '__main__':
unittest.main()
This diff is collapsed.
# Topydo - A todo.txt client written in Python.
# Copyright (C) 2014 Bram Schoenmakers <me@bramschoenmakers.nl>
# Copyright (C) 2014 - 2015 Bram Schoenmakers <me@bramschoenmakers.nl>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......@@ -16,9 +16,10 @@
import unittest
from test.command_testcase import CommandTest
from test.facilities import load_file_to_todolist
from topydo.commands.ListProjectCommand import ListProjectCommand
from test.CommandTest import CommandTest
from test.TestFacilities import load_file_to_todolist
class ListProjectCommandTest(CommandTest):
def test_projects1(self):
......@@ -42,7 +43,8 @@ class ListProjectCommandTest(CommandTest):
command.execute()
self.assertEqual(self.output, "")
self.assertEqual(self.errors, command.usage() + "\n\n" + command.help() + "\n")
self.assertEqual(self.errors,
command.usage() + "\n\n" + command.help() + "\n")
if __name__ == '__main__':
unittest.main()
# Topydo - A todo.txt client written in Python.
# Copyright (C) 2014 Bram Schoenmakers <me@bramschoenmakers.nl>
# Copyright (C) 2014 - 2015 Bram Schoenmakers <me@bramschoenmakers.nl>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......@@ -14,13 +14,14 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from datetime import date, timedelta
import unittest
from datetime import date, timedelta
from test.topydo_testcase import TopydoTest
from topydo.lib.Config import config
from topydo.lib.Recurrence import advance_recurring_todo, NoRecurrenceException
from topydo.lib.Recurrence import NoRecurrenceException, advance_recurring_todo
from topydo.lib.Todo import Todo
from test.TopydoTest import TopydoTest
class RecurrenceTest(TopydoTest):
def setUp(self):
......@@ -164,12 +165,14 @@ class RecurrenceTest(TopydoTest):
def test_no_recurrence(self):
self.todo.remove_tag('rec')
self.assertRaises(NoRecurrenceException, advance_recurring_todo, self.todo)
self.assertRaises(NoRecurrenceException, advance_recurring_todo,
self.todo)
def test_invalid_recurrence(self):
""" Throw exception when 'rec' tag has an invalid value. """
self.todo.set_tag('rec', '1')
self.assertRaises(NoRecurrenceException, advance_recurring_todo, self.todo)
self.assertRaises(NoRecurrenceException, advance_recurring_todo,
self.todo)
if __name__ == '__main__':
unittest.main()
# Topydo - A todo.txt client written in Python.
# Copyright (C) 2014 Bram Schoenmakers <me@bramschoenmakers.nl>
# Copyright (C) 2014 - 2015 Bram Schoenmakers <me@bramschoenmakers.nl>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......@@ -14,21 +14,23 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from datetime import date, timedelta
import unittest
from datetime import date, timedelta
from freezegun import freeze_time
from test.topydo_testcase import TopydoTest
from topydo.lib.RelativeDate import relative_date_to_date
from test.TopydoTest import TopydoTest
@freeze_time('2015, 11, 06')
class RelativeDateTester(TopydoTest):
def setUp(self):
super(RelativeDateTester, self).setUp()
self.today = date.today()
self.tomorrow = self.today + timedelta(1)
self.monday = self.today
if self.monday.weekday() != 0:
self.monday += timedelta(7 - self.today.weekday() % 7)
self.yesterday = date(2015, 11, 5)
self.today = date(2015, 11, 6)
self.tomorrow = date(2015, 11, 7)
self.monday = date(2015, 11, 9)
self.friday = date(2015, 11, 13)
def test_zero_days(self):
result = relative_date_to_date('0d')
......@@ -40,7 +42,7 @@ class RelativeDateTester(TopydoTest):
def test_one_week(self):
result = relative_date_to_date('1w')
self.assertEqual(result, date.today() + timedelta(weeks=1))
self.assertEqual(result, date(2015, 11, 13))
def test_one_month(self):
test_date = date(2015, 1, 10)
......@@ -103,8 +105,7 @@ class RelativeDateTester(TopydoTest):
self.assertEqual(result, self.today)
def test_today3(self):
result = relative_date_to_date('today', \
date.today() + timedelta(1))
result = relative_date_to_date('today', self.tomorrow)
self.assertEqual(result, self.today)
def test_tomorrow1(self):
......@@ -115,6 +116,14 @@ class RelativeDateTester(TopydoTest):
result = relative_date_to_date('tom')
self.assertEqual(result, self.tomorrow)
def test_yesterday1(self):
result = relative_date_to_date('yesterday')
self.assertEqual(result, self.yesterday)
def test_yesterday2(self):
result = relative_date_to_date('yes')
self.assertEqual(result, self.yesterday)
def test_monday1(self):
result = relative_date_to_date('monday')
self.assertEqual(result, self.monday)
......@@ -133,15 +142,23 @@ class RelativeDateTester(TopydoTest):
def test_offset1(self):
result = relative_date_to_date('1d', self.tomorrow)
self.assertEqual(result, date.today() + timedelta(2))
self.assertEqual(result, date(2015, 11, 8))
def test_negative_period1(self):
result = relative_date_to_date('-1d')
self.assertEqual(result, date.today() - timedelta(1))
self.assertEqual(result, date(2015, 11, 5))
def test_negative_period2(self):
result = relative_date_to_date('-0d')
self.assertTrue(result, self.today)
def test_weekday_next_week(self):
"""
When entering "Friday" on a Friday, return next week Friday instead of
today.
"""
result = relative_date_to_date("fri")
self.assertTrue(result, self.friday)
if __name__ == '__main__':
unittest.main()
This diff is collapsed.
# Topydo - A todo.txt client written in Python.
# Copyright (C) 2014 Bram Schoenmakers <me@bramschoenmakers.nl>
# Copyright (C) 2014 - 2015 Bram Schoenmakers <me@bramschoenmakers.nl>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......@@ -16,10 +16,11 @@
import unittest
from topydo.lib.Config import config
from test.command_testcase import CommandTest
from test.facilities import load_file_to_todolist
from topydo.commands.SortCommand import SortCommand
from test.CommandTest import CommandTest
from test.TestFacilities import load_file_to_todolist
from topydo.lib.Config import config
class SortCommandTest(CommandTest):
def setUp(self):
......@@ -27,17 +28,19 @@ class SortCommandTest(CommandTest):
self.todolist = load_file_to_todolist("test/data/SorterTest1.txt")
def test_sort1(self):
""" Alphabetically sorted """
""" Alphabetically sorted. """
command = SortCommand(["text"], self.todolist, self.out, self.error)
command.execute()
self.assertEqual(self.todolist.print_todos(), "First\n(A) Foo\n2014-06-14 Last")
self.assertEqual(self.todolist.print_todos(),
"First\n(A) Foo\n2014-06-14 Last")
def test_sort2(self):
command = SortCommand([], self.todolist, self.out, self.error)
command.execute()
self.assertEqual(self.todolist.print_todos(), "(A) Foo\n2014-06-14 Last\nFirst")
self.assertEqual(self.todolist.print_todos(),
"(A) Foo\n2014-06-14 Last\nFirst")
def test_sort3(self):
""" Check that order does not influence the UID of a todo. """
......@@ -55,7 +58,8 @@ class SortCommandTest(CommandTest):
command.execute()
self.assertEqual(self.output, "")
self.assertEqual(self.errors, command.usage() + "\n\n" + command.help() + "\n")
self.assertEqual(self.errors,
command.usage() + "\n\n" + command.help() + "\n")
if __name__ == '__main__':
unittest.main()
This diff is collapsed.
This diff is collapsed.
# Topydo - A todo.txt client written in Python.
# Copyright (C) 2014 Bram Schoenmakers <me@bramschoenmakers.nl>
# Copyright (C) 2014 - 2015 Bram Schoenmakers <me@bramschoenmakers.nl>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......@@ -14,11 +14,11 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from six import u
import unittest
from test.TestFacilities import load_file
from test.TopydoTest import TopydoTest
from test.facilities import load_file
from test.topydo_testcase import TopydoTest
class TodoFileTest(TopydoTest):
def test_empty_file(self):
......@@ -29,7 +29,8 @@ class TodoFileTest(TopydoTest):
def test_utf_8(self):
todofile = load_file('test/data/utf-8.txt')
self.assertEqual(todofile[0].source(), u('(C) \u25ba UTF-8 test \u25c4'))
self.assertEqual(todofile[0].source(),
u'(C) \u25ba UTF-8 test \u25c4')
if __name__ == '__main__':
unittest.main()
# Topydo - A todo.txt client written in Python.
# Copyright (C) 2014 Bram Schoenmakers <me@bramschoenmakers.nl>
# Copyright (C) 2014 - 2015 Bram Schoenmakers <me@bramschoenmakers.nl>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......@@ -16,12 +16,13 @@
import unittest
from test.facilities import load_file, print_view, todolist_to_string
from test.topydo_testcase import TopydoTest
from topydo.lib import Filter
from topydo.lib.Sorter import Sorter
from test.TestFacilities import load_file, todolist_to_string, print_view
from topydo.lib.TodoFile import TodoFile
from topydo.lib.TodoList import TodoList
from test.TopydoTest import TopydoTest
class ViewTest(TopydoTest):
def test_view(self):
......@@ -38,4 +39,3 @@ class ViewTest(TopydoTest):
if __name__ == '__main__':
unittest.main()
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment