def test_working(self): item = Item(name='w8in4') item.status = Item.WAITING_FOR item.save() response = Client().get(reverse('gtdmanager:waiting')) self.assertEqual(response.status_code, 200) self.assertItemsEqual((item, ), response.context['items'])
def test_someday_item(self): item = Item(name='maybe') item.save() self.assertEqual(item.status, Item.UNRESOLVED) response = Client().get(reverse('gtdmanager:item_someday', args=(item.id,))) item = Item.objects.get(id=item.id) self.assertEqual(item.status, Item.SOMEDAY)
def test_working(self): item = Item(name='ref') item.status = Item.REFERENCE item.save() response = Client().get(reverse('gtdmanager:references')) self.assertEqual(response.status_code, 200) self.assertItemsEqual((item, ), response.context['items'])
def test_wait_item(self): item = Item(name='waiting for Xmas') item.save() self.assertEqual(item.status, Item.UNRESOLVED) response = Client().get(reverse('gtdmanager:item_wait', args=(item.id,))) item = Item.objects.get(id=item.id) self.assertEqual(item.status, Item.WAITING_FOR)
def test_complete_item(self): item = Item(name='completed item') item.save() self.assertEqual(item.status, Item.UNRESOLVED) response = Client().get(reverse('gtdmanager:item_complete', args=(item.id, 'inbox'))) item = Item.objects.get(id=item.id) self.assertEqual(item.status, Item.COMPLETED)
def test_reference_item(self): item = Item(name='reference') item.save() self.assertEqual(item.status, Item.UNRESOLVED) response = Client().get(reverse('gtdmanager:item_reference', args=(item.id,))) item = Item.objects.get(id=item.id) self.assertEqual(item.status, Item.REFERENCE)
def test_working(self): item = Item(name='ref') item.status = Item.SOMEDAY item.save() response = Client().get(reverse('gtdmanager:someday')) self.assertEqual(response.status_code, 200) self.assertItemsEqual((item,), response.context['items'])
def test_working(self): item = Item(name='ref') item.status = Item.REFERENCE item.save() response = Client().get(reverse('gtdmanager:references')) self.assertEqual(response.status_code, 200) self.assertItemsEqual((item,), response.context['items'])
def test_working(self): item = Item(name='w8in4') item.status = Item.WAITING_FOR item.save() response = Client().get(reverse('gtdmanager:waiting')) self.assertEqual(response.status_code, 200) self.assertItemsEqual((item,), response.context['items'])
def test_working(self): item = Item(name='ref') item.status = Item.SOMEDAY item.save() response = Client().get(reverse('gtdmanager:someday')) self.assertEqual(response.status_code, 200) self.assertItemsEqual((item, ), response.context['items'])
def convert(self, with_save): item = Item(name='task') if (with_save): item.save() converted = Item.objects.convertTo(Next, item) self.assertIsInstance(converted, Next) self.assertEqual(Item.objects.count(), 1) self.assertEqual(Next.objects.count(), 1)
def test_complete_item(self): item = Item(name='completed item') item.save() self.assertEqual(item.status, Item.UNRESOLVED) response = Client().get( reverse('gtdmanager:item_complete', args=(item.id, 'inbox'))) item = Item.objects.get(id=item.id) self.assertEqual(item.status, Item.COMPLETED)
def test_item_to_project(self): item = Item(name='perfect project') item.save() self.assertEqual(item.status, Item.UNRESOLVED) Client().get(reverse('gtdmanager:item_to_project', args=(item.id,))) item = Item.objects.get(id=item.id) self.assertEqual(item.status, Item.PROJECT) self.assertEqual(len(Item.objects.all()), 1) # no new item not created
def test_has_short_id(self): """ Tests whether Item class has some sort of short id (e.g. id field) that can be used for identifying in URLs """ item = Item(name="item") item.save() self.assertTrue(item.id in (0,1))
def test_has_short_id(self): """ Tests whether Item class has some sort of short id (e.g. id field) that can be used for identifying in URLs """ item = Item(name="item") item.save() self.assertTrue(item.id in (0, 1))
def test_reference_item(self): item = Item(name='reference') item.save() self.assertEqual(item.status, Item.UNRESOLVED) response = Client().get( reverse('gtdmanager:item_reference', args=(item.id, ))) item = Item.objects.get(id=item.id) self.assertEqual(item.status, Item.REFERENCE)
def test_someday_item(self): item = Item(name='maybe') item.save() self.assertEqual(item.status, Item.UNRESOLVED) response = Client().get( reverse('gtdmanager:item_someday', args=(item.id, ))) item = Item.objects.get(id=item.id) self.assertEqual(item.status, Item.SOMEDAY)
def test_wait_item(self): item = Item(name='waiting for Xmas') item.save() self.assertEqual(item.status, Item.UNRESOLVED) response = Client().get( reverse('gtdmanager:item_wait', args=(item.id, ))) item = Item.objects.get(id=item.id) self.assertEqual(item.status, Item.WAITING_FOR)
def test_item_to_project(self): item = Item(name='perfect project') item.save() self.assertEqual(item.status, Item.UNRESOLVED) Client().get(reverse('gtdmanager:item_to_project', args=(item.id, ))) item = Item.objects.get(id=item.id) self.assertEqual(item.status, Item.PROJECT) self.assertEqual(len(Item.objects.all()), 1) # no new item not created
def test_convert(self): item = Item(name='Tst') item.save() self.assertEqual(item.status, Item.UNRESOLVED) self.assertEqual(len(Item.objects.all()), 1) self.assertEqual(len(Project.objects.all()), 0) p = Item.objects.convertTo(Project, item) p.save() self.assertEqual(p.status, Item.PROJECT) self.assertEqual(len(Item.objects.all()), 1) self.assertEqual(len(Project.objects.all()), 1)
def test_active_childs_item(self): p = Project(name='p') p.save() Item(name='compl', status=Item.COMPLETED, parent=p).save() Item(name='del', status=Item.DELETED, parent=p).save() Item(name='sm', status=Item.SOMEDAY, parent=p).save() Item(name='ref', status=Item.REFERENCE, parent=p).save() waiting = Item(name='wait', status=Item.WAITING_FOR, parent=p) waiting.save() reminder = Reminder(name='arem', parent=p) reminder.save() anext = Next(name='next', parent=p) anext.save() self.assertEqual(p.item_set.count(), 7) self.assertItemsEqual((waiting, anext, reminder), p.active_childs())
def template_cancel(self, cls, class_url): item = Item(name='item') item.save() client = Client() # convert to next response = client.get(reverse('gtdmanager:' + class_url + '_edit', args=(item.id, 'inbox'))) self.assertEqual(response.status_code, 200) converted = cls.objects.get(pk=item.id) self.assertEqual(converted.name, item.name) # cancel response = client.get(reverse('gtdmanager:' + class_url + '_to_item', args=(converted.id, 'inbox'))) self.assertRedirects(response, reverse('gtdmanager:inbox')) self.assertEqual(cls.objects.count(), 0) item = Item.objects.get(pk=item.id) self.assertEqual(converted.name, item.name)
def template_cancel(self, cls, class_url): item = Item(name='item') item.save() client = Client() # convert to next response = client.get( reverse('gtdmanager:' + class_url + '_edit', args=(item.id, 'inbox'))) self.assertEqual(response.status_code, 200) converted = cls.objects.get(pk=item.id) self.assertEqual(converted.name, item.name) # cancel response = client.get( reverse('gtdmanager:' + class_url + '_to_item', args=(converted.id, 'inbox'))) self.assertRedirects(response, reverse('gtdmanager:inbox')) self.assertEqual(cls.objects.count(), 0) item = Item.objects.get(pk=item.id) self.assertEqual(converted.name, item.name)
def test_gtddelete(self): item = Item(name='del') item.gtddelete() self.assertEqual(Item.DELETED, item.status)
def _prepare_with_active_subproject(self): p, sub = self._prepare_with_child(Project) i = Item(name='item', parent = sub) i.save() return (p, sub, i)
def _prepare_with_active_subproject(self): p, sub = self._prepare_with_child(Project) i = Item(name='item', parent=sub) i.save() return (p, sub, i)
def test_complete(self): item = Item(name='compl') item.complete() self.assertEqual(Item.COMPLETED, item.status)
def __init__(self, *args, **kwargs): if 'instance' not in kwargs: kwargs['instance'] = Item() super(ItemForm, self).__init__(*args, **kwargs) self.helper = FormHelper() self.helper.add_input(Submit('submit', 'Submit'))
def test_working(self): p = Project(name='p') p.save() sub = Project(name='subproject', parent=p) sub.save() completed = Item(name='compl', status=Item.COMPLETED, parent=p) completed.save() deleted = Item(name='del', status=Item.DELETED, parent=p) deleted.save() someday = Item(name='sm', status=Item.SOMEDAY, parent=p) someday.save() reference = Item(name='ref', status=Item.REFERENCE, parent=p) reference.save() waiting = Item(name='wait', status=Item.WAITING_FOR, parent=p) waiting.save() reminder = Reminder(name='arem', parent=p) reminder.save() anext = Next(name='next', parent=p) anext.save() self.assertEqual(p.item_set.count(), 8) response = Client().get(reverse('gtdmanager:project_detail', args=(p.id,))) self.assertEqual(response.status_code, 200) self.assertItemsEqual(response.context['subprojects'], (sub,)) self.assertItemsEqual(response.context['nexts'], (anext,)) self.assertItemsEqual(response.context['reminders'], (reminder,)) self.assertItemsEqual(response.context['waiting'], (waiting,)) self.assertItemsEqual(response.context['somedays'], (someday,)) self.assertItemsEqual(response.context['references'], (reference,)) self.assertItemsEqual(response.context['completed'], (completed,)) self.assertItemsEqual(response.context['deleted'], (deleted,))
def prepare_completed_deleted(): item = Item(name='completed', status=Item.COMPLETED) item.save() item2 = Item(name='deleted', status=Item.DELETED) item2.save() return (item, item2)
def test_working(self): p = Project(name='p') p.save() sub = Project(name='subproject', parent=p) sub.save() completed = Item(name='compl', status=Item.COMPLETED, parent=p) completed.save() deleted = Item(name='del', status=Item.DELETED, parent=p) deleted.save() someday = Item(name='sm', status=Item.SOMEDAY, parent=p) someday.save() reference = Item(name='ref', status=Item.REFERENCE, parent=p) reference.save() waiting = Item(name='wait', status=Item.WAITING_FOR, parent=p) waiting.save() reminder = Reminder(name='arem', parent=p) reminder.save() anext = Next(name='next', parent=p) anext.save() self.assertEqual(p.item_set.count(), 8) response = Client().get( reverse('gtdmanager:project_detail', args=(p.id, ))) self.assertEqual(response.status_code, 200) self.assertItemsEqual(response.context['subprojects'], (sub, )) self.assertItemsEqual(response.context['nexts'], (anext, )) self.assertItemsEqual(response.context['reminders'], (reminder, )) self.assertItemsEqual(response.context['waiting'], (waiting, )) self.assertItemsEqual(response.context['somedays'], (someday, )) self.assertItemsEqual(response.context['references'], (reference, )) self.assertItemsEqual(response.context['completed'], (completed, )) self.assertItemsEqual(response.context['deleted'], (deleted, ))
def prepare_completed_deleted(): item = Item(name='completed', status = Item.COMPLETED) item.save() item2 = Item(name='deleted', status = Item.DELETED) item2.save() return (item, item2)