Commit c6015996 authored by Bram Schoenmakers's avatar Bram Schoenmakers

Remove relative imports.

parent 43c6beee
......@@ -16,9 +16,9 @@
from datetime import date
import AddCommand
from topydo.lib import AddCommand
import CommandTest
import TodoList
from topydo.lib import TodoList
class AddCommandTest(CommandTest.CommandTest):
def setUp(self):
......
......@@ -14,66 +14,66 @@
# 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 AppendCommand
from topydo.lib.AppendCommand import AppendCommand
import CommandTest
import TodoList
from topydo.lib.TodoList import TodoList
class AppendCommandTest(CommandTest.CommandTest):
def setUp(self):
self.todolist = TodoList.TodoList([])
self.todolist = TodoList([])
self.todolist.add("Foo")
def test_append1(self):
command = AppendCommand.AppendCommand([1, "Bar"], self.todolist, self.out, self.error)
command = AppendCommand([1, "Bar"], self.todolist, self.out, self.error)
command.execute()
self.assertEqual(self.output, " 1 Foo Bar\n")
self.assertEqual(self.errors, "")
def test_append2(self):
command = AppendCommand.AppendCommand([2, "Bar"], self.todolist, self.out, self.error)
command = AppendCommand([2, "Bar"], self.todolist, self.out, self.error)
command.execute()
self.assertEqual(self.output, "")
self.assertEqual(self.errors, "Invalid todo number given.\n")
def test_append3(self):
command = AppendCommand.AppendCommand([1, ""], self.todolist, self.out, self.error)
command = AppendCommand([1, ""], self.todolist, self.out, self.error)
command.execute()
self.assertEqual(self.output, "")
self.assertEqual(self.output, "")
def test_append4(self):
command = AppendCommand.AppendCommand([1], self.todolist, self.out, self.error)
command = AppendCommand([1], self.todolist, self.out, self.error)
command.execute()
self.assertEqual(self.output, "")
self.assertEqual(self.errors, command.usage() + "\n")
def test_append5(self):
command = AppendCommand.AppendCommand([1, "Bar", "Baz"], self.todolist, self.out, self.error)
command = AppendCommand([1, "Bar", "Baz"], self.todolist, self.out, self.error)
command.execute()
self.assertEqual(self.output, " 1 Foo Bar Baz\n")
self.assertEqual(self.errors, "")
def test_append6(self):
command = AppendCommand.AppendCommand([], self.todolist, self.out, self.error)
command = AppendCommand([], self.todolist, self.out, self.error)
command.execute()
self.assertEqual(self.output, "")
self.assertEqual(self.errors, command.usage() + "\n")
def test_append7(self):
command = AppendCommand.AppendCommand(["Bar"], self.todolist, self.out, self.error)
command = AppendCommand(["Bar"], self.todolist, self.out, self.error)
command.execute()
self.assertEqual(self.output, "")
self.assertEqual(self.errors, command.usage() + "\n")
def test_help(self):
command = AppendCommand.AppendCommand(["help"], self.todolist, self.out, self.error)
command = AppendCommand(["help"], self.todolist, self.out, self.error)
command.execute()
self.assertEquals(self.output, "")
......
......@@ -14,17 +14,17 @@
# 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 ArchiveCommand
from topydo.lib.ArchiveCommand import ArchiveCommand
import CommandTest
import TestFacilities
import TodoList
from topydo.lib.TodoList import TodoList
class ArchiveCommandTest(CommandTest.CommandTest):
def test_archive(self):
todolist = TestFacilities.load_file_to_todolist("data/ArchiveCommandTest.txt")
archive = TodoList.TodoList([])
archive = TodoList([])
command = ArchiveCommand.ArchiveCommand(todolist, archive)
command = ArchiveCommand(todolist, archive)
command.execute()
self.assertTrue(todolist.is_dirty())
......
......@@ -16,7 +16,7 @@
import unittest
from Utils import escape_ansi
from topydo.lib.Utils import escape_ansi
class CommandTest(unittest.TestCase):
def __init__(self, *args, **kwargs):
......
......@@ -16,7 +16,7 @@
import unittest
from Config import config
from topydo.lib.Config import config
class ConfigTest(unittest.TestCase):
def test_config1(self):
......
......@@ -15,8 +15,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import CommandTest
import DeleteCommand
import TodoList
from topydo.lib.DeleteCommand import DeleteCommand
from topydo.lib.TodoList import TodoList
class DeleteCommandTest(CommandTest.CommandTest):
def setUp(self):
......@@ -25,10 +25,10 @@ class DeleteCommandTest(CommandTest.CommandTest):
"Bar p:1",
]
self.todolist = TodoList.TodoList(todos)
self.todolist = TodoList(todos)
def test_del1(self):
command = DeleteCommand.DeleteCommand(["1"], self.todolist, self.out, self.error, lambda p: "n")
command = DeleteCommand(["1"], self.todolist, self.out, self.error, lambda p: "n")
command.execute()
self.assertTrue(self.todolist.is_dirty())
......@@ -37,7 +37,7 @@ class DeleteCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "")
def test_del1_regex(self):
command = DeleteCommand.DeleteCommand(["Foo"], self.todolist, self.out, self.error, lambda p: "n")
command = DeleteCommand(["Foo"], self.todolist, self.out, self.error, lambda p: "n")
command.execute()
self.assertTrue(self.todolist.is_dirty())
......@@ -46,7 +46,7 @@ class DeleteCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "")
def test_del2(self):
command = DeleteCommand.DeleteCommand(["1"], self.todolist, self.out, self.error, lambda p: "y")
command = DeleteCommand(["1"], self.todolist, self.out, self.error, lambda p: "y")
command.execute()
self.assertTrue(self.todolist.is_dirty())
......@@ -55,7 +55,7 @@ class DeleteCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "")
def test_del3(self):
command = DeleteCommand.DeleteCommand(["-f", "1"], self.todolist, self.out, self.error, lambda p: "y")
command = DeleteCommand(["-f", "1"], self.todolist, self.out, self.error, lambda p: "y")
command.execute()
self.assertTrue(self.todolist.is_dirty())
......@@ -64,7 +64,7 @@ class DeleteCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "")
def test_del4(self):
command = DeleteCommand.DeleteCommand(["--force", "1"], self.todolist, self.out, self.error, lambda p: "y")
command = DeleteCommand(["--force", "1"], self.todolist, self.out, self.error, lambda p: "y")
command.execute()
self.assertTrue(self.todolist.is_dirty())
......@@ -73,7 +73,7 @@ class DeleteCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "")
def test_del5(self):
command = DeleteCommand.DeleteCommand(["2"], self.todolist, self.out, self.error)
command = DeleteCommand(["2"], self.todolist, self.out, self.error)
command.execute()
self.assertTrue(self.todolist.is_dirty())
......@@ -82,7 +82,7 @@ class DeleteCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "")
def test_del7(self):
command = DeleteCommand.DeleteCommand(["99"], self.todolist, self.out, self.error)
command = DeleteCommand(["99"], self.todolist, self.out, self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -90,7 +90,7 @@ class DeleteCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "Invalid todo number given.\n")
def test_del8(self):
command = DeleteCommand.DeleteCommand(["A"], self.todolist, self.out, self.error)
command = DeleteCommand(["A"], self.todolist, self.out, self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -98,7 +98,7 @@ class DeleteCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "Invalid todo number given.\n")
def test_empty(self):
command = DeleteCommand.DeleteCommand([], self.todolist, self.out, self.error)
command = DeleteCommand([], self.todolist, self.out, self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -106,7 +106,7 @@ class DeleteCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, command.usage() + "\n")
def test_help(self):
command = DeleteCommand.DeleteCommand(["help"], self.todolist, self.out, self.error)
command = DeleteCommand(["help"], self.todolist, self.out, self.error)
command.execute()
self.assertEquals(self.output, "")
......
......@@ -15,8 +15,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import CommandTest
import DepCommand
import TodoList
from topydo.lib.DepCommand import DepCommand
from topydo.lib.TodoList import TodoList
class DepCommandTest(CommandTest.CommandTest):
def setUp(self):
......@@ -29,10 +29,10 @@ class DepCommandTest(CommandTest.CommandTest):
"Fart p:2",
]
self.todolist = TodoList.TodoList(todos)
self.todolist = TodoList(todos)
def test_add1(self):
command = DepCommand.DepCommand(["add", "1", "to", "4"], self.todolist, self.out, self.error)
command = DepCommand(["add", "1", "to", "4"], self.todolist, self.out, self.error)
command.execute()
self.assertTrue(self.todolist.is_dirty())
......@@ -41,7 +41,7 @@ class DepCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "")
def test_add2(self):
command = DepCommand.DepCommand(["add", "1", "4"], self.todolist, self.out, self.error)
command = DepCommand(["add", "1", "4"], self.todolist, self.out, self.error)
command.execute()
self.assertTrue(self.todolist.is_dirty())
......@@ -50,7 +50,7 @@ class DepCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "")
def test_add3(self):
command = DepCommand.DepCommand(["add", "99", "3"], self.todolist, self.out, self.error)
command = DepCommand(["add", "99", "3"], self.todolist, self.out, self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -58,7 +58,7 @@ class DepCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "Invalid todo number given.\n")
def test_add4(self):
command = DepCommand.DepCommand(["add", "A", "3"], self.todolist, self.out, self.error)
command = DepCommand(["add", "A", "3"], self.todolist, self.out, self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -66,7 +66,7 @@ class DepCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "Invalid todo number given.\n")
def test_add5(self):
command = DepCommand.DepCommand(["add", "1"], self.todolist, self.out, self.error)
command = DepCommand(["add", "1"], self.todolist, self.out, self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -74,7 +74,7 @@ class DepCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, command.usage() + "\n")
def test_add6(self):
command = DepCommand.DepCommand(["add", "1", "after", "4"], self.todolist, self.out, self.error)
command = DepCommand(["add", "1", "after", "4"], self.todolist, self.out, self.error)
command.execute()
self.assertTrue(self.todolist.is_dirty())
......@@ -83,7 +83,7 @@ class DepCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "")
def test_add7(self):
command = DepCommand.DepCommand(["add", "1", "before", "4"], self.todolist, self.out, self.error)
command = DepCommand(["add", "1", "before", "4"], self.todolist, self.out, self.error)
command.execute()
self.assertTrue(self.todolist.is_dirty())
......@@ -92,7 +92,7 @@ class DepCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "")
def test_add8(self):
command = DepCommand.DepCommand(["add", "1", "partof", "4"], self.todolist, self.out, self.error)
command = DepCommand(["add", "1", "partof", "4"], self.todolist, self.out, self.error)
command.execute()
self.assertTrue(self.todolist.is_dirty())
......@@ -101,7 +101,7 @@ class DepCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "")
def test_add9(self):
command = DepCommand.DepCommand(["add", "Foo", "to", "4"], self.todolist, self.out, self.error)
command = DepCommand(["add", "Foo", "to", "4"], self.todolist, self.out, self.error)
command.execute()
self.assertTrue(self.todolist.is_dirty())
......@@ -115,7 +115,7 @@ class DepCommandTest(CommandTest.CommandTest):
to todo 3.
"""
command = DepCommand.DepCommand(p_args, self.todolist, self.out, self.error)
command = DepCommand(p_args, self.todolist, self.out, self.error)
command.execute()
self.assertTrue(self.todolist.is_dirty())
......@@ -137,7 +137,7 @@ class DepCommandTest(CommandTest.CommandTest):
self.rm_helper(["del", "1", "3"])
def test_rm3(self):
command = DepCommand.DepCommand(["rm", "99", "3"], self.todolist, self.out, self.error)
command = DepCommand(["rm", "99", "3"], self.todolist, self.out, self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -145,7 +145,7 @@ class DepCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "Invalid todo number given.\n")
def test_rm4(self):
command = DepCommand.DepCommand(["rm", "A", "3"], self.todolist, self.out, self.error)
command = DepCommand(["rm", "A", "3"], self.todolist, self.out, self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -153,7 +153,7 @@ class DepCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "Invalid todo number given.\n")
def test_rm5(self):
command = DepCommand.DepCommand(["rm", "1"], self.todolist, self.out, self.error)
command = DepCommand(["rm", "1"], self.todolist, self.out, self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -161,7 +161,7 @@ class DepCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, command.usage() + "\n")
def test_ls1(self):
command = DepCommand.DepCommand(["ls", "1", "to"], self.todolist, self.out, self.error)
command = DepCommand(["ls", "1", "to"], self.todolist, self.out, self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -169,7 +169,7 @@ class DepCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "")
def test_ls2(self):
command = DepCommand.DepCommand(["ls", "99", "to"], self.todolist, self.out, self.error)
command = DepCommand(["ls", "99", "to"], self.todolist, self.out, self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -177,7 +177,7 @@ class DepCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "Invalid todo number given.\n")
def test_ls3(self):
command = DepCommand.DepCommand(["ls", "to", "3"], self.todolist, self.out, self.error)
command = DepCommand(["ls", "to", "3"], self.todolist, self.out, self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -185,7 +185,7 @@ class DepCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "")
def test_ls4(self):
command = DepCommand.DepCommand(["ls", "to", "99"], self.todolist, self.out, self.error)
command = DepCommand(["ls", "to", "99"], self.todolist, self.out, self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -193,7 +193,7 @@ class DepCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "Invalid todo number given.\n")
def test_ls5(self):
command = DepCommand.DepCommand(["ls", "1"], self.todolist, self.out, self.error)
command = DepCommand(["ls", "1"], self.todolist, self.out, self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -201,7 +201,7 @@ class DepCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, command.usage() + "\n")
def test_ls6(self):
command = DepCommand.DepCommand(["ls"], self.todolist, self.out, self.error)
command = DepCommand(["ls"], self.todolist, self.out, self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -209,7 +209,7 @@ class DepCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, command.usage() + "\n")
def gc_helper(self, p_subcommand):
command = DepCommand.DepCommand([p_subcommand], self.todolist, self.out, self.error)
command = DepCommand([p_subcommand], self.todolist, self.out, self.error)
command.execute()
self.assertTrue(self.todolist.is_dirty())
......@@ -224,7 +224,7 @@ class DepCommandTest(CommandTest.CommandTest):
self.gc_helper("gc")
def test_invalid_subsubcommand(self):
command = DepCommand.DepCommand(["foo"], self.todolist, self.out, self.error)
command = DepCommand(["foo"], self.todolist, self.out, self.error)
command.execute()
self.assertFalse(self.output)
......@@ -232,7 +232,7 @@ class DepCommandTest(CommandTest.CommandTest):
self.assertFalse(self.todolist.is_dirty())
def test_no_subsubcommand(self):
command = DepCommand.DepCommand([], self.todolist, self.out, self.error)
command = DepCommand([], self.todolist, self.out, self.error)
command.execute()
self.assertFalse(self.output)
......@@ -240,7 +240,7 @@ class DepCommandTest(CommandTest.CommandTest):
self.assertFalse(self.todolist.is_dirty())
def test_help(self):
command = DepCommand.DepCommand(["help"], self.todolist, self.out, self.error)
command = DepCommand(["help"], self.todolist, self.out, self.error)
command.execute()
self.assertEquals(self.output, "")
......
......@@ -15,8 +15,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import CommandTest
import DepriCommand
import TodoList
from topydo.lib.DepriCommand import DepriCommand
from topydo.lib.TodoList import TodoList
class DepriCommandTest(CommandTest.CommandTest):
def setUp(self):
......@@ -25,10 +25,10 @@ class DepriCommandTest(CommandTest.CommandTest):
"Bar",
]
self.todolist = TodoList.TodoList(todos)
self.todolist = TodoList(todos)
def test_set_prio1(self):
command = DepriCommand.DepriCommand(["1"], self.todolist, self.out, self.error)
command = DepriCommand(["1"], self.todolist, self.out, self.error)
command.execute()
self.assertTrue(self.todolist.is_dirty())
......@@ -37,7 +37,7 @@ class DepriCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "")
def test_set_prio2(self):
command = DepriCommand.DepriCommand(["2"], self.todolist, self.out, self.error)
command = DepriCommand(["2"], self.todolist, self.out, self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -46,7 +46,7 @@ class DepriCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "")
def test_set_prio3(self):
command = DepriCommand.DepriCommand(["Foo"], self.todolist, self.out, self.error)
command = DepriCommand(["Foo"], self.todolist, self.out, self.error)
command.execute()
self.assertTrue(self.todolist.is_dirty())
......@@ -55,7 +55,7 @@ class DepriCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "")
def test_invalid1(self):
command = DepriCommand.DepriCommand(["99"], self.todolist, self.out, self.error)
command = DepriCommand(["99"], self.todolist, self.out, self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -63,7 +63,7 @@ class DepriCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "Invalid todo number given.\n")
def test_empty(self):
command = DepriCommand.DepriCommand([], self.todolist, self.out, self.error)
command = DepriCommand([], self.todolist, self.out, self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -71,7 +71,7 @@ class DepriCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, command.usage() + "\n")
def test_help(self):
command = DepriCommand.DepriCommand(["help"], self.todolist, self.out, self.error)
command = DepriCommand(["help"], self.todolist, self.out, self.error)
command.execute()
self.assertEquals(self.output, "")
......
......@@ -17,8 +17,8 @@
from datetime import date, timedelta
import CommandTest
import DoCommand
import TodoList
from topydo.lib.DoCommand import DoCommand
from topydo.lib.TodoList import TodoList
def _yes_prompt(self):
return "y"
......@@ -39,14 +39,14 @@ class DoCommandTest(CommandTest.CommandTest):
"Strict due:2014-01-01 rec:1d",
]
self.todolist = TodoList.TodoList(todos)
self.todolist = TodoList(todos)
self.today = date.today()
self.tomorrow = self.today + timedelta(1)
self.today = self.today.isoformat()
self.tomorrow = self.tomorrow.isoformat()
def test_do1(self):
command = DoCommand.DoCommand(["3"], self.todolist, self.out, self.error, _no_prompt)
command = DoCommand(["3"], self.todolist, self.out, self.error, _no_prompt)
command.execute()
self.assertTrue(self.todolist.is_dirty())
......@@ -55,7 +55,7 @@ class DoCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "")
def test_do_subtasks1(self):
command = DoCommand.DoCommand(["1"], self.todolist, self.out, self.error, _yes_prompt)
command = DoCommand(["1"], self.todolist, self.out, self.error, _yes_prompt)
command.execute()
result = " 2 Bar p:1\n 3 Baz p:1\nCompleted: x %s Bar p:1\nCompleted: x %s Baz p:1\nCompleted: x %s Foo id:1\n" % (self.today, self.today, self.today)
......@@ -69,7 +69,7 @@ class DoCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "")
def test_do_subtasks2(self):
command = DoCommand.DoCommand(["1"], self.todolist, self.out, self.error, _no_prompt)
command = DoCommand(["1"], self.todolist, self.out, self.error, _no_prompt)
command.execute()
result = " 2 Bar p:1\n 3 Baz p:1\nCompleted: x %s Foo id:1\n" % self.today
......@@ -88,7 +88,7 @@ class DoCommandTest(CommandTest.CommandTest):
global prompt_shown
prompt_shown = True
command = DoCommand.DoCommand(["-f", "1"], self.todolist, self.out, self.error, prompt)
command = DoCommand(["-f", "1"], self.todolist, self.out, self.error, prompt)
command.execute()
self.assertFalse(prompt_shown)
......@@ -102,7 +102,7 @@ class DoCommandTest(CommandTest.CommandTest):
global prompt_shown
prompt_shown = True
command = DoCommand.DoCommand(["--force", "1"], self.todolist, self.out, self.error, prompt)
command = DoCommand(["--force", "1"], self.todolist, self.out, self.error, prompt)
command.execute()
self.assertFalse(prompt_shown)
......@@ -110,7 +110,7 @@ class DoCommandTest(CommandTest.CommandTest):
self.assertFalse(self.todolist.todo(2).is_completed())
def _recurrence_helper(self, p_flags):
command = DoCommand.DoCommand(p_flags, self.todolist, self.out, self.error)
command = DoCommand(p_flags, self.todolist, self.out, self.error)
command.execute()
self.assertTrue(self.todolist.is_dirty())
......@@ -142,7 +142,7 @@ class DoCommandTest(CommandTest.CommandTest):
self.assertEquals(self.output, result)
def test_invalid1(self):
command = DoCommand.DoCommand(["99"], self.todolist, self.out, self.error)
command = DoCommand(["99"], self.todolist, self.out, self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -150,7 +150,7 @@ class DoCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "Invalid todo number given.\n")
def test_invalid2(self):
command = DoCommand.DoCommand(["AAA"], self.todolist, self.out, self.error)
command = DoCommand(["AAA"], self.todolist, self.out, self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -158,7 +158,7 @@ class DoCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "Invalid todo number given.\n")
def test_activated_todos1(self):
command = DoCommand.DoCommand(["2"], self.todolist, self.out, self.error)
command = DoCommand(["2"], self.todolist, self.out, self.error)
command.execute()
first_output = "Completed: x %s Bar p:1\n" % self.today
......@@ -166,21 +166,21 @@ class DoCommandTest(CommandTest.CommandTest):
self.assertEquals(self.output, first_output)
self.assertEquals(self.errors, "")
command = DoCommand.DoCommand(["3"], self.todolist, self.out, self.error)
command = DoCommand(["3"], self.todolist, self.out, self.error)
command.execute()
self.assertEquals(self.output, first_output + "Completed: x %s Baz p:1\nThe following todo item(s) became active:\nFoo id:1\n" % self.today)
self.assertEquals(self.errors, "")
def test_activated_todos2(self):
command = DoCommand.DoCommand(["7"], self.todolist, self.out, self.error)
command = DoCommand(["7"], self.todolist, self.out, self.error)
command.execute()
self.assertEquals(self.output, "Completed: x %s Subtodo of inactive p:2\n" % self.today)
self.assertEquals(self.errors, "")
def test_already_complete(self):
command = DoCommand.DoCommand(["5"], self.todolist, self.out, self.error)
command = DoCommand(["5"], self.todolist, self.out, self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -189,7 +189,7 @@ class DoCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "Todo has already been completed.\n")
def test_do_regex1(self):
command = DoCommand.DoCommand(["baz"], self.todolist, self.out, self.error)
command = DoCommand(["baz"], self.todolist, self.out, self.error)
command.execute()
self.assertTrue(self.todolist.is_dirty())
......@@ -198,7 +198,7 @@ class DoCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "")
def test_do_custom_date1(self):
command = DoCommand.DoCommand(["-d", "2014-11-18", "3"], self.todolist, self.out, self.error)
command = DoCommand(["-d", "2014-11-18", "3"], self.todolist, self.out, self.error)
command.execute()
self.assertTrue(self.todolist.is_dirty())
......@@ -206,7 +206,7 @@ class DoCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "")
def test_do_custom_date2(self):
command = DoCommand.DoCommand(["-d", "2014-11-18", "1"], self.todolist, self.out, self.error, _yes_prompt)
command = DoCommand(["-d", "2014-11-18", "1"], self.todolist, self.out, self.error, _yes_prompt)
command.execute()
self.assertTrue(self.todolist.is_dirty())
......@@ -214,7 +214,7 @@ class DoCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "")
def test_do_custom_date3(self):
command = DoCommand.DoCommand(["--date=2014-11-18", "3"], self.todolist, self.out, self.error)
command = DoCommand(["--date=2014-11-18", "3"], self.todolist, self.out, self.error)
command.execute()
self.assertTrue(self.todolist.is_dirty())
......@@ -222,7 +222,7 @@ class DoCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "")
def test_do_custom_date4(self):
command = DoCommand.DoCommand(["-d", "foo", "3"], self.todolist, self.out, self.error)
command = DoCommand(["-d", "foo", "3"], self.todolist, self.out, self.error)
command.execute()
self.assertTrue(self.todolist.is_dirty())
......@@ -230,7 +230,7 @@ class DoCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "")
def test_empty(self):
command = DoCommand.DoCommand([], self.todolist, self.out, self.error)
command = DoCommand([], self.todolist, self.out, self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -238,7 +238,7 @@ class DoCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, command.usage() + "\n")
def test_help(self):
command = DoCommand.DoCommand(["help"], self.todolist, self.out, self.error)
command = DoCommand(["help"], self.todolist, self.out, self.error)
command.execute()
self.assertEquals(self.output, "")
......
......@@ -19,13 +19,13 @@
from datetime import date, timedelta
import unittest
import Filter
from topydo.lib import Filter
from TestFacilities import load_file, todolist_to_string, load_file_to_todolist
import Todo
from topydo.lib.Todo import Todo
class FilterTest(unittest.TestCase):
def test_filter3(self):
todo = Todo.Todo("(C) Relevant")
todo = Todo("(C) Relevant")
relevance = Filter.RelevanceFilter()
result = relevance.filter([todo])
......@@ -303,10 +303,10 @@ class OrdinalTagFilterTest(unittest.TestCase):
self.tomorrow = tomorrow.isoformat()
self.todos = [
Todo.Todo("Foo due:%s" % self.today),
Todo.Todo("Bar due:%s" % self.tomorrow),
Todo.Todo("Baz due:nonsense"),
Todo.Todo("Fnord due:2014-10-32")
Todo("Foo due:%s" % self.today),
Todo("Bar due:%s" % self.tomorrow),
Todo("Baz due:nonsense"),
Todo("Fnord due:2014-10-32")
]
def test_filter1(self):
......
......@@ -16,11 +16,11 @@
import unittest
import Graph
from topydo.lib.Graph import DirectedGraph
class GraphTest(unittest.TestCase):
def setUp(self):
self.graph = Graph.DirectedGraph()
self.graph = DirectedGraph()
self.graph.add_edge(1, 2, 1)
self.graph.add_edge(2, 4, "Test")
......
......@@ -17,24 +17,24 @@
from datetime import date
import unittest
from Config import config
from Importance import importance
import Todo
from topydo.lib.Config import config
from topydo.lib.Importance import importance
from topydo.lib.Todo import Todo
class ImportanceTest(unittest.TestCase):
def test_importance1(self):
todo = Todo.Todo("Foo")
todo = Todo("Foo")
self.assertEqual(importance(todo), 2)
def test_importance2(self):
todo = Todo.Todo("(A) Foo")
todo = Todo("(A) Foo")
self.assertEqual(importance(todo), 5)
def test_importance3(self):
todo = Todo.Todo("(A) Foo " + config().tag_star() + ":1")
todo = Todo("(A) Foo " + config().tag_star() + ":1")
self.assertEqual(importance(todo), 6)
def test_importance4(self):
today_str = date.today().isoformat()
todo = Todo.Todo("(C) Foo " + config().tag_due() + ":" + today_str)
todo = Todo("(C) Foo " + config().tag_due() + ":" + today_str)
self.assertEqual(importance(todo), 8)
......@@ -14,9 +14,9 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from Config import config
from topydo.lib.Config import config
import CommandTest
import ListCommand
from topydo.lib.ListCommand import ListCommand
import TestFacilities
class ListCommandTest(CommandTest.CommandTest):
......@@ -28,7 +28,7 @@ class ListCommandTest(CommandTest.CommandTest):
config("")
def test_list1(self):
command = ListCommand.ListCommand([""], self.todolist, self.out, self.error)
command = ListCommand([""], self.todolist, self.out, self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -36,7 +36,7 @@ class ListCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "")
def test_list3(self):
command = ListCommand.ListCommand(["Context1"], self.todolist, self.out, self.error)
command = ListCommand(["Context1"], self.todolist, self.out, self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -44,7 +44,7 @@ class ListCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "")
def test_list4(self):
command = ListCommand.ListCommand(["-x", "Context1"], self.todolist, self.out, self.error)
command = ListCommand(["-x", "Context1"], self.todolist, self.out, self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -52,7 +52,7 @@ class ListCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "")
def test_list5(self):
command = ListCommand.ListCommand(["-x"], self.todolist, self.out, self.error)
command = ListCommand(["-x"], self.todolist, self.out, self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -60,7 +60,7 @@ class ListCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "")
def test_list6(self):
command = ListCommand.ListCommand(["Project3"], self.todolist, self.out, self.error)
command = ListCommand(["Project3"], self.todolist, self.out, self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -68,7 +68,7 @@ class ListCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "")
def test_list7(self):
command = ListCommand.ListCommand(["-s", "text", "-x", "Project1"], self.todolist, self.out, self.error)
command = ListCommand(["-s", "text", "-x", "Project1"], self.todolist, self.out, self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -76,7 +76,7 @@ class ListCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "")
def test_list8(self):
command = ListCommand.ListCommand(["--", "-project1"], self.todolist, self.out, self.error)
command = ListCommand(["--", "-project1"], self.todolist, self.out, self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -84,7 +84,7 @@ class ListCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "")
def test_list9(self):
command = ListCommand.ListCommand(["--", "-project1", "-Drink"], self.todolist, self.out, self.error)
command = ListCommand(["--", "-project1", "-Drink"], self.todolist, self.out, self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -92,7 +92,7 @@ class ListCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "")
def test_list10(self):
command = ListCommand.ListCommand(["text1", "2"], self.todolist, self.out, self.error)
command = ListCommand(["text1", "2"], self.todolist, self.out, self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -102,7 +102,7 @@ class ListCommandTest(CommandTest.CommandTest):
def test_list11(self):
config("data/listcommand.conf")
command = ListCommand.ListCommand(["project"], self.todolist, self.out, self.error)
command = ListCommand(["project"], self.todolist, self.out, self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -112,7 +112,7 @@ class ListCommandTest(CommandTest.CommandTest):
def test_list12(self):
config("data/listcommand.conf")
command = ListCommand.ListCommand(["-x", "project"], self.todolist, self.out, self.error)
command = ListCommand(["-x", "project"], self.todolist, self.out, self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -120,7 +120,7 @@ class ListCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "")
def test_list13(self):
command = ListCommand.ListCommand(["-x", "--", "-@Context1 +Project2"], self.todolist, self.out, self.error)
command = ListCommand(["-x", "--", "-@Context1 +Project2"], self.todolist, self.out, self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -130,7 +130,7 @@ class ListCommandTest(CommandTest.CommandTest):
def test_list14(self):
config("data/listcommand2.conf")
command = ListCommand.ListCommand([], self.todolist, self.out, self.error)
command = ListCommand([], self.todolist, self.out, self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -138,7 +138,7 @@ class ListCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "")
def test_list15(self):
command = ListCommand.ListCommand(["p:<10"], self.todolist, self.out, self.error)
command = ListCommand(["p:<10"], self.todolist, self.out, self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -146,7 +146,7 @@ class ListCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "")
def test_help(self):
command = ListCommand.ListCommand(["help"], self.todolist, self.out, self.error)
command = ListCommand(["help"], self.todolist, self.out, self.error)
command.execute()
self.assertEquals(self.output, "")
......
......@@ -16,12 +16,12 @@
import CommandTest
import TestFacilities
import ListContextCommand
from topydo.lib.ListContextCommand import ListContextCommand
class ListContextCommandTest(CommandTest.CommandTest):
def test_contexts1(self):
todolist = TestFacilities.load_file_to_todolist("data/TodoListTest.txt")
command = ListContextCommand.ListContextCommand([""], todolist, self.out, self.error)
command = ListContextCommand([""], todolist, self.out, self.error)
command.execute()
self.assertEquals(self.output,"Context1\nContext2\n")
......@@ -29,14 +29,14 @@ class ListContextCommandTest(CommandTest.CommandTest):
def test_contexts2(self):
todolist = TestFacilities.load_file_to_todolist("data/TodoListTest.txt")
command = ListContextCommand.ListContextCommand(["aaa"], todolist, self.out, self.error)
command = ListContextCommand(["aaa"], todolist, self.out, self.error)
command.execute()
self.assertEquals(self.output,"Context1\nContext2\n")
self.assertFalse(self.errors)
def test_help(self):
command = ListContextCommand.ListContextCommand(["help"], None, self.out, self.error)
command = ListContextCommand(["help"], None, self.out, self.error)
command.execute()
self.assertEquals(self.output, "")
......
......@@ -16,12 +16,12 @@
import CommandTest
import TestFacilities
import ListProjectCommand
from topydo.lib.ListProjectCommand import ListProjectCommand
class ListProjectCommandTest(CommandTest.CommandTest):
def test_projects1(self):
todolist = TestFacilities.load_file_to_todolist("data/TodoListTest.txt")
command = ListProjectCommand.ListProjectCommand([""], todolist, self.out, self.error)
command = ListProjectCommand([""], todolist, self.out, self.error)
command.execute()
self.assertEquals(self.output,"Project1\nProject2\n")
......@@ -29,14 +29,14 @@ class ListProjectCommandTest(CommandTest.CommandTest):
def test_projects2(self):
todolist = TestFacilities.load_file_to_todolist("data/TodoListTest.txt")
command = ListProjectCommand.ListProjectCommand(["aaa"], todolist, self.out, self.error)
command = ListProjectCommand(["aaa"], todolist, self.out, self.error)
command.execute()
self.assertEquals(self.output,"Project1\nProject2\n")
self.assertFalse(self.errors)
def test_help(self):
command = ListProjectCommand.ListProjectCommand(["help"], None, self.out, self.error)
command = ListProjectCommand(["help"], None, self.out, self.error)
command.execute()
self.assertEquals(self.output, "")
......
......@@ -17,8 +17,8 @@
from datetime import date, timedelta
import CommandTest
import PostponeCommand
import TodoList
from topydo.lib.PostponeCommand import PostponeCommand
from topydo.lib.TodoList import TodoList
class PostponeCommandTest(CommandTest.CommandTest):
def setUp(self):
......@@ -36,10 +36,10 @@ class PostponeCommandTest(CommandTest.CommandTest):
"Future due:%s t:%s" % (self.future.isoformat(), self.future_start.isoformat()),
]
self.todolist = TodoList.TodoList(todos)
self.todolist = TodoList(todos)
def test_postpone1(self):
command = PostponeCommand.PostponeCommand(["1", "1w"], self.todolist, self.out, self.error)
command = PostponeCommand(["1", "1w"], self.todolist, self.out, self.error)
command.execute()
due = self.today + timedelta(7)
......@@ -49,7 +49,7 @@ class PostponeCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "")
def test_postpone2(self):
command = PostponeCommand.PostponeCommand(["2", "1w"], self.todolist, self.out, self.error)
command = PostponeCommand(["2", "1w"], self.todolist, self.out, self.error)
command.execute()
due = self.today + timedelta(7)
......@@ -59,7 +59,7 @@ class PostponeCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "")
def test_postpone3(self):
command = PostponeCommand.PostponeCommand(["-s", "2", "1w"], self.todolist, self.out, self.error)
command = PostponeCommand(["-s", "2", "1w"], self.todolist, self.out, self.error)
command.execute()
due = self.today + timedelta(7)
......@@ -69,7 +69,7 @@ class PostponeCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "")
def test_postpone4(self):
command = PostponeCommand.PostponeCommand(["3", "1w"], self.todolist, self.out, self.error)
command = PostponeCommand(["3", "1w"], self.todolist, self.out, self.error)
command.execute()
due = self.today + timedelta(7)
......@@ -79,7 +79,7 @@ class PostponeCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "")
def test_postpone5(self):
command = PostponeCommand.PostponeCommand(["-s", "3", "1w"], self.todolist, self.out, self.error)
command = PostponeCommand(["-s", "3", "1w"], self.todolist, self.out, self.error)
command.execute()
due = self.today + timedelta(7)
......@@ -90,7 +90,7 @@ class PostponeCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "")
def test_postpone6(self):
command = PostponeCommand.PostponeCommand(["4", "1w"], self.todolist, self.out, self.error)
command = PostponeCommand(["4", "1w"], self.todolist, self.out, self.error)
command.execute()
due = self.today + timedelta(7)
......@@ -100,7 +100,7 @@ class PostponeCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "")
def test_postpone7(self):
command = PostponeCommand.PostponeCommand(["5", "1w"], self.todolist, self.out, self.error)
command = PostponeCommand(["5", "1w"], self.todolist, self.out, self.error)
command.execute()
due = self.future + timedelta(7)
......@@ -110,7 +110,7 @@ class PostponeCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "")
def test_postpone8(self):
command = PostponeCommand.PostponeCommand(["-s", "5", "1w"], self.todolist, self.out, self.error)
command = PostponeCommand(["-s", "5", "1w"], self.todolist, self.out, self.error)
command.execute()
due = self.future + timedelta(7)
......@@ -121,7 +121,7 @@ class PostponeCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "")
def test_postpone9(self):
command = PostponeCommand.PostponeCommand(["1", "foo"], self.todolist, self.out, self.error)
command = PostponeCommand(["1", "foo"], self.todolist, self.out, self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -129,7 +129,7 @@ class PostponeCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "Invalid date pattern given.\n")
def test_postpone10(self):
command = PostponeCommand.PostponeCommand(["99", "foo"], self.todolist, self.out, self.error)
command = PostponeCommand(["99", "foo"], self.todolist, self.out, self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -137,7 +137,7 @@ class PostponeCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "Invalid todo number given.\n")
def test_postpone11(self):
command = PostponeCommand.PostponeCommand(["A", "foo"], self.todolist, self.out, self.error)
command = PostponeCommand(["A", "foo"], self.todolist, self.out, self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -145,7 +145,7 @@ class PostponeCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "Invalid todo number given.\n")
def test_postpone12(self):
command = PostponeCommand.PostponeCommand(["1"], self.todolist, self.out, self.error)
command = PostponeCommand(["1"], self.todolist, self.out, self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -153,7 +153,7 @@ class PostponeCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, command.usage() + "\n")
def test_postpone13(self):
command = PostponeCommand.PostponeCommand(["Foo", "1w"], self.todolist, self.out, self.error)
command = PostponeCommand(["Foo", "1w"], self.todolist, self.out, self.error)
command.execute()
due = self.today + timedelta(7)
......@@ -163,7 +163,7 @@ class PostponeCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "")
def test_help(self):
command = PostponeCommand.PostponeCommand(["help"], self.todolist, self.out, self.error)
command = PostponeCommand(["help"], self.todolist, self.out, self.error)
command.execute()
self.assertEquals(self.output, "")
......
......@@ -15,8 +15,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import CommandTest
import PriorityCommand
import TodoList
from topydo.lib.PriorityCommand import PriorityCommand
from topydo.lib.TodoList import TodoList
class PriorityCommandTest(CommandTest.CommandTest):
def setUp(self):
......@@ -25,10 +25,10 @@ class PriorityCommandTest(CommandTest.CommandTest):
"Bar",
]
self.todolist = TodoList.TodoList(todos)
self.todolist = TodoList(todos)
def test_set_prio1(self):
command = PriorityCommand.PriorityCommand(["1", "B"], self.todolist, self.out, self.error)
command = PriorityCommand(["1", "B"], self.todolist, self.out, self.error)
command.execute()
self.assertTrue(self.todolist.is_dirty())
......@@ -36,7 +36,7 @@ class PriorityCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "")
def test_set_prio2(self):
command = PriorityCommand.PriorityCommand(["2", "Z"], self.todolist, self.out, self.error)
command = PriorityCommand(["2", "Z"], self.todolist, self.out, self.error)
command.execute()
self.assertTrue(self.todolist.is_dirty())
......@@ -44,7 +44,7 @@ class PriorityCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "")
def test_set_prio3(self):
command = PriorityCommand.PriorityCommand(["Foo", "B"], self.todolist, self.out, self.error)
command = PriorityCommand(["Foo", "B"], self.todolist, self.out, self.error)
command.execute()
self.assertTrue(self.todolist.is_dirty())
......@@ -52,7 +52,7 @@ class PriorityCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "")
def test_set_prio4(self):
command = PriorityCommand.PriorityCommand(["1", "A"], self.todolist, self.out, self.error)
command = PriorityCommand(["1", "A"], self.todolist, self.out, self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -60,7 +60,7 @@ class PriorityCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "")
def test_invalid1(self):
command = PriorityCommand.PriorityCommand(["99", "A"], self.todolist, self.out, self.error)
command = PriorityCommand(["99", "A"], self.todolist, self.out, self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -68,7 +68,7 @@ class PriorityCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "Invalid todo number given.\n")
def test_invalid2(self):
command = PriorityCommand.PriorityCommand(["1", "ZZ"], self.todolist, self.out, self.error)
command = PriorityCommand(["1", "ZZ"], self.todolist, self.out, self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -76,7 +76,7 @@ class PriorityCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "Invalid priority given.\n")
def test_invalid3(self):
command = PriorityCommand.PriorityCommand(["A"], self.todolist, self.out, self.error)
command = PriorityCommand(["A"], self.todolist, self.out, self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -84,7 +84,7 @@ class PriorityCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, command.usage() + "\n")
def test_invalid4(self):
command = PriorityCommand.PriorityCommand(["1"], self.todolist, self.out, self.error)
command = PriorityCommand(["1"], self.todolist, self.out, self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -92,7 +92,7 @@ class PriorityCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, command.usage() + "\n")
def test_empty(self):
command = PriorityCommand.PriorityCommand([], self.todolist, self.out, self.error)
command = PriorityCommand([], self.todolist, self.out, self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -100,7 +100,7 @@ class PriorityCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, command.usage() + "\n")
def test_help(self):
command = PriorityCommand.PriorityCommand(["help"], self.todolist, self.out, self.error)
command = PriorityCommand(["help"], self.todolist, self.out, self.error)
command.execute()
self.assertEquals(self.output, "")
......
......@@ -17,13 +17,13 @@
from datetime import date, timedelta
import unittest
from Config import config
from Recurrence import advance_recurring_todo, strict_advance_recurring_todo, NoRecurrenceException
import Todo
from topydo.lib.Config import config
from topydo.lib.Recurrence import advance_recurring_todo, strict_advance_recurring_todo, NoRecurrenceException
from topydo.lib.Todo import Todo
class RecurrenceTest(unittest.TestCase):
def setUp(self):
self.todo = Todo.Todo("Test rec:1w")
self.todo = Todo("Test rec:1w")
def test_duedate1(self):
""" Where due date is in the future. """
......
......@@ -17,7 +17,7 @@
from datetime import date, timedelta
import unittest
import RelativeDate
from topydo.lib.RelativeDate import relative_date_to_date
class RelativeDateTester(unittest.TestCase):
def setUp(self):
......@@ -29,82 +29,82 @@ class RelativeDateTester(unittest.TestCase):
self.monday += timedelta(7 - self.today.weekday() % 7)
def test_zero_days(self):
result = RelativeDate.relative_date_to_date('0d')
result = relative_date_to_date('0d')
self.assertEquals(result, self.today)
def test_one_day(self):
result = RelativeDate.relative_date_to_date('1d')
result = relative_date_to_date('1d')
self.assertEquals(result, self.tomorrow)
def test_one_week(self):
result = RelativeDate.relative_date_to_date('1w')
result = relative_date_to_date('1w')
self.assertEquals(result, date.today() + timedelta(weeks=1))
def test_one_month(self):
result = RelativeDate.relative_date_to_date('1m')
result = relative_date_to_date('1m')
self.assertEquals(result, date.today() + timedelta(30))
def test_one_year(self):
result = RelativeDate.relative_date_to_date('1y')
result = relative_date_to_date('1y')
self.assertEquals(result, date.today() + timedelta(365))
def test_zero_months(self):
result = RelativeDate.relative_date_to_date('0m')
result = relative_date_to_date('0m')
self.assertEquals(result, self.today)
def test_zero_years(self):
result = RelativeDate.relative_date_to_date('0y')
result = relative_date_to_date('0y')
self.assertEquals(result, self.today)
def test_garbage1(self):
result = RelativeDate.relative_date_to_date('0dd')
result = relative_date_to_date('0dd')
self.assertFalse(result)
def test_garbage2(self):
result = RelativeDate.relative_date_to_date('-0d')
result = relative_date_to_date('-0d')
self.assertFalse(result)
def test_one_day_capital(self):
result = RelativeDate.relative_date_to_date('1D')
result = relative_date_to_date('1D')
self.assertEquals(result, self.tomorrow)
def test_today1(self):
result = RelativeDate.relative_date_to_date('today')
result = relative_date_to_date('today')
self.assertEquals(result, self.today)
def test_today2(self):
result = RelativeDate.relative_date_to_date('tod')
result = relative_date_to_date('tod')
self.assertEquals(result, self.today)
def test_today3(self):
result = RelativeDate.relative_date_to_date('today', \
result = relative_date_to_date('today', \
date.today() + timedelta(1))
self.assertEquals(result, self.today)
def test_tomorrow1(self):
result = RelativeDate.relative_date_to_date('Tomorrow')
result = relative_date_to_date('Tomorrow')
self.assertEquals(result, self.tomorrow)
def test_tomorrow2(self):
result = RelativeDate.relative_date_to_date('tom')
result = relative_date_to_date('tom')
self.assertEquals(result, self.tomorrow)
def test_monday1(self):
result = RelativeDate.relative_date_to_date('monday')
result = relative_date_to_date('monday')
self.assertEquals(result, self.monday)
def test_monday2(self):
result = RelativeDate.relative_date_to_date('mo')
result = relative_date_to_date('mo')
self.assertEquals(result, self.monday)
def test_monday3(self):
result = RelativeDate.relative_date_to_date('mon')
result = relative_date_to_date('mon')
self.assertEquals(result, self.monday)
def test_monday4(self):
result = RelativeDate.relative_date_to_date('mondayy')
result = relative_date_to_date('mondayy')
self.assertFalse(result)
def test_offset1(self):
result = RelativeDate.relative_date_to_date('1d', self.tomorrow)
result = relative_date_to_date('1d', self.tomorrow)
self.assertEquals(result, date.today() + timedelta(2))
......@@ -15,7 +15,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import CommandTest
import SortCommand
from topydo.lib.SortCommand import SortCommand
import TestFacilities
class SortCommandTest(CommandTest.CommandTest):
......@@ -24,19 +24,19 @@ class SortCommandTest(CommandTest.CommandTest):
def test_sort1(self):
""" Alphabetically sorted """
command = SortCommand.SortCommand(["text"], self.todolist, self.out, self.error)
command = SortCommand(["text"], self.todolist, self.out, self.error)
command.execute()
self.assertEquals(str(self.todolist), "First\n(A) Foo\n2014-06-14 Last")
def test_sort2(self):
command = SortCommand.SortCommand([], self.todolist, self.out, self.error)
command = SortCommand([], self.todolist, self.out, self.error)
command.execute()
self.assertEquals(str(self.todolist), "(A) Foo\n2014-06-14 Last\nFirst")
def test_help(self):
command = SortCommand.SortCommand(["help"], self.todolist, self.out, self.error)
command = SortCommand(["help"], self.todolist, self.out, self.error)
command.execute()
self.assertEquals(self.output, "")
......
......@@ -16,8 +16,8 @@
import unittest
from Config import config
import Sorter
from topydo.lib.Config import config
from topydo.lib.Sorter import Sorter
from TestFacilities import load_file, todolist_to_string, load_file_to_todolist
......@@ -37,21 +37,21 @@ class SorterTest(unittest.TestCase):
def test_sort1(self):
""" Alphabetically sorted """
sorter = Sorter.Sorter('text')
sorter = Sorter('text')
self.sort_file('data/SorterTest1.txt', 'data/SorterTest1-result.txt', sorter)
def test_sort2a(self):
"""
Ascendingly sorted by priority. Also checks stableness of the sort.
"""
sorter = Sorter.Sorter('prio')
sorter = Sorter('prio')
self.sort_file('data/SorterTest2.txt', 'data/SorterTest2-result.txt', sorter)
def test_sort2b(self):
"""
Ascendingly sorted by priority. Also checks stableness of the sort.
"""
sorter = Sorter.Sorter('asc:prio')
sorter = Sorter('asc:prio')
self.sort_file('data/SorterTest2.txt', 'data/SorterTest2-result.txt', sorter)
def test_sort3(self):
......@@ -59,32 +59,32 @@ class SorterTest(unittest.TestCase):
Descendingly sorted by priority. Also checks stableness of the
sort.
"""
sorter = Sorter.Sorter('desc:prio')
sorter = Sorter('desc:prio')
self.sort_file('data/SorterTest3.txt', 'data/SorterTest3-result.txt', sorter)
def test_sort4(self):
""" Ascendingly sorted by due date """
sorter = Sorter.Sorter(config().tag_due())
sorter = Sorter(config().tag_due())
self.sort_file('data/SorterTest4.txt', 'data/SorterTest4-result.txt', sorter)
def test_sort5(self):
""" Descendingly sorted by due date """
sorter = Sorter.Sorter('desc:due')
sorter = Sorter('desc:due')
self.sort_file('data/SorterTest5.txt', 'data/SorterTest5-result.txt', sorter)
def test_sort6(self):
""" Ascendingly sorted by creation date """
sorter = Sorter.Sorter('creation')
sorter = Sorter('creation')
self.sort_file('data/SorterTest6.txt', 'data/SorterTest6-result.txt', sorter)
def test_sort7(self):
""" Ascendingly sorted by completion date. """
sorter = Sorter.Sorter('completion')
sorter = Sorter('completion')
self.sort_file('data/SorterTest7.txt', 'data/SorterTest7-result.txt', sorter)
def test_sort8(self):
""" Descendingly sorted by importance """
sorter = Sorter.Sorter('desc:importance')
sorter = Sorter('desc:importance')
self.sort_file('data/SorterTest8.txt', 'data/SorterTest8-result.txt', sorter)
def test_sort9(self):
......@@ -92,22 +92,22 @@ class SorterTest(unittest.TestCase):
Sort on multiple levels: first descending importance, then
ascending priority.
"""
sorter = Sorter.Sorter('desc:importance,priority')
sorter = Sorter('desc:importance,priority')
self.sort_file('data/SorterTest9.txt', 'data/SorterTest9-result.txt', sorter)
def test_sort10(self):
""" Deal with garbage input. """
sorter = Sorter.Sorter('')
sorter = Sorter('')
self.sort_file('data/SorterTest9.txt', 'data/SorterTest9.txt', sorter)
def test_sort11(self):
""" Deal with garbage input. """
sorter = Sorter.Sorter('fnord')
sorter = Sorter('fnord')
self.sort_file('data/SorterTest9.txt', 'data/SorterTest9.txt', sorter)
def test_sort12(self):
""" Deal with garbage input. """
sorter = Sorter.Sorter('desc:importance,,priority')
sorter = Sorter('desc:importance,,priority')
self.sort_file('data/SorterTest9.txt', 'data/SorterTest9-result.txt', sorter)
def test_sort13(self):
......@@ -117,11 +117,11 @@ class SorterTest(unittest.TestCase):
Reusing input and output for normal importance test, since without
dependencies the average importance should be equal.
"""
sorter = Sorter.Sorter('desc:importance-avg')
sorter = Sorter('desc:importance-avg')
self.sort_file('data/SorterTest9.txt', 'data/SorterTest9-result.txt', sorter)
def test_sort14(self):
sorter = Sorter.Sorter('desc:importance-average')
sorter = Sorter('desc:importance-average')
todolist = load_file_to_todolist('data/SorterTest10.txt')
view = todolist.view(sorter, [])
......@@ -134,7 +134,7 @@ class SorterTest(unittest.TestCase):
Test that own importance is used when average turns out to be
lower.
"""
sorter = Sorter.Sorter('desc:importance-average')
sorter = Sorter('desc:importance-average')
todolist = load_file_to_todolist('data/SorterTest11.txt')
view = todolist.view(sorter, [])
......@@ -146,7 +146,7 @@ class SorterTest(unittest.TestCase):
"""
Check sort of low priority tasks (D or lower) with non-priority tasks.
"""
sorter = Sorter.Sorter('desc:importance,desc:prio')
sorter = Sorter('desc:importance,desc:prio')
todolist = load_file_to_todolist('data/SorterTest12.txt')
view = todolist.view(sorter, [])
......
......@@ -15,8 +15,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import CommandTest
import TagCommand
import TodoList
from topydo.lib.TagCommand import TagCommand
from topydo.lib.TodoList import TodoList
class TagCommandTest(CommandTest.CommandTest):
def setUp(self):
......@@ -27,10 +27,10 @@ class TagCommandTest(CommandTest.CommandTest):
"Fnord due:2014-10-20 due:2014-10-22",
]
self.todolist = TodoList.TodoList(todos)
self.todolist = TodoList(todos)
def test_add_tag1(self):
command = TagCommand.TagCommand(["1", "due", "2014-10-22"], self.todolist, self.out, self.error)
command = TagCommand(["1", "due", "2014-10-22"], self.todolist, self.out, self.error)
command.execute()
self.assertEquals(self.todolist.todo(1).source(), "Foo due:2014-10-22")
......@@ -39,7 +39,7 @@ class TagCommandTest(CommandTest.CommandTest):
self.assertTrue(self.todolist.is_dirty())
def test_add_tag2(self):
command = TagCommand.TagCommand(["Foo", "due", "2014-10-22"], self.todolist, self.out, self.error)
command = TagCommand(["Foo", "due", "2014-10-22"], self.todolist, self.out, self.error)
command.execute()
self.assertEquals(self.todolist.todo(1).source(), "Foo due:2014-10-22")
......@@ -48,7 +48,7 @@ class TagCommandTest(CommandTest.CommandTest):
self.assertTrue(self.todolist.is_dirty())
def test_add_tag3(self):
command = TagCommand.TagCommand(["-a", "2", "due", "2014-10-19"], self.todolist, self.out, self.error)
command = TagCommand(["-a", "2", "due", "2014-10-19"], self.todolist, self.out, self.error)
command.execute()
self.assertEquals(self.todolist.todo(2).source(), "Bar due:2014-10-22 due:2014-10-19")
......@@ -57,7 +57,7 @@ class TagCommandTest(CommandTest.CommandTest):
self.assertTrue(self.todolist.is_dirty())
def test_add_tag4(self):
command = TagCommand.TagCommand(["Foox", "due", "2014-10-22"], self.todolist, self.out, self.error)
command = TagCommand(["Foox", "due", "2014-10-22"], self.todolist, self.out, self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -65,7 +65,7 @@ class TagCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "Invalid todo number.\n")
def test_set_tag4(self):
command = TagCommand.TagCommand(["3", "due", "2014-10-20"], self.todolist, self.out, self.error)
command = TagCommand(["3", "due", "2014-10-20"], self.todolist, self.out, self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -73,7 +73,7 @@ class TagCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "")
def test_set_tag5(self):
command = TagCommand.TagCommand(["4", "due", "2014-10-20"], self.todolist, self.out, self.error, lambda t: "all")
command = TagCommand(["4", "due", "2014-10-20"], self.todolist, self.out, self.error, lambda t: "all")
command.execute()
self.assertTrue(self.todolist.is_dirty())
......@@ -81,7 +81,7 @@ class TagCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "")
def test_set_tag6(self):
command = TagCommand.TagCommand(["4", "due", "2014-10-20"], self.todolist, self.out, self.error, lambda t: "1")
command = TagCommand(["4", "due", "2014-10-20"], self.todolist, self.out, self.error, lambda t: "1")
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -89,7 +89,7 @@ class TagCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "")
def test_set_tag7(self):
command = TagCommand.TagCommand(["4", "due", "2014-10-20"], self.todolist, self.out, self.error, lambda t: "2")
command = TagCommand(["4", "due", "2014-10-20"], self.todolist, self.out, self.error, lambda t: "2")
command.execute()
self.assertTrue(self.todolist.is_dirty())
......@@ -97,7 +97,7 @@ class TagCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "")
def test_set_tag8(self):
command = TagCommand.TagCommand(["4", "due", "2014-10-20"], self.todolist, self.out, self.error, lambda t: "")
command = TagCommand(["4", "due", "2014-10-20"], self.todolist, self.out, self.error, lambda t: "")
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -105,7 +105,7 @@ class TagCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "")
def test_set_tag9(self):
command = TagCommand.TagCommand(["4", "due", "2014-10-20"], self.todolist, self.out, self.error, lambda t: "99")
command = TagCommand(["4", "due", "2014-10-20"], self.todolist, self.out, self.error, lambda t: "99")
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -113,7 +113,7 @@ class TagCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "")
def test_set_tag10(self):
command = TagCommand.TagCommand(["-f", "4", "due", "2014-10-20"], self.todolist, self.out, self.error, lambda t: "99")
command = TagCommand(["-f", "4", "due", "2014-10-20"], self.todolist, self.out, self.error, lambda t: "99")
command.execute()
self.assertTrue(self.todolist.is_dirty())
......@@ -121,7 +121,7 @@ class TagCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "")
def test_rm_tag1(self):
command = TagCommand.TagCommand(["1", "due"], self.todolist, self.out, self.error)
command = TagCommand(["1", "due"], self.todolist, self.out, self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -129,7 +129,7 @@ class TagCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "")
def test_rm_tag2(self):
command = TagCommand.TagCommand(["2", "due"], self.todolist, self.out, self.error)
command = TagCommand(["2", "due"], self.todolist, self.out, self.error)
command.execute()
self.assertTrue(self.todolist.is_dirty())
......@@ -137,7 +137,7 @@ class TagCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "")
def test_rm_tag3(self):
command = TagCommand.TagCommand(["4", "due"], self.todolist, self.out, self.error, lambda t: "all")
command = TagCommand(["4", "due"], self.todolist, self.out, self.error, lambda t: "all")
command.execute()
self.assertTrue(self.todolist.is_dirty())
......@@ -145,7 +145,7 @@ class TagCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "")
def test_rm_tag4(self):
command = TagCommand.TagCommand(["4", "due"], self.todolist, self.out, self.error, lambda t: "1")
command = TagCommand(["4", "due"], self.todolist, self.out, self.error, lambda t: "1")
command.execute()
self.assertTrue(self.todolist.is_dirty())
......@@ -153,7 +153,7 @@ class TagCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "")
def test_rm_tag6(self):
command = TagCommand.TagCommand(["4", "due"], self.todolist, self.out, self.error, lambda t: "99")
command = TagCommand(["4", "due"], self.todolist, self.out, self.error, lambda t: "99")
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -161,7 +161,7 @@ class TagCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "")
def test_rm_tag7(self):
command = TagCommand.TagCommand(["4", "due"], self.todolist, self.out, self.error, lambda t: "A")
command = TagCommand(["4", "due"], self.todolist, self.out, self.error, lambda t: "A")
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -169,7 +169,7 @@ class TagCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "")
def test_rm_tag8(self):
command = TagCommand.TagCommand(["5", "due"], self.todolist, self.out, self.error)
command = TagCommand(["5", "due"], self.todolist, self.out, self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -177,7 +177,7 @@ class TagCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "Invalid todo number.\n")
def test_rm_tag9(self):
command = TagCommand.TagCommand(["A", "due"], self.todolist, self.out, self.error)
command = TagCommand(["A", "due"], self.todolist, self.out, self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -185,7 +185,7 @@ class TagCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "Invalid todo number.\n")
def test_rm_tag10(self):
command = TagCommand.TagCommand(["-f", "4", "due"], self.todolist, self.out, self.error, lambda t: "A")
command = TagCommand(["-f", "4", "due"], self.todolist, self.out, self.error, lambda t: "A")
command.execute()
self.assertTrue(self.todolist.is_dirty())
......@@ -193,7 +193,7 @@ class TagCommandTest(CommandTest.CommandTest):
self.assertEquals(self.errors, "")
def test_help(self):
command = TagCommand.TagCommand(["help"], self.todolist, self.out, self.error)
command = TagCommand(["help"], self.todolist, self.out, self.error)
command.execute()
self.assertEquals(self.output, "")
......
......@@ -14,23 +14,23 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import Todo
import TodoFile
import TodoList
from topydo.lib.Todo import Todo
from topydo.lib.TodoFile import TodoFile
from topydo.lib.TodoList import TodoList
def load_file(p_filename):
"""
Loads a todo file from the given filename and returns a list of todos.
"""
todolist = load_file_to_raw_list(p_filename)
return [Todo.Todo(src) for src in todolist]
return [Todo(src) for src in todolist]
def load_file_to_raw_list(p_filename):
"""
Loads a todo file from the given filename and returns a list of todo
strings (unparsed).
"""
todofile = TodoFile.TodoFile(p_filename)
todofile = TodoFile(p_filename)
return todofile.read()
def load_file_to_todolist(p_filename):
......@@ -38,7 +38,7 @@ def load_file_to_todolist(p_filename):
Loads a todo file to a TodoList instance.
"""
todolist = load_file_to_raw_list(p_filename)
return TodoList.TodoList(todolist)
return TodoList(todolist)
def todolist_to_string(p_list):
""" Converts a todo list to a single string. """
......
This diff is collapsed.
......@@ -19,18 +19,18 @@
import re
import unittest
import Todo
import TodoFile
from TodoListBase import InvalidTodoException
import TodoList
from topydo.lib.Todo import Todo
from topydo.lib.TodoFile import TodoFile
from topydo.lib.TodoListBase import InvalidTodoException
from topydo.lib.TodoList import TodoList
class TodoListTester(unittest.TestCase):
def setUp(self):
self.todofile = TodoFile.TodoFile('data/TodoListTest.txt')
self.todofile = TodoFile('data/TodoListTest.txt')
lines = [line for line in self.todofile.read() \
if re.search(r'\S', line)]
self.text = ''.join(lines)
self.todolist = TodoList.TodoList(lines)
self.todolist = TodoList(lines)
def test_contexts(self):
self.assertEquals(set(['Context1', 'Context2']), \
......@@ -146,15 +146,15 @@ class TodoListTester(unittest.TestCase):
self.assertFalse(self.todolist.todo_by_dep_id('2'))
def test_todo_number1(self):
todo = Todo.Todo("No number")
todo = Todo("No number")
self.todolist.add_todo(todo)
todo = self.todolist.todo(6)
self.assertIsInstance(todo, Todo.Todo)
self.assertIsInstance(todo, Todo)
self.assertEquals(todo.text(), "No number")
def test_todo_number2(self):
todo = Todo.Todo("Non-existent")
todo = Todo("Non-existent")
self.assertRaises(InvalidTodoException, self.todolist.number, todo)
def test_todo_complete(self):
......@@ -193,7 +193,7 @@ class TodoListTester(unittest.TestCase):
class TodoListDependencyTester(unittest.TestCase):
def setUp(self):
self.todolist = TodoList.TodoList([])
self.todolist = TodoList([])
self.todolist.add("Foo id:1")
self.todolist.add("Bar p:1")
self.todolist.add("Baz p:1 id:2")
......@@ -290,7 +290,7 @@ class TodoListDependencyTester(unittest.TestCase):
class TodoListCleanDependencyTester(unittest.TestCase):
def setUp(self):
self.todolist = TodoList.TodoList([])
self.todolist = TodoList([])
self.todolist.add("Bar p:1")
self.todolist.add("Baz p:1 id:2")
self.todolist.add("Buzz p:2")
......
......@@ -17,7 +17,7 @@
from datetime import date, timedelta
import unittest
import Todo
from topydo.lib.Todo import Todo
def today_date():
today = date.today()
......@@ -29,59 +29,59 @@ def tomorrow_date():
class TodoTest(unittest.TestCase):
def test_due_date1(self):
todo = Todo.Todo("(C) Foo due:2014-06-09")
todo = Todo("(C) Foo due:2014-06-09")
due = date(2014, 6, 9)
self.assertEqual(todo.due_date(), due)
def test_false_date(self):
todo = Todo.Todo("(C) Foo due:2014-04-31")
todo = Todo("(C) Foo due:2014-04-31")
self.assertEqual( todo.due_date(), None )
def test_active1(self):
todo = Todo.Todo("(C) Foo due:2014-01-01")
todo = Todo("(C) Foo due:2014-01-01")
self.assertTrue(todo.is_active())
def test_active2(self):
todo = Todo.Todo("(C) Foo t:" + tomorrow_date())
todo = Todo("(C) Foo t:" + tomorrow_date())
self.assertFalse(todo.is_active())
def test_active3(self):
todo = Todo.Todo("x 2014-06-09 Foo t:2014-01-01")
todo = Todo("x 2014-06-09 Foo t:2014-01-01")
self.assertFalse(todo.is_active())
def test_active4(self):
todo = Todo.Todo("(C) Foo t:" + today_date())
todo = Todo("(C) Foo t:" + today_date())
self.assertTrue(todo.is_active())
def test_active5(self):
todo = Todo.Todo("(C) Foo t:2014-02-29")
todo = Todo("(C) Foo t:2014-02-29")
self.assertTrue(todo.is_active())
def test_overdue1(self):
todo = Todo.Todo("(C) Foo due:2014-01-01")
todo = Todo("(C) Foo due:2014-01-01")
self.assertTrue(todo.is_overdue())
def test_overdue2(self):
todo = Todo.Todo("(C) Foo due:" + tomorrow_date())
todo = Todo("(C) Foo due:" + tomorrow_date())
self.assertFalse(todo.is_overdue())
def test_overdue3(self):
todo = Todo.Todo("(C) Foo due:" + today_date())
todo = Todo("(C) Foo due:" + today_date())
self.assertFalse(todo.is_overdue())
def days_till_due(self):
todo = Todo.Todo("(C) due:" + tomorrow_date())
todo = Todo("(C) due:" + tomorrow_date())
self.assertEqual(todo.days_till_due(), 1)
def test_length1(self):
todo = Todo.Todo("(C) Foo t:2014-01-01 due:2013-12-31")
todo = Todo("(C) Foo t:2014-01-01 due:2013-12-31")
self.assertEqual(todo.length(), 0)
def test_length2(self):
todo = Todo.Todo("(C) Foo t:2014-01-01 due:2014-01-01")
todo = Todo("(C) Foo t:2014-01-01 due:2014-01-01")
self.assertEqual(todo.length(), 0)
def test_length3(self):
todo = 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)
......@@ -16,20 +16,20 @@
import unittest
import Filter
import Sorter
from topydo.lib import Filter
from topydo.lib.Sorter import Sorter
from TestFacilities import load_file, todolist_to_string
import TodoFile
import TodoList
from topydo.lib.TodoFile import TodoFile
from topydo.lib.TodoList import TodoList
class ViewTest(unittest.TestCase):
def test_view(self):
""" Check filters and printer for views. """
todofile = TodoFile.TodoFile('data/FilterTest1.txt')
todofile = TodoFile('data/FilterTest1.txt')
ref = load_file('data/ViewTest1-result.txt')
todolist = TodoList.TodoList(todofile.read())
sorter = Sorter.Sorter('text')
todolist = TodoList(todofile.read())
sorter = Sorter('text')
todofilter = Filter.GrepFilter('+Project')
view = todolist.view(sorter, [todofilter])
......
#!/bin/bash
export PYTHONPATH=../topydo/lib
export PYTHONPATH=..
if [ -n "$1" ]; then
TESTS=$1
......
......@@ -19,13 +19,13 @@
from datetime import date
import re
from Config import config
import Command
from PrettyPrinter import pretty_print
from RelativeDate import relative_date_to_date
from TodoListBase import InvalidTodoException
from topydo.lib.Config import config
from topydo.lib.Command import Command
from topydo.lib.PrettyPrinter import pretty_print
from topydo.lib.RelativeDate import relative_date_to_date
from topydo.lib.TodoListBase import InvalidTodoException
class AddCommand(Command.Command):
class AddCommand(Command):
def __init__(self, p_args, p_todolist,
p_out=lambda a: None,
p_err=lambda a: None,
......
......@@ -14,9 +14,9 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from Command import Command, InvalidCommandArgument
from PrettyPrinter import pretty_print
from TodoListBase import InvalidTodoException
from topydo.lib.Command import Command, InvalidCommandArgument
from topydo.lib.PrettyPrinter import pretty_print
from topydo.lib.TodoListBase import InvalidTodoException
class AppendCommand(Command):
def __init__(self, p_args, p_todolist,
......
......@@ -14,9 +14,9 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import Command
from topydo.lib.Command import Command
class ArchiveCommand(Command.Command):
class ArchiveCommand(Command):
def __init__(self, p_todolist, p_archive_list):
"""
Constructor.
......
......@@ -16,9 +16,9 @@
import re
from Command import Command, InvalidCommandArgument
from PrettyPrinter import pretty_print, pretty_print_list
from TodoListBase import InvalidTodoException
from topydo.lib.Command import Command, InvalidCommandArgument
from topydo.lib.PrettyPrinter import pretty_print, pretty_print_list
from topydo.lib.TodoListBase import InvalidTodoException
class DCommand(Command):
"""
......
......@@ -14,8 +14,8 @@
# 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 DCommand import DCommand
from PrettyPrinter import pretty_print
from topydo.lib.DCommand import DCommand
from topydo.lib.PrettyPrinter import pretty_print
class DeleteCommand(DCommand):
def __init__(self, p_args, p_todolist,
......
......@@ -14,12 +14,12 @@
# 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 Command import Command, InvalidCommandArgument
from Config import config
import Filter
import Sorter
from TodoListBase import InvalidTodoException
import View
from topydo.lib.Command import Command, InvalidCommandArgument
from topydo.lib.Config import config
from topydo.lib import Filter
from topydo.lib.Sorter import Sorter
from topydo.lib.TodoListBase import InvalidTodoException
from topydo.lib.View import View
class DepCommand(Command):
def __init__(self, p_args, p_todolist,
......@@ -95,9 +95,9 @@ class DepCommand(Command):
self.error(self.usage())
if todos:
sorter = Sorter.Sorter(config().sort_string())
sorter = Sorter(config().sort_string())
instance_filter = Filter.InstanceFilter(todos)
view = View.View(sorter, [instance_filter], self.todolist)
view = View(sorter, [instance_filter], self.todolist)
self.out(view.pretty_print())
except InvalidTodoException:
self.error("Invalid todo number given.")
......
......@@ -14,9 +14,9 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from Command import Command, InvalidCommandArgument
from PrettyPrinter import pretty_print
from TodoListBase import InvalidTodoException
from topydo.lib.Command import Command, InvalidCommandArgument
from topydo.lib.PrettyPrinter import pretty_print
from topydo.lib.TodoListBase import InvalidTodoException
class DepriCommand(Command):
def __init__(self, p_args, p_todolist,
......
......@@ -16,10 +16,10 @@
from datetime import date
from DCommand import DCommand
from PrettyPrinter import pretty_print
from Recurrence import advance_recurring_todo, strict_advance_recurring_todo
from Utils import date_string_to_date
from topydo.lib.DCommand import DCommand
from topydo.lib.PrettyPrinter import pretty_print
from topydo.lib.Recurrence import advance_recurring_todo, strict_advance_recurring_todo
from topydo.lib.Utils import date_string_to_date
class DoCommand(DCommand):
def __init__(self, p_args, p_todolist,
......
......@@ -16,9 +16,9 @@
import re
from Config import config
from RelativeDate import relative_date_to_date
from Utils import date_string_to_date
from topydo.lib.Config import config
from topydo.lib.RelativeDate import relative_date_to_date
from topydo.lib.Utils import date_string_to_date
class Filter(object):
def filter(self, p_todos):
......
......@@ -25,7 +25,7 @@ future.
from datetime import date
from Config import config
from topydo.lib.Config import config
IMPORTANCE_VALUE = {'A': 3, 'B': 2, 'C': 1}
......
......@@ -16,13 +16,13 @@
import re
import Command
from Config import config
import Filter
from PrettyPrinter import pp_indent
import Sorter
from topydo.lib.Command import Command
from topydo.lib.Config import config
from topydo.lib import Filter
from topydo.lib.PrettyPrinter import pp_indent
from topydo.lib.Sorter import Sorter
class ListCommand(Command.Command):
class ListCommand(Command):
def __init__(self, p_args, p_todolist,
p_out=lambda a: None,
p_err=lambda a: None,
......@@ -80,7 +80,7 @@ class ListCommand(Command.Command):
self._process_flags()
sorter = Sorter.Sorter(self.sort_expression)
sorter = Sorter(self.sort_expression)
filters = self._filters()
pp_filters = [pp_indent(config().list_indent())]
......
......@@ -14,9 +14,9 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import Command
from topydo.lib.Command import Command
class ListContextCommand(Command.Command):
class ListContextCommand(Command):
def __init__(self, p_args, p_todolist,
p_out=lambda a: None,
p_err=lambda a: None,
......
......@@ -14,9 +14,9 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import Command
from topydo.lib.Command import Command
class ListProjectCommand(Command.Command):
class ListProjectCommand(Command):
def __init__(self, p_args, p_todolist,
p_out=lambda a: None,
p_err=lambda a: None,
......
......@@ -16,12 +16,12 @@
from datetime import date, timedelta
from Command import Command, InvalidCommandArgument
from Config import config
from PrettyPrinter import pretty_print
from RelativeDate import relative_date_to_date
from TodoListBase import InvalidTodoException
from Utils import date_string_to_date
from topydo.lib.Command import Command, InvalidCommandArgument
from topydo.lib.Config import config
from topydo.lib.PrettyPrinter import pretty_print
from topydo.lib.RelativeDate import relative_date_to_date
from topydo.lib.TodoListBase import InvalidTodoException
from topydo.lib.Utils import date_string_to_date
class PostponeCommand(Command):
def __init__(self, p_args, p_todolist,
......
......@@ -18,7 +18,7 @@
import re
from Config import config
from topydo.lib.Config import config
PRIORITY_COLORS = {
'A': '\033[36m', # cyan
......
......@@ -14,10 +14,10 @@
# 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 Command import Command, InvalidCommandArgument
from PrettyPrinter import pretty_print
from TodoListBase import InvalidTodoException
from Utils import is_valid_priority
from topydo.lib.Command import Command, InvalidCommandArgument
from topydo.lib.PrettyPrinter import pretty_print
from topydo.lib.TodoListBase import InvalidTodoException
from topydo.lib.Utils import is_valid_priority
class PriorityCommand(Command):
def __init__(self, p_args, p_todolist,
......
......@@ -18,9 +18,9 @@
from datetime import date, timedelta
from Config import config
from RelativeDate import relative_date_to_date
import Todo
from topydo.lib.Config import config
from topydo.lib.RelativeDate import relative_date_to_date
from topydo.lib.Todo import Todo
class NoRecurrenceException(Exception):
pass
......@@ -33,7 +33,7 @@ def _advance_recurring_todo_helper(p_todo, p_offset):
When no recurrence tag is present, an exception is raised.
"""
todo = Todo.Todo(p_todo.source())
todo = Todo(p_todo.source())
pattern = todo.tag_value('rec')
if not pattern:
......
......@@ -14,9 +14,9 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from Command import Command, InvalidCommandArgument
from Config import config
import Sorter
from topydo.lib.Command import Command, InvalidCommandArgument
from topydo.lib.Config import config
from topydo.lib.Sorter import Sorter
class SortCommand(Command):
def __init__(self, p_args, p_todolist,
......@@ -35,7 +35,7 @@ class SortCommand(Command):
except InvalidCommandArgument:
expression = config().sort_string()
sorter = Sorter.Sorter(expression) # TODO: validate
sorter = Sorter(expression) # TODO: validate
sorted_todos = sorter.sort(self.todolist.todos())
self.todolist.erase()
......
......@@ -19,7 +19,7 @@
from datetime import date
import re
from Importance import importance, average_importance
from topydo.lib.Importance import importance, average_importance
def is_priority_field(p_field):
""" Returns True when the field name denotes the priority. """
......
......@@ -14,9 +14,9 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from Command import Command, InvalidCommandArgument
from TodoListBase import InvalidTodoException
from PrettyPrinter import pretty_print
from topydo.lib.Command import Command, InvalidCommandArgument
from topydo.lib.TodoListBase import InvalidTodoException
from topydo.lib.PrettyPrinter import pretty_print
class TagCommand(Command):
def __init__(self, p_args, p_todolist,
......
......@@ -20,24 +20,24 @@ This module provides the Todo class.
from datetime import date
from Config import config
import Utils
import TodoBase
from topydo.lib.Config import config
from topydo.lib.TodoBase import TodoBase
from topydo.lib.Utils import date_string_to_date
class Todo(TodoBase.TodoBase):
class Todo(TodoBase):
"""
This class adds common functionality with respect to dates to the Todo
base class, mainly by interpreting the start and due dates of task.
"""
def __init__(self, p_str):
TodoBase.TodoBase.__init__(self, p_str)
TodoBase.__init__(self, p_str)
self.attributes = {}
def get_date(self, p_tag):
""" Given a date tag, return a date object. """
string = self.tag_value(p_tag)
return Utils.date_string_to_date(string) if string else None
return date_string_to_date(string) if string else None
def start_date(self):
""" Returns a date object of the todo's start date. """
......
......@@ -21,8 +21,8 @@ This module contains the class that represents a single todo item.
from datetime import date
import re
import TodoParser
from Utils import is_valid_priority
from topydo.lib.TodoParser import parse_line
from topydo.lib.Utils import is_valid_priority
class TodoBase(object):
"""
......@@ -164,7 +164,7 @@ class TodoBase(object):
def set_source_text(self, p_text):
""" Sets the todo source text. The text will be parsed again. """
self.src = p_text.strip()
self.fields = TodoParser.parse_line(self.src)
self.fields = parse_line(self.src)
def projects(self):
""" Returns a set of projects associated with this todo item. """
......
......@@ -18,10 +18,10 @@
A list of todo items.
"""
import Graph
import TodoListBase
from topydo.lib.Graph import DirectedGraph
from topydo.lib.TodoListBase import TodoListBase
class TodoList(TodoListBase.TodoListBase):
class TodoList(TodoListBase):
"""
Provides operations for a todo list, such as adding items, removing them,
etc.
......@@ -37,7 +37,7 @@ class TodoList(TodoListBase.TodoListBase):
"""
self._todos = []
self._tododict = {} # hash(todo) to todo lookup
self._depgraph = Graph.DirectedGraph()
self._depgraph = DirectedGraph()
self.add_list(p_todostrings)
self.dirty = False
......
......@@ -21,10 +21,10 @@ A list of todo items.
from datetime import date
import re
import Filter
from PrettyPrinter import pretty_print_list
import Todo
import View
from topydo.lib import Filter
from topydo.lib.PrettyPrinter import pretty_print_list
from topydo.lib.Todo import Todo
from topydo.lib.View import View
class InvalidTodoException(Exception):
pass
......@@ -87,7 +87,7 @@ class TodoListBase(object):
return todos[0] if len(todos) else None
def add_list(self, p_srcs):
todos = [Todo.Todo(src) for src in p_srcs if re.search(r'\S', src)]
todos = [Todo(src) for src in p_srcs if re.search(r'\S', src)]
self.add_todos(todos)
return todos
......@@ -154,7 +154,7 @@ class TodoListBase(object):
defined by the end user. Todos is this list should not be modified,
modifications should occur through this class.
"""
return View.View(p_sorter, p_filters, self)
return View(p_sorter, p_filters, self)
def is_dirty(self):
return self.dirty
......
......@@ -21,7 +21,7 @@ todo.txt file.
import re
import Utils
from topydo.lib.Utils import date_string_to_date
_DATE_MATCH = r'\d{4}-\d{2}-\d{2}'
......@@ -68,17 +68,17 @@ def parse_line(p_string):
result['completed'] = True
completion_date = completed_head.group('completionDate')
result['completionDate'] = Utils.date_string_to_date(completion_date)
result['completionDate'] = date_string_to_date(completion_date)
creation_date = completed_head.group('creationDate')
result['creationDate'] = Utils.date_string_to_date(creation_date)
result['creationDate'] = date_string_to_date(creation_date)
rest = completed_head.group('rest')
elif normal_head:
result['priority'] = normal_head.group('priority')
creation_date = normal_head.group('creationDate')
result['creationDate'] = Utils.date_string_to_date(creation_date)
result['creationDate'] = date_string_to_date(creation_date)
rest = normal_head.group('rest')
......
......@@ -16,7 +16,7 @@
""" A view is a list of todos, sorted and filtered. """
from PrettyPrinter import pretty_print_list, pp_color
from topydo.lib.PrettyPrinter import pretty_print_list, pp_color
class View(object):
"""
......
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