Esempio n. 1
0
 def test_indexes_are_added(self):
     """New indexes are added when a new store is created."""
     store = TodoStore(self.db)
     store.initialize_db()
     INDEXES['foo'] = 'bar'
     self.assertNotIn('foo', dict(self.db.list_indexes()))
     store = TodoStore(self.db)
     store.initialize_db()
     self.assertIn('foo', dict(self.db.list_indexes()))
Esempio n. 2
0
 def test_indexes_are_updated(self):
     """Indexes are updated when a new store is created."""
     store = TodoStore(self.db)
     store.initialize_db()
     new_expression = 'newtags'
     INDEXES[TAGS_INDEX] = new_expression
     self.assertNotEqual(
         new_expression, dict(self.db.list_indexes())['tags'])
     store = TodoStore(self.db)
     store.initialize_db()
     self.assertEqual(
         [new_expression], dict(self.db.list_indexes())['tags'])
Esempio n. 3
0
 def test_reinitialize_db(self):
     """Creates indexes."""
     store = TodoStore(self.db)
     store.new_task()
     store.initialize_db()
     for key, value in self.db.list_indexes():
         self.assertEqual(INDEXES[key], value[0])
Esempio n. 4
0
 def test_tag_task(self):
     """Sets the tags for a task."""
     store = TodoStore(self.db)
     task = store.new_task()
     tag = "you're it"
     store.tag_task(task, [tag])
     self.assertEqual([tag], task.tags)
Esempio n. 5
0
 def test_save_task_get_task(self):
     """Saves a modified task and retrieves it from the db."""
     store = TodoStore(self.db)
     task = store.new_task()
     task.title = "This is the title."
     store.save_task(task)
     task_copy = store.get_task(task.task_id)
     self.assertEqual(task.title, task_copy.title)
Esempio n. 6
0
 def test_get_all_tags_duplicates(self):
     store = TodoStore(self.db)
     store.initialize_db()
     tags = ['foo', 'bar', 'bam']
     store.new_task(tags=tags)
     self.assertEqual(sorted(tags), sorted(store.get_all_tags()))
     tags2 = ['foo', 'sball']
     store.new_task(tags=tags2)
     self.assertEqual(set(tags + tags2), set(store.get_all_tags()))
Esempio n. 7
0
 def test_get_all_tags(self):
     store = TodoStore(self.db)
     store.initialize_db()
     tags = ['foo', 'bar', 'bam']
     task = store.new_task(tags=tags)
     self.assertEqual(sorted(tags), sorted(store.get_all_tags()))
     tags = ['foo', 'sball']
     task.tags = tags
     store.save_task(task)
     self.assertEqual(sorted(tags), sorted(store.get_all_tags()))
Esempio n. 8
0
 def test_get_all_tasks(self):
     store = TodoStore(self.db)
     store.initialize_db()
     task1 = store.new_task()
     task2 = store.new_task()
     task3 = store.new_task()
     task_ids = [task.task_id for task in store.get_all_tasks()]
     self.assertEqual(
         sorted([task1.task_id, task2.task_id, task3.task_id]),
         sorted(task_ids))
Esempio n. 9
0
 def test_get_tasks_by_empty_tags(self):
     store = TodoStore(self.db)
     store.initialize_db()
     tags = ['foo', 'bar', 'bam']
     task1 = store.new_task(tags=tags)
     tags2 = ['foo', 'sball']
     task2 = store.new_task(tags=tags2)
     self.assertEqual(
         sorted([task1.task_id, task2.task_id]),
         sorted([t.task_id for t in store.get_tasks_by_tags([])]))
Esempio n. 10
0
 def test_delete_task(self):
     """Deletes a task by id."""
     store = TodoStore(self.db)
     task = store.new_task()
     store.delete_task(task)
     self.assertRaises(KeyError, store.get_task, task.task_id)
Esempio n. 11
0
 def test_get_non_existant_task(self):
     """Saves a modified task and retrieves it from the db."""
     store = TodoStore(self.db)
     self.assertRaises(KeyError, store.get_task, "nonexistant")
Esempio n. 12
0
 def test_new_task_with_tags(self):
     """Creates a new task."""
     store = TodoStore(self.db)
     tags = ['foo', 'bar', 'bam']
     task = store.new_task(tags=tags)
     self.assertEqual(tags, task.tags)
Esempio n. 13
0
 def test_new_task_with_title(self):
     """Creates a new task."""
     store = TodoStore(self.db)
     title = "Un task muy importante"
     task = store.new_task(title=title)
     self.assertEqual(title, task.title)
Esempio n. 14
0
 def test_new_task(self):
     """Creates a new task."""
     store = TodoStore(self.db)
     task = store.new_task()
     self.assertTrue(isinstance(task, Task))
     self.assertIsNotNone(task.task_id)