示例#1
0
 def test_working(self):
     p = Project(name='Proj')
     p.save()
     response = Client().get(reverse('gtdmanager:projects'))
     self.assertEqual(response.status_code, 200)
     self.assertEqual(response.context['btnName'], 'projects')
     self.assertItemsEqual((p, ), response.context['projects'])
示例#2
0
 def _prepare_with_child(self, cls):
     p = Project(name='p')
     p.save()
     i = cls(name='child', parent=p)
     i.save()
     self.assertTrue(p.is_parent_of(i))
     return (p, i)
示例#3
0
 def test_working(self):
     p = Project(name='Proj')
     p.save()
     response = Client().get(reverse('gtdmanager:projects'))
     self.assertEqual(response.status_code, 200)
     self.assertEqual(response.context['btnName'], 'projects')
     self.assertItemsEqual((p,), response.context['projects'])
示例#4
0
 def _prepare_with_child(self, cls):
     p = Project(name='p')
     p.save()
     i = cls(name='child', parent=p)
     i.save()
     self.assertTrue(p.is_parent_of(i))
     return (p, i)
示例#5
0
 def test_parenting_self_form_validation(self):
     p = Project(name='parent')
     p.save()
     postdata = {'name': 'test', 'parent': '27', 'description': ''}
     form = ProjectForm(postdata, instance=p)
     # foreign key is not updated, so form.instance.parent is still None,
     # we make check in ProjectForm
     self.assertFalse(form.is_valid())
示例#6
0
 def test_edit(self):
     p = Project(name='p')
     p.save()
     response = Client().get(reverse('gtdmanager:project_edit', args=(1, )))
     self.assertEqual(response.status_code, 200)
     self.assertIn('form', response.context)
     self.assertEqual(response.context['title'], 'Edit project')
     self.assertEqual(response.context['edit'], True)
示例#7
0
 def test_parenting_self_form_validation(self):
     p = Project(name='parent')
     p.save()
     postdata = {'name': 'test', 'parent': '27', 'description': ''}
     form = ProjectForm(postdata, instance=p)
     # foreign key is not updated, so form.instance.parent is still None,
     # we make check in ProjectForm
     self.assertFalse(form.is_valid())
示例#8
0
 def test_edit(self):
     p = Project(name='p')
     p.save()
     response = Client().get(reverse('gtdmanager:project_edit', args=(1,)))
     self.assertEqual(response.status_code, 200)
     self.assertIn('form', response.context)
     self.assertEqual(response.context['title'], 'Edit project')
     self.assertEqual(response.context['edit'], True)
示例#9
0
    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, ))
示例#10
0
 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())
示例#11
0
 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())
示例#12
0
 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,))
示例#13
0
 def test_convert_nonitem(self):
     item = Project('proj')
     with self.assertRaises(RuntimeError):
         Item.objects.convertTo(Next, item)
示例#14
0
 def test_is_parent_none(self):
     p = Project(name='parent1')
     self.assertFalse(p.is_parent_of(None))
示例#15
0
 def test_is_parent_none(self):
     p = Project(name='parent1')
     self.assertFalse(p.is_parent_of(None))