Beispiel #1
0
    def setUp(self):
        self.storage = TestTaskStorage([])
        self.controller = TaskController(self.storage)
        self.author = User('tester', 0)
        self.responsible = User('resp', 1)
        self.queue = Queue('test', '-1', self.author)
        self.author.queues.append(self.queue)
        self.test_task = Task('My task',
                              key='12345',
                              responsible=[self.responsible.nick],
                              author=self.author.nick,
                              queue=self.queue.key)

        self.parent_task = Task('Parent',
                                key='p1',
                                author=self.author.nick,
                                queue=self.queue.key)

        self.controller_task = Task('controller',
                                    key='c1',
                                    author=self.author.nick,
                                    queue=self.queue.key)

        self.storage.tasks.append(self.controller_task)
        self.storage.tasks.append(self.test_task)
        self.storage.tasks.append(self.parent_task)
Beispiel #2
0
 def test_move_in_failed(self):
     queue = self.controller.add_queue(name='Test queue',
                                       key='100',
                                       owner=self.owner)
     task = Task('test task', key='54354', queue=queue)
     self.controller.link_queue_with_task(queue, task)
     task.status = 'failed'
     self.controller.move_in_failed(queue, task)
     self.assertIn(task.key, queue.failed_tasks)
Beispiel #3
0
 def test_move_in_opened(self):
     queue = self.controller.add_queue(name='Test queue',
                                       key='100',
                                       owner=self.owner)
     task = Task('test task', key='54354', queue=queue)
     task.status = 'solved'
     queue.solved_tasks.append(task.key)
     self.controller.move_in_opened(queue, task)
     self.assertIn(task.key, queue.opened_tasks)
Beispiel #4
0
 def test_unlink_responsible_with_task(self):
     owner = self.controller.add_user(nick='owner', uid=0)
     responsible = self.controller.add_user(nick='responsible', uid=1)
     task = Task(name='Test task', key='3453', author=owner.nick)
     self.controller.link_responsible_with_task(responsible, task)
     self.controller.unlink_responsible_and_task(responsible, task)
     self.assertListEqual(responsible.tasks_responsible, [])
Beispiel #5
0
 def test_link_queue_with_task(self):
     queue = self.controller.add_queue(name='Test queue',
                                       key='100',
                                       owner=self.owner)
     task = Task('test task', key='54354', queue=queue)
     self.controller.link_queue_with_task(queue, task)
     self.assertIn(task.key, queue.opened_tasks)
Beispiel #6
0
 def test_rec_delete_queue_with_tasks(self):
     queue = self.controller.add_queue(name='Test queue',
                                       key='100',
                                       owner=self.owner)
     task = Task('test task', key='54354', queue=queue)
     self.controller.link_queue_with_task(queue, task)
     self.controller.remove_queue('100', True, self.owner)
     self.assertNotIn(queue, self.storage.queues)
Beispiel #7
0
 def test_try_to_unrec_delete_queue_with_tasks(self):
     queue = self.controller.add_queue(name='Test queue',
                                       key='100',
                                       owner=self.owner)
     task = Task('test task', key='54354', queue=queue)
     self.controller.link_queue_with_task(queue, task)
     with self.assertRaises(DeletingQueueError):
         self.controller.remove_queue('100', False, self.owner)
Beispiel #8
0
    def test_remove_task(self):
        self.task_for_remove = Task('reM_TASK',
                                    key='3456',
                                    author=self.author.nick,
                                    queue=self.queue.key)
        self.storage.tasks.append(self.task_for_remove)

        self.controller.remove_task(self.task_for_remove, self.author, True)
        self.assertNotIn(self.task_for_remove, self.storage.tasks)
Beispiel #9
0
    def test_edit_task(self):
        actual = self.controller.edit_task(task=self.test_task,
                                           name='Edited task',
                                           task_queue=self.queue,
                                           editor=self.author)

        expected = Task(name='Edited task',
                        key='12345',
                        author='tester',
                        queue='-1',
                        responsible=['resp'])
        self.assertEqual(actual.__dict__, expected.__dict__)
Beispiel #10
0
 def make_plan_task(plan):
     """
     This method using for creating task from plan attributes
     :param plan: plan which create task
     :return: task which create by plan
     """
     start = Time.get_date_string(Time.NOW)
     deadline = Time.get_date_string(Time.NOW + Time.Interval[plan.period])
     return Task(key=plan.key,
                 name=plan.name,
                 reminder=plan.reminder,
                 author=plan.author,
                 start=start,
                 deadline=deadline,
                 creating_time=start)
Beispiel #11
0
 def test_make_plan_task(self):
     plan = self.controller.create_plan(key='1',
                                        author=self.author,
                                        name='plan for create task',
                                        period='daily',
                                        activation_time='01.09.2018.9:00')
     Time.NOW = dt(2018, 9, 1, 9, 0)
     actual = self.controller.make_plan_task(plan)
     expected = Task(key='1',
                     name='plan for create task',
                     reminder=None,
                     author='tester',
                     start='01.09.2018.09:00',
                     deadline='02.09.2018.09:00',
                     creating_time='01.09.2018.09:00')
     print(actual.__dict__)
     print(expected.__dict__)
     self.assertEqual(actual.__dict__, expected.__dict__)
Beispiel #12
0
    def test_planned_tasks(self):
        self.controller.create_plan(key='1',
                                    author=self.author,
                                    name='test plan',
                                    period='monthly',
                                    activation_time='20.09.2018.9:00')

        Time.NOW = dt(2018, 9, 20, 9, 0)
        planned_tasks = self.controller.update_all_plans()

        expected_task = Task(key='1',
                             name='test plan',
                             reminder=None,
                             author='tester',
                             start='20.09.2018.09:00',
                             deadline='20.10.2018.09:00',
                             creating_time='20.09.2018.09:00')
        print(expected_task.__dict__)
        print(planned_tasks[0].__dict__)
        self.assertDictEqual(expected_task.__dict__, planned_tasks[0].__dict__)
Beispiel #13
0
 def test_unlink_author_with_task(self):
     owner = self.controller.add_user(nick='owner', uid=0)
     task = Task(name='Test task', key='3453', author=owner.nick)
     self.controller.link_author_with_task(owner, task)
     self.controller.unlink_author_and_task(owner, task)
     self.assertListEqual(owner.tasks_author, [])