Commit c547b850 authored by Bram Schoenmakers's avatar Bram Schoenmakers

Improve coverage of JsonPrinter by printing a single todo item.

parent ead9c3b3
# Topydo - A todo.txt client written in Python.
# Copyright (C) 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/>.
from topydo.lib.JsonPrinter import JsonPrinter
from topydo.lib.Todo import Todo
from test.TopydoTest import TopydoTest
class JsonPrinterTest(TopydoTest):
"""
Tests the functionality of printing a single todo item. Printing a list is
already covered by the ListCommand tests.
"""
def test_json(self):
""" Print a single todo item. """
printer = JsonPrinter()
todo = Todo('2015-06-06 Foo due:2015-05-32')
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"}')
...@@ -224,7 +224,6 @@ class ListCommandUnicodeTest(CommandTest): ...@@ -224,7 +224,6 @@ class ListCommandUnicodeTest(CommandTest):
self.assertEqual(self.output, expected) self.assertEqual(self.output, expected)
class ListCommandJsonTest(CommandTest): class ListCommandJsonTest(CommandTest):
def test_json(self): def test_json(self):
todolist = load_file_to_todolist("test/data/ListCommandTest.txt") todolist = load_file_to_todolist("test/data/ListCommandTest.txt")
......
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