def test_priority_setter_exception(self): todo_entry = TodoEntry( 'x (A) Make @Cute +T1 +T2 c1:c2 c3:c4 with c-c-c-c-c') with self.assertRaises(ValueError) as cm: todo_entry.priority = 'AA' with self.assertRaises(TypeError) as cm: todo_entry.priority = 5 with self.assertRaises(TypeError) as cm: todo_entry.priority = TodoEntry('')
def test_base_entry(self): todotxt_text = '(A) Make @Cute +T1 +T2 c1:c2 c3:c4 with c-c-c-c-c' todo_entry = TodoEntry(todotxt_text) self.assertEqual(todo_entry.completed, False) self.assertEqual(todo_entry.priority, 'A') self.assertEqual(todo_entry.projects, {'T1', 'T2'}) self.assertEqual(todo_entry.contexts, {'Cute', }) self.assertEqual(todo_entry.completed_date, None) self.assertEqual(todo_entry.created_date, None) self.assertEqual(todo_entry.tags, dict(c1='c2', c3='c4'))
def test_completed_with_many_dates(self): todotxt_text = 'x (A) 2016-05-06 2016-05-05 2016-05-04 Make @Cute +T1 +T2 c1:c2 c3:c4 with c-c-c-c-c' todo_entry = TodoEntry(todotxt_text) self.assertEqual(todo_entry.completed, True) self.assertEqual(todo_entry.priority, 'A') self.assertEqual(todo_entry.projects, {'T1', 'T2'}) self.assertEqual(todo_entry.contexts, {'Cute', }) self.assertEqual(todo_entry.completed_date, '2016-05-06') self.assertEqual(todo_entry.created_date, '2016-05-05') self.assertEqual(todo_entry.tags, dict(c1='c2', c3='c4'))
def test_create_with_complete_date(self): todotxt_text = 'x (B) 2017-01-01 Make @Cute +T1 +T2 c1:c2 c3:c4 with c-c-c-c-c' todo_entry = TodoEntry(todotxt_text) self.assertEqual(todo_entry.completed, True) self.assertEqual(todo_entry.priority, 'B') self.assertEqual(todo_entry.projects, {'T1', 'T2'}) self.assertEqual(todo_entry.contexts, {'Cute', }) self.assertEqual(todo_entry.completed_date, None) self.assertEqual(todo_entry.created_date, '2017-01-01') self.assertEqual(todo_entry.tags, dict(c1='c2', c3='c4'))
def test_completed_date_setter_exception(self): todo_entry = TodoEntry( '(A) Make @Cute +T1 +T2 c1:c2 c3:c4 with c-c-c-c-c') with self.assertRaises(ValueError) as cm: todo_entry.completed_date = '2017-01-01' self.assertEqual(cm.exception.args[0], "Please, complete todo entry first") todo_entry.completed = True with self.assertRaises(ValueError) as cm: todo_entry.completed_date = '2017-01-01' self.assertEqual(cm.exception.args[0], "Cannot set completed_date without created_date")
def test_add_tag(self): todotxt_text = '(A) Make @Cute +T1 +T2 c1:c2 c3:c4 with c-c-c-c-c' todo_entry = TodoEntry(todotxt_text) todo_entry.remove_tag('c3', 'c4') self.assertEqual(todo_entry.completed, False) self.assertEqual(todo_entry.priority, 'A') self.assertEqual(todo_entry.projects, {'T1', 'T2'}) self.assertEqual(todo_entry.contexts, {'Cute'}) self.assertEqual(todo_entry.completed_date, None) self.assertEqual(todo_entry.created_date, None) self.assertEqual(todo_entry.tags, dict(c1='c2')) self.assertEqual(str(todo_entry), '(A) Make @Cute +T1 +T2 c1:c2 with c-c-c-c-c')
def __init__(self, name, project=None): if isinstance(name, TodoEntry): self.entry = name else: self.entry = TodoEntry(name) self.project = project
def test_created_date_setter_positive(initial_entry, result_entry, created_date_value): todo_entry = TodoEntry(initial_entry) todo_entry.created_date = created_date_value assert str(todo_entry) == result_entry
def test_completed_setter_positive(initial_entry, result_entry, completed_value): todo_entry = TodoEntry(initial_entry) todo_entry.completed = completed_value assert str(todo_entry) == result_entry
def test_priority_setter_positive(initial_entry, result_entry, priority_value): todo_entry = TodoEntry(initial_entry) todo_entry.priority = priority_value assert str(todo_entry) == result_entry
def test_merge_logic(initial_entry_text, additional_entry_text, required_result): initial_entry = TodoEntry(initial_entry_text) additional_entry = TodoEntry(additional_entry_text) initial_entry.merge(additional_entry) assert str(initial_entry) == required_result
def test_equality(self): entry1 = TodoEntry('(A) Make @Cute +T1 +T2 c1:c2 c3:c4 with c-c-c-c-c') entry2 = TodoEntry('(B) Make @Cute +T1 +T2 c1:c2 c3:c4 with c-c-c-c-c') entry2.priority = 'A' self.assertEqual(entry1, entry2)
def test_str(self): todo_text = '(A) Make @Cute +T1 +T2 c1:c2 c3:c4 with c-c-c-c-c' todo_entry = TodoEntry(todo_text) self.assertEqual(str(todo_entry), todo_text)
def test_hash(self): todo_text = '(A) Make @Cute +T1 +T2 c1:c2 c3:c4 with c-c-c-c-c' todo_entry = TodoEntry(todo_text) self.assertEqual(hash(todo_text), hash(todo_entry))