Ejemplo n.º 1
0
 def test_manager_delete_entry_deletes_the_entry_correctly(self):
     tasks_manager = SimpleTasksManager('work', self.storage)
     jobs = ['one job', 'two job', 'three job']
     for job in jobs:
         tasks_manager.add_entry(job)
     saved_jobs = [file['./work.foo']['tasks'][i]['name'] for i in range(len(file['./work.foo']['tasks']))]
     self.assertEqual(saved_jobs, jobs)
     tasks_manager.delete_entry('two job')
     saved_jobs = [file['./work.foo']['tasks'][i]['name'] for i in range(len(file['./work.foo']['tasks']))]
     self.assertEqual(['one job', 'three job'], saved_jobs)
Ejemplo n.º 2
0
 def test_manager_edit_renames_task_correctly_given_partial_match_of_task_name_based_on_name_prefix(self):
     tasks_manager = SimpleTasksManager('work', self.storage)
     tasks_manager.add_entry('one job')
     tasks_manager.edit_entry('one', 'yet another job')
     self.assertEqual(1, len(file['./work.foo']['tasks']))
     self.assertEqual('yet another job', file['./work.foo']['tasks'][0]['name'])
Ejemplo n.º 3
0
 def test_manager_get_full_name_get_the_complete_name_of_the_entry_correctly(self):
     tasks_manager = SimpleTasksManager('work', self.storage)
     tasks_manager.add_entry('one job')
     tasks_manager.add_entry('two job')
     tasks_manager.add_entry('three job')
     self.assertEqual('one job', tasks_manager.get_entry_full_name('one'))
Ejemplo n.º 4
0
 def test_manager_raises_error_when_task_already_exists(self):
     tasks_manager = SimpleTasksManager('work', self.storage)
     tasks_manager.add_entry('job 1')
     self.assertRaises(UniqueViolationError, tasks_manager.add_entry, 'job 1')
Ejemplo n.º 5
0
 def test_manager_edit_renames_task_correctly(self):
     tasks_manager = SimpleTasksManager('work', self.storage)
     tasks_manager.add_entry('job 1')
     tasks_manager.edit_entry('job 1', 'one job')
     self.assertEqual(1, len(file['./work.foo']['tasks']))
     self.assertEqual('one job', file['./work.foo']['tasks'][0]['name'])
Ejemplo n.º 6
0
 def test_tasks_manager_retrieve_returns_a_tasks(self):
     tasks_manager = SimpleTasksManager('work', self.storage)
     tasks = tasks_manager.retrieve()
     self.assertTrue(isinstance(tasks, SimpleTasks))
Ejemplo n.º 7
0
 def test_tasks_manager_storage_path_use_storage_path_method_to_give_the_path(self):
     tasks_manager = SimpleTasksManager('work', self.storage)
     self.assertEqual('./work.foo', tasks_manager.storage_path)
Ejemplo n.º 8
0
 def test_tasks_manager_undo_undoes_an_entry_for_and_existing_entry(self):
     tasks_manager = SimpleTasksManager('work', self.storage)
     tasks_manager.add_entry('job 1')
     tasks_manager.finish_entry(entry='job 1')
     tasks_manager.undo_entry(entry='job 1')
     self.assertEqual(file['./work.foo'], {'group': 'work', 'tasks': [{'done': False, 'name': 'job 1'}]})
Ejemplo n.º 9
0
 def test_tasks_manager_undo_creates_new_entry_for_non_existing_ones(self):
     tasks_manager = SimpleTasksManager('work', self.storage)
     tasks_manager.undo_entry(entry='job 1')
     self.assertTrue('./work.foo' in file)
     self.assertEqual(file['./work.foo'], {'group': 'work', 'tasks': [{'done': False, 'name': 'job 1'}]})
Ejemplo n.º 10
0
 def test_tasks_manager_finish_makes_the_entry_done_if_it_already_existing(self):
     tasks_manager = SimpleTasksManager('work', self.storage)
     tasks_manager.add_entry('job 1')
     tasks_manager.finish_entry(entry='job 1')
     self.assertEqual(file['./work.foo'], {'group': 'work', 'tasks': [{'done': True, 'name': 'job 1'}]})
Ejemplo n.º 11
0
 def test_tasks_manager_finish_entry_creates_and_finishes_task_if_not_existing_already(self):
     tasks_manager = SimpleTasksManager('work', self.storage)
     tasks_manager.finish_entry(entry='job 1')
     self.assertTrue('./work.foo' in file)
     self.assertEqual(file['./work.foo'], {'group': 'work', 'tasks': [{'done': True, 'name': 'job 1'}]})
Ejemplo n.º 12
0
 def test_tasks_manager_add_entry_creates_the_appropriate_file_if_not_existing_already(self):
     tasks_manager = SimpleTasksManager('work', self.storage)
     tasks_manager.add_entry(entry='job 1')
     self.assertTrue('./work.foo' in file)
Ejemplo n.º 13
0
 def test_tasks_manager_initializes_with_a_name_and_a_storage(self):
     self.assertTrue(SimpleTasksManager('work', self.storage))
Ejemplo n.º 14
0
 def create(name: str):
     storage_path = click.get_app_dir('tasks')
     return SimpleTasksManager(
         name,
         SimpleJsonStorageFactory().create(storage_path))