Commit 75627f3d authored by Bram Schoenmakers's avatar Bram Schoenmakers

Add tests for configurable alphabet

parent f8d4a5af
...@@ -434,6 +434,48 @@ class ListCommandTest(CommandTest): ...@@ -434,6 +434,48 @@ class ListCommandTest(CommandTest):
self.assertEqual(self.output, '|2| This item is visible\n') self.assertEqual(self.output, '|2| This item is visible\n')
self.assertEqual(self.errors, "") self.assertEqual(self.errors, "")
def test_list50(self):
"""
Fallback to normal alphabet for too short alphabets, fallback on
default alphabet.
"""
config(p_overrides={('topydo', 'identifier_alphabet'): 'a', ('topydo', 'identifiers'): 'text'})
# self.todolist was loaded with old identifier settings
todolist = load_file_to_todolist("test/data/ListCommandTest.txt")
command = ListCommand(["-F", "%I", "Foo"], todolist, self.out, self.error)
command.execute()
self.assertEqual(self.output, "t5c\n")
self.assertEqual(self.errors, '')
def test_list51(self):
""" Test hexadecimal IDs """
config(p_overrides={('topydo', 'identifier_alphabet'): '0123456789abcdef', ('topydo', 'identifiers'): 'text'})
# self.todolist was loaded with old identifier settings
todolist = load_file_to_todolist("test/data/ListCommandTest.txt")
command = ListCommand(["-F", "%i", "Foo"], todolist, self.out, self.error)
command.execute()
self.assertEqual(self.output, '2c8\n')
self.assertEqual(self.errors, '')
def test_list52(self):
""" Alphabet is too short due to duplicate characters """
config(p_overrides={('topydo', 'identifier_alphabet'): '0123456788', ('topydo', 'identifiers'): 'text'})
# self.todolist was loaded with old identifier settings
todolist = load_file_to_todolist("test/data/ListCommandTest.txt")
command = ListCommand(["-F", "%i", "Foo"], todolist, self.out, self.error)
command.execute()
self.assertEqual(self.output, 't5c\n')
self.assertEqual(self.errors, '')
def test_list_name(self): def test_list_name(self):
name = ListCommand.name() name = ListCommand.name()
......
...@@ -23,6 +23,7 @@ from test.command_testcase import CommandTest ...@@ -23,6 +23,7 @@ from test.command_testcase import CommandTest
from test.facilities import load_file_to_todolist from test.facilities import load_file_to_todolist
from topydo.commands.ListCommand import ListCommand from topydo.commands.ListCommand import ListCommand
from topydo.lib.Config import config from topydo.lib.Config import config
from topydo.lib.TodoListBase import TodoListBase
# We're searching for 'mock' # We're searching for 'mock'
# 'mock' was added as 'unittest.mock' in Python 3.3, but PyPy 3 is based on Python 3.2 # 'mock' was added as 'unittest.mock' in Python 3.3, but PyPy 3 is based on Python 3.2
...@@ -763,5 +764,12 @@ x 2014-12-12 Completed but with date:2014-12-12 ...@@ -763,5 +764,12 @@ x 2014-12-12 Completed but with date:2014-12-12
self.assertEqual(self.output, result) self.assertEqual(self.output, result)
self.assertEqual(self.errors, "") self.assertEqual(self.errors, "")
def test_list_format52(self):
config(p_overrides={('topydo', 'identifier_alphabet'): '0123456789abcdef', ('topydo', 'identifiers'): 'text'})
# make sure that it fallbacks to the default alphabet
todolist = TodoListBase([str(i) for i in range(0, 100 * 16 * 10)])
self.assertEqual(4, todolist.max_id_length())
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
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