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

Merge branch 'master' into column-ui

parents 393d4d03 0c7a3aa3
[run] [run]
source = topydo source = topydo
branch = True
[report] [report]
exclude_lines = exclude_lines =
...@@ -11,5 +12,5 @@ exclude_lines = ...@@ -11,5 +12,5 @@ exclude_lines =
if __name__ == .__main__.: if __name__ == .__main__.:
omit = omit =
topydo/lib/ExitCommand.py topydo/commands/ExitCommand.py
topydo/lib/Version.py topydo/lib/Version.py
*.pyc *.py[cod]
*.sw? *.sw?
install install
.coverage .coverage
...@@ -11,6 +11,7 @@ build/ ...@@ -11,6 +11,7 @@ build/
develop-eggs/ develop-eggs/
dist/ dist/
eggs/ eggs/
htmlcov/
lib/ lib/
lib64/ lib64/
parts/ parts/
...@@ -19,6 +20,9 @@ var/ ...@@ -19,6 +20,9 @@ var/
*.egg-info/ *.egg-info/
.installed.cfg .installed.cfg
*.egg *.egg
.eggs/
# Sublime Text # Sublime Text
*.sublime-* *.sublime-*
!/topydo/lib/
sudo: false # run on new infrastructure sudo: false # run on new infrastructure
language: python language: python
python: python:
- "2.7"
- "3.2"
- "3.3" - "3.3"
- "3.4" - "3.4"
- "3.5"
- "pypy3"
install: install:
- "python -m pip install pip --upgrade"
- "pip install ." - "pip install ."
- "pip install urwid" - "pip install urwid"
- "pip install icalendar" - "pip install .[ical]"
- "pip install .[prompt-toolkit]"
- "pip install .[test]"
- "pip install pylint" - "pip install pylint"
script: "./run-tests.sh" - "pip install codecov"
script:
- "green -vvr"
- "python -m pylint --errors-only topydo test"
# Cache Dependencies # Cache Dependencies
after_script:
- codecov
cache: cache:
directories: directories:
- $HOME/travis/.cache/pip - $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 0.6
--- ---
...@@ -16,7 +113,9 @@ ...@@ -16,7 +113,9 @@
--- ---
* Remove 'ical' subcommand in favor of 'topydo ls -f ical' * 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] [colorscheme]
project_color = project_color =
......
...@@ -5,11 +5,9 @@ smoothly into topydo. ...@@ -5,11 +5,9 @@ smoothly into topydo.
### General ### General
* This Github page defaults to the **stable** branch which is for **bug fixes * Use descriptive commit messages. The post
only**. If you would like to add a new feature, make sure to make a Pull [How to write a commit message](http://chris.beams.io/posts/git-commit/) by
Request on the `master` branch. Chris Beams has some good guidelines.
* Use descriptive commit messages.
### Coding style ### Coding style
...@@ -17,37 +15,63 @@ smoothly into topydo. ...@@ -17,37 +15,63 @@ smoothly into topydo.
possible. I won't be very picky about long lines, but please try to avoid possible. I won't be very picky about long lines, but please try to avoid
them. them.
* I strongly prefer simple and short functions, doing only one thing. I'll * 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. otherwise on a screen.
### Testing ### Testing
* Run tests with: * First make sure to have the prerequisites installed to perform the tests:
pip install .[test]
* Then, run the tests with:
./run-tests.sh [python2|python3] green -r
Obviously, I won't accept anything that makes the tests fail. When you submit 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 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. 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): * 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. 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. 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 * Check the test coverage of your contributed code, in particular if you touched
touched code in the topydo.lib or topydo.command packages: code in the topydo.lib or topydo.command packages:
pip install coverage coverage report -m
coverage run setup.py test
coverage report
Or alternatively, for a more friendly output, run: Or alternatively, for a more friendly output, run:
coverage html 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). 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 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 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 inspired by the [todo.txt CLI][2] by Gina Trapani. This tool is actually a
...@@ -28,10 +28,20 @@ Simply install with: ...@@ -28,10 +28,20 @@ Simply install with:
### Optional dependencies ### Optional dependencies
* icalendar : To print your todo.txt file as an iCalendar file * [icalendar][7] : To print your todo.txt file as an iCalendar file
(not supported for Python 3.2). (not supported for Python 3.2).
* prompt-toolkit : For topydo's _prompt_ mode, which offers a shell-like * [prompt-toolkit][6] : For topydo's _prompt_ mode, which offers a shell-like
interface with auto-completion. 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 Demo
---- ----
...@@ -43,4 +53,10 @@ Demo ...@@ -43,4 +53,10 @@ Demo
[2]: https://github.com/ginatrapani/todo.txt-cli [2]: https://github.com/ginatrapani/todo.txt-cli
[3]: https://github.com/bram85/todo.txt-tools [3]: https://github.com/bram85/todo.txt-tools
[4]: https://github.com/bram85/topydo/wiki [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): ...@@ -20,12 +20,6 @@ def find_version(*file_paths):
return version_match.group(1) return version_match.group(1)
raise RuntimeError("Unable to find version string.") raise RuntimeError("Unable to find version string.")
conditional_dependencies = {
"colorama>=0.2.5": "win32" in sys.platform,
}
setup( setup(
name = "topydo", name = "topydo",
packages = find_packages(exclude=["test"]), packages = find_packages(exclude=["test"]),
...@@ -35,13 +29,16 @@ setup( ...@@ -35,13 +29,16 @@ setup(
author_email = "me@bramschoenmakers.nl", author_email = "me@bramschoenmakers.nl",
url = "https://github.com/bram85/topydo", url = "https://github.com/bram85/topydo",
install_requires = [ install_requires = [
'six >= 1.9.0', 'arrow >= 0.7.0',
] + [p for p, cond in conditional_dependencies.items() if cond], ],
extras_require = { extras_require = {
':sys_platform=="win32"': ['colorama>=0.2.5'],
':python_version=="3.2"': ['backports.shutil_get_terminal_size>=1.0.0'],
'ical': ['icalendar'], 'ical': ['icalendar'],
'prompt-toolkit': ['prompt-toolkit >= 0.47'],
'urwid': ['urwid >= 1.3.0'], '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= { entry_points= {
'console_scripts': ['topydo = topydo.cli.UILoader:main'], 'console_scripts': ['topydo = topydo.cli.UILoader:main'],
...@@ -52,10 +49,12 @@ setup( ...@@ -52,10 +49,12 @@ setup(
"Intended Audience :: End Users/Desktop", "Intended Audience :: End Users/Desktop",
"License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)", "License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)",
"Natural Language :: English", "Natural Language :: English",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3.2", "Programming Language :: Python :: 3.2",
"Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.3",
"Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: Utilities", "Topic :: Utilities",
], ],
long_description = """\ long_description = """\
......
# Topydo - A todo.txt client written in Python. # 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 # 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 # it under the terms of the GNU General Public License as published by
...@@ -14,10 +14,9 @@ ...@@ -14,10 +14,9 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # 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 topydo.lib.Utils import escape_ansi
from test.TopydoTest import TopydoTest
class CommandTest(TopydoTest): class CommandTest(TopydoTest):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
...@@ -32,6 +31,3 @@ class CommandTest(TopydoTest): ...@@ -32,6 +31,3 @@ class CommandTest(TopydoTest):
def error(self, p_error): def error(self, p_error):
if p_error: if p_error:
self.errors += escape_ansi(p_error + "\n") 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 (D) Bar @Context1 +Project2 p:1
(C) Baz @Context1 +Project1 key:value id:1 (C) Baz @Context1 +Project1 key:value id:1
(C) Drink beer @ home (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. # 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 # 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 # it under the terms of the GNU General Public License as published by
...@@ -19,6 +19,7 @@ from topydo.lib.Todo import Todo ...@@ -19,6 +19,7 @@ from topydo.lib.Todo import Todo
from topydo.lib.TodoFile import TodoFile from topydo.lib.TodoFile import TodoFile
from topydo.lib.TodoList import TodoList from topydo.lib.TodoList import TodoList
def load_file(p_filename): def load_file(p_filename):
""" """
Loads a todo file from the given filename and returns a list of todos. Loads a todo file from the given filename and returns a list of todos.
...@@ -26,6 +27,7 @@ def load_file(p_filename): ...@@ -26,6 +27,7 @@ def load_file(p_filename):
todolist = load_file_to_raw_list(p_filename) todolist = load_file_to_raw_list(p_filename)
return [Todo(src) for src in todolist] return [Todo(src) for src in todolist]
def load_file_to_raw_list(p_filename): def load_file_to_raw_list(p_filename):
""" """
Loads a todo file from the given filename and returns a list of todo 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): ...@@ -34,6 +36,7 @@ def load_file_to_raw_list(p_filename):
todofile = TodoFile(p_filename) todofile = TodoFile(p_filename)
return todofile.read() return todofile.read()
def load_file_to_todolist(p_filename): def load_file_to_todolist(p_filename):
""" """
Loads a todo file to a TodoList instance. Loads a todo file to a TodoList instance.
...@@ -41,10 +44,12 @@ def load_file_to_todolist(p_filename): ...@@ -41,10 +44,12 @@ def load_file_to_todolist(p_filename):
todolist = load_file_to_raw_list(p_filename) todolist = load_file_to_raw_list(p_filename)
return TodoList(todolist) return TodoList(todolist)
def todolist_to_string(p_list): def todolist_to_string(p_list):
""" Converts a todo list to a single string. """ """ Converts a todo list to a single string. """
return '\n'.join([t.source() for t in p_list]) return '\n'.join([t.source() for t in p_list])
def print_view(p_view): def print_view(p_view):
printer = PrettyPrinter() printer = PrettyPrinter()
return printer.print_list(p_view.todos) return printer.print_list(p_view.todos)
# Topydo - A todo.txt client written in Python. # 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 # 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 # it under the terms of the GNU General Public License as published by
...@@ -16,10 +16,11 @@ ...@@ -16,10 +16,11 @@
import unittest import unittest
from test.command_testcase import CommandTest
from topydo.commands.AppendCommand import AppendCommand from topydo.commands.AppendCommand import AppendCommand
from test.CommandTest import CommandTest
from topydo.lib.TodoList import TodoList from topydo.lib.TodoList import TodoList
class AppendCommandTest(CommandTest): class AppendCommandTest(CommandTest):
def setUp(self): def setUp(self):
super(AppendCommandTest, self).setUp() super(AppendCommandTest, self).setUp()
...@@ -27,14 +28,16 @@ class AppendCommandTest(CommandTest): ...@@ -27,14 +28,16 @@ class AppendCommandTest(CommandTest):
self.todolist.add("Foo") self.todolist.add("Foo")
def test_append1(self): 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() command.execute()
self.assertEqual(self.output, "| 1| Foo Bar\n") self.assertEqual(self.output, "| 1| Foo Bar\n")
self.assertEqual(self.errors, "") self.assertEqual(self.errors, "")
def test_append2(self): 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() command.execute()
self.assertEqual(self.output, "") self.assertEqual(self.output, "")
...@@ -55,7 +58,8 @@ class AppendCommandTest(CommandTest): ...@@ -55,7 +58,8 @@ class AppendCommandTest(CommandTest):
self.assertEqual(self.errors, command.usage() + "\n") self.assertEqual(self.errors, command.usage() + "\n")
def test_append5(self): 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() command.execute()
self.assertEqual(self.output, "| 1| Foo Bar Baz\n") self.assertEqual(self.output, "| 1| Foo Bar Baz\n")
...@@ -80,7 +84,8 @@ class AppendCommandTest(CommandTest): ...@@ -80,7 +84,8 @@ class AppendCommandTest(CommandTest):
command.execute() command.execute()
self.assertEqual(self.output, "") 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__': if __name__ == '__main__':
unittest.main() unittest.main()
# Topydo - A todo.txt client written in Python. # 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 # 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 # it under the terms of the GNU General Public License as published by
...@@ -16,11 +16,12 @@ ...@@ -16,11 +16,12 @@
import unittest import unittest
from test.command_testcase import CommandTest
from test.facilities import load_file_to_todolist
from topydo.commands.ArchiveCommand import ArchiveCommand 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 from topydo.lib.TodoList import TodoList
class ArchiveCommandTest(CommandTest): class ArchiveCommandTest(CommandTest):
def test_archive(self): def test_archive(self):
todolist = load_file_to_todolist("test/data/ArchiveCommandTest.txt") todolist = load_file_to_todolist("test/data/ArchiveCommandTest.txt")
...@@ -36,4 +37,3 @@ class ArchiveCommandTest(CommandTest): ...@@ -36,4 +37,3 @@ class ArchiveCommandTest(CommandTest):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
# Topydo - A todo.txt client written in Python. # 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 # 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 # it under the terms of the GNU General Public License as published by
...@@ -17,9 +17,11 @@ ...@@ -17,9 +17,11 @@
""" Tests for the colorscheme functionality. """ """ Tests for the colorscheme functionality. """
import unittest 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 topydo.lib.Config import config
from test.TopydoTest import TopydoTest
class ColorsTest(TopydoTest): class ColorsTest(TopydoTest):
def test_project_color1(self): def test_project_color1(self):
...@@ -183,3 +185,6 @@ class ColorsTest(TopydoTest): ...@@ -183,3 +185,6 @@ class ColorsTest(TopydoTest):
self.assertEqual(context_color, '\033[1;35m') self.assertEqual(context_color, '\033[1;35m')
self.assertEqual(link_color, '\033[4;36m') self.assertEqual(link_color, '\033[4;36m')
self.assertEqual(metadata_color, '\033[1;32m') 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 @@ ...@@ -15,20 +15,22 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
import unittest import unittest
from six import u
from test.CommandTest import CommandTest from test.command_testcase import CommandTest
from topydo.lib.Config import config
from topydo.commands.DeleteCommand import DeleteCommand from topydo.commands.DeleteCommand import DeleteCommand
from topydo.lib.Config import config
from topydo.lib.TodoList import TodoList from topydo.lib.TodoList import TodoList
from topydo.lib.TodoListBase import InvalidTodoException from topydo.lib.TodoListBase import InvalidTodoException
def _yes_prompt(self): def _yes_prompt(self):
return "y" return "y"
def _no_prompt(self): def _no_prompt(self):
return "n" return "n"
class DeleteCommandTest(CommandTest): class DeleteCommandTest(CommandTest):
def setUp(self): def setUp(self):
super(DeleteCommandTest, self).setUp() super(DeleteCommandTest, self).setUp()
...@@ -42,7 +44,8 @@ class DeleteCommandTest(CommandTest): ...@@ -42,7 +44,8 @@ class DeleteCommandTest(CommandTest):
self.todolist = TodoList(todos) self.todolist = TodoList(todos)
def test_del1(self): 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() command.execute()
self.assertTrue(self.todolist.is_dirty()) self.assertTrue(self.todolist.is_dirty())
...@@ -51,7 +54,8 @@ class DeleteCommandTest(CommandTest): ...@@ -51,7 +54,8 @@ class DeleteCommandTest(CommandTest):
self.assertEqual(self.errors, "") self.assertEqual(self.errors, "")
def test_del1_regex(self): 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() command.execute()
self.assertTrue(self.todolist.is_dirty()) self.assertTrue(self.todolist.is_dirty())
...@@ -60,16 +64,19 @@ class DeleteCommandTest(CommandTest): ...@@ -60,16 +64,19 @@ class DeleteCommandTest(CommandTest):
self.assertEqual(self.errors, "") self.assertEqual(self.errors, "")
def test_del2(self): 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() command.execute()
self.assertTrue(self.todolist.is_dirty()) self.assertTrue(self.todolist.is_dirty())
self.assertEqual(self.todolist.count(), 2) 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, "") self.assertEqual(self.errors, "")
def test_del3(self): 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() command.execute()
self.assertTrue(self.todolist.is_dirty()) self.assertTrue(self.todolist.is_dirty())
...@@ -78,7 +85,8 @@ class DeleteCommandTest(CommandTest): ...@@ -78,7 +85,8 @@ class DeleteCommandTest(CommandTest):
self.assertEqual(self.errors, "") self.assertEqual(self.errors, "")
def test_del4(self): 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() command.execute()
self.assertTrue(self.todolist.is_dirty()) self.assertTrue(self.todolist.is_dirty())
...@@ -125,7 +133,8 @@ class DeleteCommandTest(CommandTest): ...@@ -125,7 +133,8 @@ class DeleteCommandTest(CommandTest):
def test_multi_del1(self): def test_multi_del1(self):
""" Test deletion of multiple items. """ """ 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() command.execute()
result = "a @test with due:2015-06-03\na @test with +project" result = "a @test with due:2015-06-03\na @test with +project"
...@@ -135,7 +144,8 @@ class DeleteCommandTest(CommandTest): ...@@ -135,7 +144,8 @@ class DeleteCommandTest(CommandTest):
def test_multi_del2(self): def test_multi_del2(self):
""" Test deletion of multiple items. """ """ 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() command.execute()
result = "a @test with due:2015-06-03\na @test with +project" result = "a @test with due:2015-06-03\na @test with +project"
...@@ -145,7 +155,8 @@ class DeleteCommandTest(CommandTest): ...@@ -145,7 +155,8 @@ class DeleteCommandTest(CommandTest):
def test_multi_del3(self): def test_multi_del3(self):
""" Fail if any of supplied todo numbers is invalid. """ """ 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() command.execute()
self.assertFalse(self.todolist.is_dirty()) self.assertFalse(self.todolist.is_dirty())
...@@ -154,7 +165,8 @@ class DeleteCommandTest(CommandTest): ...@@ -154,7 +165,8 @@ class DeleteCommandTest(CommandTest):
def test_multi_del4(self): def test_multi_del4(self):
""" Check output when all supplied todo numbers are invalid. """ """ 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() command.execute()
self.assertFalse(self.todolist.is_dirty()) self.assertFalse(self.todolist.is_dirty())
...@@ -162,16 +174,21 @@ class DeleteCommandTest(CommandTest): ...@@ -162,16 +174,21 @@ class DeleteCommandTest(CommandTest):
self.assertEqual(self.errors, "Invalid todo number given: 99.\nInvalid todo number given: A.\n") self.assertEqual(self.errors, "Invalid todo number given: 99.\nInvalid todo number given: A.\n")
def test_multi_del5(self): 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() command.execute()
self.assertFalse(self.todolist.is_dirty()) self.assertFalse(self.todolist.is_dirty())
self.assertEqual(self.output, "") 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): 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() command.execute()
result = "Removed: a @test with due:2015-06-03\nRemoved: a @test with +project\n" result = "Removed: a @test with due:2015-06-03\nRemoved: a @test with +project\n"
...@@ -182,7 +199,8 @@ class DeleteCommandTest(CommandTest): ...@@ -182,7 +199,8 @@ class DeleteCommandTest(CommandTest):
self.assertEqual(self.errors, "") self.assertEqual(self.errors, "")
def test_expr_del2(self): 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() command.execute()
self.assertTrue(self.todolist.is_dirty()) self.assertTrue(self.todolist.is_dirty())
...@@ -190,14 +208,16 @@ class DeleteCommandTest(CommandTest): ...@@ -190,14 +208,16 @@ class DeleteCommandTest(CommandTest):
self.assertEqual(self.errors, "") self.assertEqual(self.errors, "")
def test_expr_del3(self): 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() command.execute()
self.assertFalse(self.todolist.is_dirty()) self.assertFalse(self.todolist.is_dirty())
def test_expr_del4(self): def test_expr_del4(self):
""" Remove only relevant todo items. """ """ 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() command.execute()
result = "Foo" result = "Foo"
...@@ -208,7 +228,8 @@ class DeleteCommandTest(CommandTest): ...@@ -208,7 +228,8 @@ class DeleteCommandTest(CommandTest):
def test_expr_del5(self): def test_expr_del5(self):
""" Force deleting unrelevant items with additional -x flag. """ """ 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() command.execute()
self.assertTrue(self.todolist.is_dirty()) self.assertTrue(self.todolist.is_dirty())
...@@ -227,7 +248,8 @@ class DeleteCommandTest(CommandTest): ...@@ -227,7 +248,8 @@ class DeleteCommandTest(CommandTest):
command.execute() command.execute()
self.assertEqual(self.output, "") 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__': if __name__ == '__main__':
unittest.main() unittest.main()
# Topydo - A todo.txt client written in Python. # 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 # 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 # it under the terms of the GNU General Public License as published by
...@@ -16,10 +16,11 @@ ...@@ -16,10 +16,11 @@
import unittest import unittest
from test.command_testcase import CommandTest
from topydo.commands.DepCommand import DepCommand from topydo.commands.DepCommand import DepCommand
from test.CommandTest import CommandTest
from topydo.lib.TodoList import TodoList from topydo.lib.TodoList import TodoList
class DepCommandTest(CommandTest): class DepCommandTest(CommandTest):
def setUp(self): def setUp(self):
super(DepCommandTest, self).setUp() super(DepCommandTest, self).setUp()
...@@ -35,7 +36,8 @@ class DepCommandTest(CommandTest): ...@@ -35,7 +36,8 @@ class DepCommandTest(CommandTest):
self.todolist = TodoList(todos) self.todolist = TodoList(todos)
def test_add1(self): 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() command.execute()
self.assertTrue(self.todolist.is_dirty()) self.assertTrue(self.todolist.is_dirty())
...@@ -44,7 +46,8 @@ class DepCommandTest(CommandTest): ...@@ -44,7 +46,8 @@ class DepCommandTest(CommandTest):
self.assertEqual(self.errors, "") self.assertEqual(self.errors, "")
def test_add2(self): 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() command.execute()
self.assertTrue(self.todolist.is_dirty()) self.assertTrue(self.todolist.is_dirty())
...@@ -53,7 +56,8 @@ class DepCommandTest(CommandTest): ...@@ -53,7 +56,8 @@ class DepCommandTest(CommandTest):
self.assertEqual(self.errors, "") self.assertEqual(self.errors, "")
def test_add3(self): 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() command.execute()
self.assertFalse(self.todolist.is_dirty()) self.assertFalse(self.todolist.is_dirty())
...@@ -61,7 +65,8 @@ class DepCommandTest(CommandTest): ...@@ -61,7 +65,8 @@ class DepCommandTest(CommandTest):
self.assertEqual(self.errors, "Invalid todo number given.\n") self.assertEqual(self.errors, "Invalid todo number given.\n")
def test_add4(self): 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() command.execute()
self.assertFalse(self.todolist.is_dirty()) self.assertFalse(self.todolist.is_dirty())
...@@ -77,7 +82,8 @@ class DepCommandTest(CommandTest): ...@@ -77,7 +82,8 @@ class DepCommandTest(CommandTest):
self.assertEqual(self.errors, command.usage() + "\n") self.assertEqual(self.errors, command.usage() + "\n")
def test_add6(self): 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() command.execute()
self.assertTrue(self.todolist.is_dirty()) self.assertTrue(self.todolist.is_dirty())
...@@ -86,7 +92,8 @@ class DepCommandTest(CommandTest): ...@@ -86,7 +92,8 @@ class DepCommandTest(CommandTest):
self.assertEqual(self.errors, "") self.assertEqual(self.errors, "")
def test_add7(self): 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() command.execute()
self.assertTrue(self.todolist.is_dirty()) self.assertTrue(self.todolist.is_dirty())
...@@ -95,7 +102,8 @@ class DepCommandTest(CommandTest): ...@@ -95,7 +102,8 @@ class DepCommandTest(CommandTest):
self.assertEqual(self.errors, "") self.assertEqual(self.errors, "")
def test_add8(self): 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() command.execute()
self.assertTrue(self.todolist.is_dirty()) self.assertTrue(self.todolist.is_dirty())
...@@ -104,7 +112,8 @@ class DepCommandTest(CommandTest): ...@@ -104,7 +112,8 @@ class DepCommandTest(CommandTest):
self.assertEqual(self.errors, "") self.assertEqual(self.errors, "")
def test_add9(self): 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() command.execute()
self.assertTrue(self.todolist.is_dirty()) self.assertTrue(self.todolist.is_dirty())
...@@ -117,7 +126,6 @@ class DepCommandTest(CommandTest): ...@@ -117,7 +126,6 @@ class DepCommandTest(CommandTest):
Helper function that checks the removal of the dependency from todo 1 Helper function that checks the removal of the dependency from todo 1
to todo 3. to todo 3.
""" """
command = DepCommand(p_args, self.todolist, self.out, self.error) command = DepCommand(p_args, self.todolist, self.out, self.error)
command.execute() command.execute()
...@@ -140,7 +148,8 @@ class DepCommandTest(CommandTest): ...@@ -140,7 +148,8 @@ class DepCommandTest(CommandTest):
self.rm_helper(["del", "1", "3"]) self.rm_helper(["del", "1", "3"])
def test_rm3(self): 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() command.execute()
self.assertFalse(self.todolist.is_dirty()) self.assertFalse(self.todolist.is_dirty())
...@@ -148,7 +157,8 @@ class DepCommandTest(CommandTest): ...@@ -148,7 +157,8 @@ class DepCommandTest(CommandTest):
self.assertEqual(self.errors, "Invalid todo number given.\n") self.assertEqual(self.errors, "Invalid todo number given.\n")
def test_rm4(self): 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() command.execute()
self.assertFalse(self.todolist.is_dirty()) self.assertFalse(self.todolist.is_dirty())
...@@ -164,7 +174,8 @@ class DepCommandTest(CommandTest): ...@@ -164,7 +174,8 @@ class DepCommandTest(CommandTest):
self.assertEqual(self.errors, command.usage() + "\n") self.assertEqual(self.errors, command.usage() + "\n")
def test_ls1(self): 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() command.execute()
self.assertFalse(self.todolist.is_dirty()) self.assertFalse(self.todolist.is_dirty())
...@@ -172,7 +183,8 @@ class DepCommandTest(CommandTest): ...@@ -172,7 +183,8 @@ class DepCommandTest(CommandTest):
self.assertEqual(self.errors, "") self.assertEqual(self.errors, "")
def test_ls2(self): 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() command.execute()
self.assertFalse(self.todolist.is_dirty()) self.assertFalse(self.todolist.is_dirty())
...@@ -180,7 +192,8 @@ class DepCommandTest(CommandTest): ...@@ -180,7 +192,8 @@ class DepCommandTest(CommandTest):
self.assertEqual(self.errors, "Invalid todo number given.\n") self.assertEqual(self.errors, "Invalid todo number given.\n")
def test_ls3(self): 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() command.execute()
self.assertFalse(self.todolist.is_dirty()) self.assertFalse(self.todolist.is_dirty())
...@@ -188,7 +201,8 @@ class DepCommandTest(CommandTest): ...@@ -188,7 +201,8 @@ class DepCommandTest(CommandTest):
self.assertEqual(self.errors, "") self.assertEqual(self.errors, "")
def test_ls4(self): 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() command.execute()
self.assertFalse(self.todolist.is_dirty()) self.assertFalse(self.todolist.is_dirty())
...@@ -212,7 +226,8 @@ class DepCommandTest(CommandTest): ...@@ -212,7 +226,8 @@ class DepCommandTest(CommandTest):
self.assertEqual(self.errors, command.usage() + "\n") self.assertEqual(self.errors, command.usage() + "\n")
def test_ls7(self): 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() command.execute()
self.assertFalse(self.todolist.is_dirty()) self.assertFalse(self.todolist.is_dirty())
...@@ -220,7 +235,8 @@ class DepCommandTest(CommandTest): ...@@ -220,7 +235,8 @@ class DepCommandTest(CommandTest):
self.assertEqual(self.errors, command.usage() + "\n") self.assertEqual(self.errors, command.usage() + "\n")
def gc_helper(self, p_subcommand): 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() command.execute()
self.assertTrue(self.todolist.is_dirty()) self.assertTrue(self.todolist.is_dirty())
...@@ -255,7 +271,8 @@ class DepCommandTest(CommandTest): ...@@ -255,7 +271,8 @@ class DepCommandTest(CommandTest):
command.execute() command.execute()
self.assertEqual(self.output, "") 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__': if __name__ == '__main__':
unittest.main() unittest.main()
# Topydo - A todo.txt client written in Python. # 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 # 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 # it under the terms of the GNU General Public License as published by
...@@ -15,12 +15,12 @@ ...@@ -15,12 +15,12 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
import unittest import unittest
from six import u
from test.command_testcase import CommandTest
from topydo.commands.DepriCommand import DepriCommand from topydo.commands.DepriCommand import DepriCommand
from test.CommandTest import CommandTest
from topydo.lib.TodoList import TodoList from topydo.lib.TodoList import TodoList
class DepriCommandTest(CommandTest): class DepriCommandTest(CommandTest):
def setUp(self): def setUp(self):
super(DepriCommandTest, self).setUp() super(DepriCommandTest, self).setUp()
...@@ -63,7 +63,8 @@ class DepriCommandTest(CommandTest): ...@@ -63,7 +63,8 @@ class DepriCommandTest(CommandTest):
self.assertEqual(self.errors, "") self.assertEqual(self.errors, "")
def test_depri4(self): 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() command.execute()
self.assertTrue(self.todolist.is_dirty()) self.assertTrue(self.todolist.is_dirty())
...@@ -73,10 +74,10 @@ class DepriCommandTest(CommandTest): ...@@ -73,10 +74,10 @@ class DepriCommandTest(CommandTest):
self.assertEqual(self.errors, "") self.assertEqual(self.errors, "")
def test_expr_depri1(self): 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() 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" 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()) self.assertTrue(self.todolist.is_dirty())
...@@ -84,7 +85,8 @@ class DepriCommandTest(CommandTest): ...@@ -84,7 +85,8 @@ class DepriCommandTest(CommandTest):
self.assertEqual(self.errors, "") self.assertEqual(self.errors, "")
def test_expr_depri2(self): 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() command.execute()
result = "Priority removed.\n| 4| a @test with due:2015-06-03\n" result = "Priority removed.\n| 4| a @test with due:2015-06-03\n"
...@@ -94,29 +96,30 @@ class DepriCommandTest(CommandTest): ...@@ -94,29 +96,30 @@ class DepriCommandTest(CommandTest):
self.assertEqual(self.errors, "") self.assertEqual(self.errors, "")
def test_expr_depri3(self): 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() command.execute()
self.assertFalse(self.todolist.is_dirty()) self.assertFalse(self.todolist.is_dirty())
def test_expr_depri4(self): def test_expr_depri4(self):
""" Don't remove priority from unrelevant todo items. """ """ 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() command.execute()
self.assertFalse(self.todolist.is_dirty()) self.assertFalse(self.todolist.is_dirty())
def test_expr_depri5(self): def test_expr_depri5(self):
""" Force unprioritizing unrelevant items with additional -x flag. """ """ 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() command.execute()
self.assertTrue(self.todolist.is_dirty()) self.assertTrue(self.todolist.is_dirty())
self.assertEqual(self.output, "Priority removed.\n| 6| Bax id:1\n") self.assertEqual(self.output, "Priority removed.\n| 6| Bax id:1\n")
self.assertEqual(self.errors, "") self.assertEqual(self.errors, "")
def test_invalid1(self): def test_invalid1(self):
command = DepriCommand(["99"], self.todolist, self.out, self.error) command = DepriCommand(["99"], self.todolist, self.out, self.error)
command.execute() command.execute()
...@@ -126,7 +129,8 @@ class DepriCommandTest(CommandTest): ...@@ -126,7 +129,8 @@ class DepriCommandTest(CommandTest):
self.assertEqual(self.errors, "Invalid todo number given.\n") self.assertEqual(self.errors, "Invalid todo number given.\n")
def test_invalid2(self): 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() command.execute()
self.assertFalse(self.todolist.is_dirty()) self.assertFalse(self.todolist.is_dirty())
...@@ -134,7 +138,8 @@ class DepriCommandTest(CommandTest): ...@@ -134,7 +138,8 @@ class DepriCommandTest(CommandTest):
self.assertEqual(self.errors, "Invalid todo number given: 99.\n") self.assertEqual(self.errors, "Invalid todo number given: 99.\n")
def test_invalid3(self): 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() command.execute()
self.assertFalse(self.todolist.is_dirty()) self.assertFalse(self.todolist.is_dirty())
...@@ -142,13 +147,17 @@ class DepriCommandTest(CommandTest): ...@@ -142,13 +147,17 @@ class DepriCommandTest(CommandTest):
self.assertEqual(self.errors, "Invalid todo number given: 99.\nInvalid todo number given: FooBar.\n") self.assertEqual(self.errors, "Invalid todo number given: 99.\nInvalid todo number given: FooBar.\n")
def test_invalid4(self): 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() command.execute()
self.assertFalse(self.todolist.is_dirty()) self.assertFalse(self.todolist.is_dirty())
self.assertFalse(self.output) 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): def test_empty(self):
command = DepriCommand([], self.todolist, self.out, self.error) command = DepriCommand([], self.todolist, self.out, self.error)
...@@ -163,7 +172,8 @@ class DepriCommandTest(CommandTest): ...@@ -163,7 +172,8 @@ class DepriCommandTest(CommandTest):
command.execute() command.execute()
self.assertEqual(self.output, "") 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__': if __name__ == '__main__':
unittest.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. # 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 # 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 # it under the terms of the GNU General Public License as published by
...@@ -16,8 +16,9 @@ ...@@ -16,8 +16,9 @@
import unittest import unittest
from test.topydo_testcase import TopydoTest
from topydo.lib.Graph import DirectedGraph from topydo.lib.Graph import DirectedGraph
from test.TopydoTest import TopydoTest
class GraphTest(TopydoTest): class GraphTest(TopydoTest):
def setUp(self): def setUp(self):
...@@ -63,7 +64,8 @@ class GraphTest(TopydoTest): ...@@ -63,7 +64,8 @@ class GraphTest(TopydoTest):
self.assertEqual(self.graph.incoming_neighbors(1, True), set()) self.assertEqual(self.graph.incoming_neighbors(1, True), set())
def test_incoming_neighbors4(self): 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): def test_outgoing_neighbors1(self):
self.assertEqual(self.graph.outgoing_neighbors(1), set([2, 3])) self.assertEqual(self.graph.outgoing_neighbors(1), set([2, 3]))
...@@ -72,7 +74,8 @@ class GraphTest(TopydoTest): ...@@ -72,7 +74,8 @@ class GraphTest(TopydoTest):
self.assertEqual(self.graph.outgoing_neighbors(2), set([4])) self.assertEqual(self.graph.outgoing_neighbors(2), set([4]))
def test_outgoing_neighbors3(self): 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): def test_outgoing_neighbors4(self):
self.assertEqual(self.graph.outgoing_neighbors(3), set([5])) self.assertEqual(self.graph.outgoing_neighbors(3), set([5]))
......
# Topydo - A todo.txt client written in Python. # 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 # 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 # it under the terms of the GNU General Public License as published by
...@@ -14,31 +14,47 @@ ...@@ -14,31 +14,47 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
from datetime import date
import unittest 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.Config import config
from topydo.lib.Importance import importance from topydo.lib.Importance import importance
from topydo.lib.Todo import Todo from topydo.lib.Todo import Todo
from test.TopydoTest import TopydoTest
@freeze_time("2015, 11, 06")
class ImportanceTest(TopydoTest): class ImportanceTest(TopydoTest):
def test_importance1(self): def test_importance01(self):
todo = Todo("Foo") todo = Todo("Foo")
self.assertEqual(importance(todo), 2) self.assertEqual(importance(todo), 2)
def test_importance2(self): def test_importance02(self):
todo = Todo("(A) Foo") todo = Todo("(A) Foo")
self.assertEqual(importance(todo), 5) self.assertEqual(importance(todo), 5)
def test_importance3(self): def test_importance03(self):
todo = Todo("(A) Foo " + config().tag_star() + ":1") todo = Todo("(A) Foo " + config().tag_star() + ":1")
self.assertEqual(importance(todo), 6) self.assertEqual(importance(todo), 6)
def test_importance4(self): def test_importance04(self):
today_str = date.today().isoformat() today_str = date.today().isoformat()
todo = Todo("(C) Foo " + config().tag_due() + ":" + today_str) todo = Todo("(C) Foo " + config().tag_due() + ":" + today_str)
self.assertEqual(importance(todo), 8) 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__': if __name__ == '__main__':
unittest.main() unittest.main()
...@@ -14,15 +14,19 @@ ...@@ -14,15 +14,19 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # 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.JsonPrinter import JsonPrinter
from topydo.lib.Todo import Todo from topydo.lib.Todo import Todo
from test.TopydoTest import TopydoTest
class JsonPrinterTest(TopydoTest): class JsonPrinterTest(TopydoTest):
""" """
Tests the functionality of printing a single todo item. Printing a list is Tests the functionality of printing a single todo item. Printing a list is
already covered by the ListCommand tests. already covered by the ListCommand tests.
""" """
def test_json(self): def test_json(self):
""" Print a single todo item. """ """ Print a single todo item. """
printer = JsonPrinter() printer = JsonPrinter()
...@@ -31,3 +35,6 @@ class JsonPrinterTest(TopydoTest): ...@@ -31,3 +35,6 @@ class JsonPrinterTest(TopydoTest):
result = printer.print_todo(todo) 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"}') 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. # 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 # 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 # it under the terms of the GNU General Public License as published by
...@@ -16,9 +16,10 @@ ...@@ -16,9 +16,10 @@
import unittest import unittest
from test.command_testcase import CommandTest
from test.facilities import load_file_to_todolist
from topydo.commands.ListContextCommand import ListContextCommand from topydo.commands.ListContextCommand import ListContextCommand
from test.CommandTest import CommandTest
from test.TestFacilities import load_file_to_todolist
class ListContextCommandTest(CommandTest): class ListContextCommandTest(CommandTest):
def test_contexts1(self): def test_contexts1(self):
...@@ -26,7 +27,7 @@ class ListContextCommandTest(CommandTest): ...@@ -26,7 +27,7 @@ class ListContextCommandTest(CommandTest):
command = ListContextCommand([""], todolist, self.out, self.error) command = ListContextCommand([""], todolist, self.out, self.error)
command.execute() command.execute()
self.assertEqual(self.output,"Context1\nContext2\n") self.assertEqual(self.output, "Context1\nContext2\n")
self.assertFalse(self.errors) self.assertFalse(self.errors)
def test_contexts2(self): def test_contexts2(self):
...@@ -34,7 +35,7 @@ class ListContextCommandTest(CommandTest): ...@@ -34,7 +35,7 @@ class ListContextCommandTest(CommandTest):
command = ListContextCommand(["aaa"], todolist, self.out, self.error) command = ListContextCommand(["aaa"], todolist, self.out, self.error)
command.execute() command.execute()
self.assertEqual(self.output,"Context1\nContext2\n") self.assertEqual(self.output, "Context1\nContext2\n")
self.assertFalse(self.errors) self.assertFalse(self.errors)
def test_help(self): def test_help(self):
...@@ -42,7 +43,8 @@ class ListContextCommandTest(CommandTest): ...@@ -42,7 +43,8 @@ class ListContextCommandTest(CommandTest):
command.execute() command.execute()
self.assertEqual(self.output, "") 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__': if __name__ == '__main__':
unittest.main() unittest.main()
This diff is collapsed.
# Topydo - A todo.txt client written in Python. # 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 # 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 # it under the terms of the GNU General Public License as published by
...@@ -16,9 +16,10 @@ ...@@ -16,9 +16,10 @@
import unittest import unittest
from test.command_testcase import CommandTest
from test.facilities import load_file_to_todolist
from topydo.commands.ListProjectCommand import ListProjectCommand from topydo.commands.ListProjectCommand import ListProjectCommand
from test.CommandTest import CommandTest
from test.TestFacilities import load_file_to_todolist
class ListProjectCommandTest(CommandTest): class ListProjectCommandTest(CommandTest):
def test_projects1(self): def test_projects1(self):
...@@ -42,7 +43,8 @@ class ListProjectCommandTest(CommandTest): ...@@ -42,7 +43,8 @@ class ListProjectCommandTest(CommandTest):
command.execute() command.execute()
self.assertEqual(self.output, "") 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__': if __name__ == '__main__':
unittest.main() unittest.main()
# Topydo - A todo.txt client written in Python. # 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 # 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 # it under the terms of the GNU General Public License as published by
...@@ -14,13 +14,14 @@ ...@@ -14,13 +14,14 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
from datetime import date, timedelta
import unittest import unittest
from datetime import date, timedelta
from test.topydo_testcase import TopydoTest
from topydo.lib.Config import config 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 topydo.lib.Todo import Todo
from test.TopydoTest import TopydoTest
class RecurrenceTest(TopydoTest): class RecurrenceTest(TopydoTest):
def setUp(self): def setUp(self):
...@@ -164,12 +165,14 @@ class RecurrenceTest(TopydoTest): ...@@ -164,12 +165,14 @@ class RecurrenceTest(TopydoTest):
def test_no_recurrence(self): def test_no_recurrence(self):
self.todo.remove_tag('rec') 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): def test_invalid_recurrence(self):
""" Throw exception when 'rec' tag has an invalid value. """ """ Throw exception when 'rec' tag has an invalid value. """
self.todo.set_tag('rec', '1') 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__': if __name__ == '__main__':
unittest.main() unittest.main()
# Topydo - A todo.txt client written in Python. # 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 # 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 # it under the terms of the GNU General Public License as published by
...@@ -14,21 +14,23 @@ ...@@ -14,21 +14,23 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
from datetime import date, timedelta
import unittest 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 topydo.lib.RelativeDate import relative_date_to_date
from test.TopydoTest import TopydoTest
@freeze_time('2015, 11, 06')
class RelativeDateTester(TopydoTest): class RelativeDateTester(TopydoTest):
def setUp(self): def setUp(self):
super(RelativeDateTester, self).setUp() super(RelativeDateTester, self).setUp()
self.today = date.today() self.yesterday = date(2015, 11, 5)
self.tomorrow = self.today + timedelta(1) self.today = date(2015, 11, 6)
self.tomorrow = date(2015, 11, 7)
self.monday = self.today self.monday = date(2015, 11, 9)
if self.monday.weekday() != 0: self.friday = date(2015, 11, 13)
self.monday += timedelta(7 - self.today.weekday() % 7)
def test_zero_days(self): def test_zero_days(self):
result = relative_date_to_date('0d') result = relative_date_to_date('0d')
...@@ -40,7 +42,7 @@ class RelativeDateTester(TopydoTest): ...@@ -40,7 +42,7 @@ class RelativeDateTester(TopydoTest):
def test_one_week(self): def test_one_week(self):
result = relative_date_to_date('1w') 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): def test_one_month(self):
test_date = date(2015, 1, 10) test_date = date(2015, 1, 10)
...@@ -103,8 +105,7 @@ class RelativeDateTester(TopydoTest): ...@@ -103,8 +105,7 @@ class RelativeDateTester(TopydoTest):
self.assertEqual(result, self.today) self.assertEqual(result, self.today)
def test_today3(self): def test_today3(self):
result = relative_date_to_date('today', \ result = relative_date_to_date('today', self.tomorrow)
date.today() + timedelta(1))
self.assertEqual(result, self.today) self.assertEqual(result, self.today)
def test_tomorrow1(self): def test_tomorrow1(self):
...@@ -115,6 +116,14 @@ class RelativeDateTester(TopydoTest): ...@@ -115,6 +116,14 @@ class RelativeDateTester(TopydoTest):
result = relative_date_to_date('tom') result = relative_date_to_date('tom')
self.assertEqual(result, self.tomorrow) 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): def test_monday1(self):
result = relative_date_to_date('monday') result = relative_date_to_date('monday')
self.assertEqual(result, self.monday) self.assertEqual(result, self.monday)
...@@ -133,15 +142,23 @@ class RelativeDateTester(TopydoTest): ...@@ -133,15 +142,23 @@ class RelativeDateTester(TopydoTest):
def test_offset1(self): def test_offset1(self):
result = relative_date_to_date('1d', self.tomorrow) 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): def test_negative_period1(self):
result = relative_date_to_date('-1d') 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): def test_negative_period2(self):
result = relative_date_to_date('-0d') result = relative_date_to_date('-0d')
self.assertTrue(result, self.today) 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__': if __name__ == '__main__':
unittest.main() unittest.main()
This diff is collapsed.
# Topydo - A todo.txt client written in Python. # 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 # 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 # it under the terms of the GNU General Public License as published by
...@@ -16,10 +16,11 @@ ...@@ -16,10 +16,11 @@
import unittest 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 topydo.commands.SortCommand import SortCommand
from test.CommandTest import CommandTest from topydo.lib.Config import config
from test.TestFacilities import load_file_to_todolist
class SortCommandTest(CommandTest): class SortCommandTest(CommandTest):
def setUp(self): def setUp(self):
...@@ -27,17 +28,19 @@ class SortCommandTest(CommandTest): ...@@ -27,17 +28,19 @@ class SortCommandTest(CommandTest):
self.todolist = load_file_to_todolist("test/data/SorterTest1.txt") self.todolist = load_file_to_todolist("test/data/SorterTest1.txt")
def test_sort1(self): def test_sort1(self):
""" Alphabetically sorted """ """ Alphabetically sorted. """
command = SortCommand(["text"], self.todolist, self.out, self.error) command = SortCommand(["text"], self.todolist, self.out, self.error)
command.execute() 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): def test_sort2(self):
command = SortCommand([], self.todolist, self.out, self.error) command = SortCommand([], self.todolist, self.out, self.error)
command.execute() 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): def test_sort3(self):
""" Check that order does not influence the UID of a todo. """ """ Check that order does not influence the UID of a todo. """
...@@ -55,7 +58,8 @@ class SortCommandTest(CommandTest): ...@@ -55,7 +58,8 @@ class SortCommandTest(CommandTest):
command.execute() command.execute()
self.assertEqual(self.output, "") 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__': if __name__ == '__main__':
unittest.main() unittest.main()
This diff is collapsed.
# Topydo - A todo.txt client written in Python. # 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 # 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 # it under the terms of the GNU General Public License as published by
...@@ -14,20 +14,23 @@ ...@@ -14,20 +14,23 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
from datetime import date, timedelta
import unittest import unittest
from datetime import date, timedelta
from test.topydo_testcase import TopydoTest
from topydo.lib.Todo import Todo from topydo.lib.Todo import Todo
from test.TopydoTest import TopydoTest
def today_date(): def today_date():
today = date.today() today = date.today()
return today.isoformat() return today.isoformat()
def tomorrow_date(): def tomorrow_date():
tomorrow = date.today() + timedelta(days=1) tomorrow = date.today() + timedelta(days=1)
return tomorrow.isoformat() return tomorrow.isoformat()
class TodoTest(TopydoTest): class TodoTest(TopydoTest):
def test_due_date1(self): def test_due_date1(self):
todo = Todo("(C) Foo due:2014-06-09") todo = Todo("(C) Foo due:2014-06-09")
...@@ -37,7 +40,7 @@ class TodoTest(TopydoTest): ...@@ -37,7 +40,7 @@ class TodoTest(TopydoTest):
def test_false_date(self): def test_false_date(self):
todo = Todo("(C) Foo due:2014-04-31") todo = Todo("(C) Foo due:2014-04-31")
self.assertEqual( todo.due_date(), None ) self.assertEqual(todo.due_date(), None)
def test_active1(self): def test_active1(self):
todo = Todo("(C) Foo due:2014-01-01") todo = Todo("(C) Foo due:2014-01-01")
...@@ -87,5 +90,29 @@ class TodoTest(TopydoTest): ...@@ -87,5 +90,29 @@ class TodoTest(TopydoTest):
todo = Todo("(C) Foo t:2014-01-01 due:2014-01-02") todo = Todo("(C) Foo t:2014-01-01 due:2014-01-02")
self.assertEqual(todo.length(), 1) self.assertEqual(todo.length(), 1)
def test_length4(self):
todo = Todo("(C) Foo)")
self.assertEqual(todo.length(), 0)
def test_length5(self):
todo = Todo("(C) 2015-11-18 Foo)")
self.assertEqual(todo.length(), 0)
def test_length6(self):
todo = Todo("(C) 2015-11-18 Foo due:2015-11-19)")
self.assertEqual(todo.length(), 1)
def test_length7(self):
todo = Todo("(C) 2015-11-18 Foo due:2015-11-18)")
self.assertEqual(todo.length(), 0)
def test_length8(self):
todo = Todo("(C) 2015-11-18 Foo t:2015-11-19 due:2015-11-20)")
self.assertEqual(todo.length(), 1)
def test_length9(self):
todo = Todo("(C) 2015-11-18 Foo due:2015-11-16)")
self.assertEqual(todo.length(), 0)
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
# Topydo - A todo.txt client written in Python. # 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 # 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 # it under the terms of the GNU General Public License as published by
...@@ -16,12 +16,13 @@ ...@@ -16,12 +16,13 @@
""" Tests for the TodoBase class. """ """ Tests for the TodoBase class. """
from datetime import date, timedelta
import re import re
import unittest import unittest
from datetime import date, timedelta
from test.topydo_testcase import TopydoTest
from topydo.lib.TodoBase import TodoBase from topydo.lib.TodoBase import TodoBase
from test.TopydoTest import TopydoTest
class TodoBaseTester(TopydoTest): class TodoBaseTester(TopydoTest):
def test_parse_tag(self): def test_parse_tag(self):
...@@ -85,7 +86,7 @@ class TodoBaseTester(TopydoTest): ...@@ -85,7 +86,7 @@ class TodoBaseTester(TopydoTest):
def test_set_tag_double_value(self): def test_set_tag_double_value(self):
todo = TodoBase("(C) Foo foo:bar baz:bar") todo = TodoBase("(C) Foo foo:bar baz:bar")
todo.set_tag('foo', 'blah'); todo.set_tag('foo', 'blah')
self.assertTrue(todo.has_tag('foo')) self.assertTrue(todo.has_tag('foo'))
self.assertTrue(todo.tag_value('foo'), 'blah') self.assertTrue(todo.tag_value('foo'), 'blah')
...@@ -97,7 +98,8 @@ class TodoBaseTester(TopydoTest): ...@@ -97,7 +98,8 @@ class TodoBaseTester(TopydoTest):
todo.set_tag('foo', 'blah') todo.set_tag('foo', 'blah')
self.assertTrue(todo.has_tag('foo', 'blah')) self.assertTrue(todo.has_tag('foo', 'blah'))
self.assertTrue(todo.has_tag('foo', 'bar') or todo.has_tag('foo', 'baz')) self.assertTrue(todo.has_tag('foo', 'bar') or
todo.has_tag('foo', 'baz'))
def test_set_tag_empty_value(self): def test_set_tag_empty_value(self):
todo = TodoBase("(C) Foo foo:bar foo:baz") todo = TodoBase("(C) Foo foo:bar foo:baz")
...@@ -108,14 +110,12 @@ class TodoBaseTester(TopydoTest): ...@@ -108,14 +110,12 @@ class TodoBaseTester(TopydoTest):
def test_tag_empty_value(self): def test_tag_empty_value(self):
""" Tag should not be recorded when there is no value. """ """ Tag should not be recorded when there is no value. """
todo = TodoBase("(C) Foo foo:") todo = TodoBase("(C) Foo foo:")
self.assertFalse(todo.has_tag('foo')) self.assertFalse(todo.has_tag('foo'))
def test_tag_empty_key(self): def test_tag_empty_key(self):
""" Tag should not be recorded when there is no key. """ """ Tag should not be recorded when there is no key. """
todo = TodoBase("(C) Foo :bar") todo = TodoBase("(C) Foo :bar")
self.assertFalse(todo.has_tag('')) self.assertFalse(todo.has_tag(''))
...@@ -259,7 +259,7 @@ class TodoBaseTester(TopydoTest): ...@@ -259,7 +259,7 @@ class TodoBaseTester(TopydoTest):
today_str = today.isoformat() today_str = today.isoformat()
self.assertEqual(todo.fields['completionDate'], today) self.assertEqual(todo.fields['completionDate'], today)
self.assertTrue(re.match('^x ' + today_str + ' 2014-06-12 Foo', \ self.assertTrue(re.match('^x ' + today_str + ' 2014-06-12 Foo',
todo.src)) todo.src))
def test_set_complete3(self): def test_set_complete3(self):
...@@ -280,7 +280,8 @@ class TodoBaseTester(TopydoTest): ...@@ -280,7 +280,8 @@ class TodoBaseTester(TopydoTest):
today_str = today.isoformat() today_str = today.isoformat()
self.assertEqual(todo.fields['completionDate'], today) self.assertEqual(todo.fields['completionDate'], today)
self.assertTrue(re.match('^x ' + today_str + ' 2014-06-12 Foo', todo.src)) self.assertTrue(re.match('^x ' + today_str + ' 2014-06-12 Foo',
todo.src))
def test_set_complete5(self): def test_set_complete5(self):
todo = TodoBase("x 2014-06-13 Foo") todo = TodoBase("x 2014-06-13 Foo")
...@@ -302,7 +303,7 @@ class TodoBaseTester(TopydoTest): ...@@ -302,7 +303,7 @@ class TodoBaseTester(TopydoTest):
todo.set_source_text(new_text) todo.set_source_text(new_text)
self.assertEqual(todo.src, new_text) self.assertEqual(todo.src, new_text)
self.assertEqual(todo.priority(),'C') self.assertEqual(todo.priority(), 'C')
def test_set_creation_date1(self): def test_set_creation_date1(self):
todo = TodoBase("Foo") todo = TodoBase("Foo")
......
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.
# Topydo - A todo.txt client written in Python. # 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 # 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 # it under the terms of the GNU General Public License as published by
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
from topydo.lib.Command import Command from topydo.lib.Command import Command
class ArchiveCommand(Command): class ArchiveCommand(Command):
def __init__(self, p_todolist, p_archive_list): def __init__(self, p_todolist, p_archive_list):
""" """
......
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