def test_projects2(self): todolist = load_file_to_todolist("test/data/TodoListTest.txt") command = ListProjectCommand(["aaa"], todolist, self.out, self.error) command.execute() self.assertEqual(self.output, "Project1\nProject2\n") self.assertFalse(self.errors)
def test_contexts1(self): todolist = load_file_to_todolist("test/data/TodoListTest.txt") command = ListContextCommand([""], todolist, self.out, self.error) command.execute() self.assertEqual(self.output,"Context1\nContext2\n") self.assertFalse(self.errors)
def test_sort14(self): sorter = Sorter('desc:importance-average') todolist = load_file_to_todolist('test/data/SorterTest10.txt') view = todolist.view(sorter, []) result = load_file('test/data/SorterTest10-result.txt') self.assertEqual(print_view(view), todolist_to_string(result))
def test_filter7(self): """ Tests the dependency filter. """ todolist = load_file_to_todolist('test/data/FilterTest2.txt') depfilter = Filter.DependencyFilter(todolist) filtered_todos = depfilter.filter(todolist.todos()) reference = load_file('test/data/FilterTest2-result.txt') self.assertEqual(todolist_to_string(filtered_todos), \ todolist_to_string(reference))
def test_filter7(self): """ Tests the dependency filter. """ todolist = load_file_to_todolist('test/data/FilterTest2.txt') depfilter = Filter.DependencyFilter(todolist) filtered_todos = depfilter.filter(todolist.todos()) reference = load_file('test/data/FilterTest2-result.txt') self.assertEquals(todolist_to_string(filtered_todos), \ todolist_to_string(reference))
def test_sort16(self): """ Check sort of low priority tasks (D or lower) with non-priority tasks. """ sorter = Sorter('desc:importance,desc:prio') todolist = load_file_to_todolist('test/data/SorterTest12.txt') view = todolist.view(sorter, []) result = load_file('test/data/SorterTest12-result.txt') self.assertEqual(print_view(view), todolist_to_string(result))
def test_archive(self): todolist = load_file_to_todolist("test/data/ArchiveCommandTest.txt") archive = TodoList([]) command = ArchiveCommand(todolist, archive) command.execute() self.assertTrue(todolist.is_dirty()) self.assertTrue(archive.is_dirty()) self.assertEqual(todolist.print_todos(), "x Not complete\n(C) Active") self.assertEqual(archive.print_todos(), "x 2014-10-19 Complete\nx 2014-10-20 Another one complete")
def test_ical_python32(self): """ Test case for Python 3.2 where icalendar is not supported. """ todolist = load_file_to_todolist("test/data/ListCommandTest.txt") command = ListCommand(["-f", "ical"], todolist, self.out, self.error) command.execute() self.assertFalse(todolist.is_dirty()) self.assertEqual(self.output, '') self.assertEqual(self.errors, "icalendar is not supported in this Python version.\n")
def test_sort15(self): """ Test that own importance is used when average turns out to be lower. """ sorter = Sorter('desc:importance-average') todolist = load_file_to_todolist('test/data/SorterTest11.txt') view = todolist.view(sorter, []) result = load_file('test/data/SorterTest11-result.txt') self.assertEqual(print_view(view), todolist_to_string(result))
def test_archive(self): todolist = load_file_to_todolist("test/data/ArchiveCommandTest.txt") archive = TodoList([]) command = ArchiveCommand(todolist, archive) command.execute() self.assertTrue(todolist.is_dirty()) self.assertTrue(archive.is_dirty()) self.assertEqual(todolist.print_todos(), "x Not complete\n(C) Active") self.assertEqual( archive.print_todos(), "x 2014-10-19 Complete\nx 2014-10-20 Another one complete")
def test_ical_unicode(self): todolist = load_file_to_todolist("test/data/ListCommandUnicodeTest.txt") command = ListCommand(["-f", "ical"], todolist, self.out, self.error) command.execute() self.assertTrue(todolist.is_dirty()) icaltext = "" with codecs.open('test/data/ListCommandUnicodeTest.ics', 'r', encoding='utf-8') as ical: icaltext = ical.read() self.assertEqual(replace_ical_tags(self.output), replace_ical_tags(icaltext)) self.assertEqual(self.errors, "")
def test_json_unicode(self): todolist = load_file_to_todolist("test/data/ListCommandUnicodeTest.txt") command = ListCommand(["-f", "json"], todolist, self.out, self.error) command.execute() self.assertFalse(todolist.is_dirty()) jsontext = "" with codecs.open('test/data/ListCommandUnicodeTest.json', 'r', encoding='utf-8') as json: jsontext = json.read() self.assertEqual(self.output, jsontext) self.assertEqual(self.errors, "")
def test_ical_python32(self): """ Test case for Python 3.2 where icalendar is not supported. """ todolist = load_file_to_todolist("test/data/ListCommandTest.txt") command = ListCommand(["-f", "ical"], todolist, self.out, self.error) command.execute() self.assertFalse(todolist.is_dirty()) self.assertEqual(self.output, '') self.assertEqual( self.errors, "icalendar is not supported in this Python version.\n")
def test_json(self): todolist = load_file_to_todolist("test/data/ListCommandTest.txt") command = ListCommand(["-f", "json"], todolist, self.out, self.error) command.execute() self.assertFalse(todolist.is_dirty()) jsontext = "" with codecs.open('test/data/ListCommandTest.json', 'r', encoding='utf-8') as json: jsontext = json.read() self.assertEqual(self.output, jsontext) self.assertEqual(self.errors, "")
def test_ical_unicode(self): todolist = load_file_to_todolist( "test/data/ListCommandUnicodeTest.txt") command = ListCommand(["-f", "ical"], todolist, self.out, self.error) command.execute() self.assertTrue(todolist.is_dirty()) icaltext = "" with codecs.open('test/data/ListCommandUnicodeTest.ics', 'r', encoding='utf-8') as ical: icaltext = ical.read() self.assertEqual(replace_ical_tags(self.output), replace_ical_tags(icaltext)) self.assertEqual(self.errors, "")
def setUp(self): super(SortCommandTest, self).setUp() self.todolist = load_file_to_todolist("test/data/SorterTest1.txt")
def setUp(self): super(ListCommandTest, self).setUp() self.todolist = load_file_to_todolist("test/data/ListCommandTest.txt")