示例#1
0
 def test_assignedWorker(self):
     taskUnit = TaskUnit(createdAt=self.createdAt,
                         deadline=self.deadline,
                         profit=self.profit,
                         processing=self.processing,
                         taskID=self.taskID)
     worker = Worker(workerID="W1",
                     begin=tHour(0, 00),
                     end=tHour(23, 59),
                     multitask=2)
     taskUnit.assignWorker(worker)
     self.assertEqual(taskUnit.assignedWorker, worker)
示例#2
0
 def test_asDict(self):
     taskUnit = TaskUnit(createdAt=self.createdAt,
                         deadline=self.deadline,
                         profit=self.profit,
                         processing=self.processing,
                         taskID=self.taskID)
     taskUnit.assignWorker(self.worker)
     # Calculate the correct ISO for task.
     deadline = timeutil.addSeconds(self.createdAt, self.deadline)
     expectedReleaseISO = release.releaseAt(deadline,
                                            self.processing).isoformat()
     expectedDeadlineISO = timeutil.addSeconds(self.createdAt,
                                               self.deadline).isoformat()
     expectedCreatedAtISO = self.createdAt.isoformat()
     expectedResult = {
         "id": self.taskID,
         "releaseISO": expectedReleaseISO,
         "deadlineISO": expectedDeadlineISO,
         "createdAtISO": expectedCreatedAtISO,
         "profit": self.profit,
         "processing": self.processing,
         "assignedWorkerID": self.worker.workerID
     }
     self.assertEqual(taskUnit.asDict(), expectedResult)