Пример #1
0
    def testCycleStartsWithExitingAState(self):
        """In some workflows, the cycle we are intertested in can start with a transition into a number of states
            so we measure from the exit of the previous state rather than the arrival at a specific state."""

        history = pd.Series([CREATED_STATE,
                             'queued',
                             START_STATE,
                             START_STATE,
                             START_STATE,
                             START_STATE,
                             START_STATE,
                             START_STATE,
                             START_STATE,
                             START_STATE,
                             START_STATE,
                             START_STATE,
                             END_STATE],
                            index=pd.to_datetime(['2012-01-01',
                                                  '2012-01-02',
                                                  '2012-01-03',
                                                  '2012-01-04',
                                                  '2012-01-05',
                                                  '2012-01-06',
                                                  '2012-01-07',
                                                  '2012-01-08',
                                                  '2012-01-09',
                                                  '2012-01-10',
                                                  '2012-01-11',
                                                  '2012-01-12',
                                                  '2012-01-13']))

        self.assertEquals(cycle_time(history,
                                     after_state='queued'), 11)
Пример #2
0
    def testGetCycleTime(self):

        history = pd.Series([CREATED_STATE,
                             CREATED_STATE,
                             START_STATE,
                             'pending',
                             'pending',
                             'pending',
                             'Customer Approval',
                             'Customer Approval',
                             'pending',
                             'pending',
                             'Customer Approval',
                             'Customer Approval',
                             'Customer Approval',
                             'Customer Approval',
                             END_STATE],
                            index=pd.to_datetime(['2012-01-01',
                                                  '2012-01-02',
                                                  '2012-01-03',
                                                  '2012-01-04',
                                                  '2012-01-05',
                                                  '2012-01-06',
                                                  '2012-01-07',
                                                  '2012-01-08',
                                                  '2012-01-09',
                                                  '2012-01-10',
                                                  '2012-01-11',
                                                  '2012-01-12',
                                                  '2012-01-13',
                                                  '2012-01-14',
                                                  '2012-01-15']))

        self.assertEquals(cycle_time(history), 13)
Пример #3
0
    def testCycleEndsWithExitingAState(self):
        """In some workflows, the cycle we are interested in can end with a transition to more than one state so
           we measure to the exit from the last state rather than the arrival at the end state."""

        history = pd.Series([CREATED_STATE,
                             START_STATE,
                             START_STATE,
                             START_STATE,
                             START_STATE,
                             START_STATE,
                             START_STATE,
                             START_STATE,
                             START_STATE,
                             START_STATE,
                             START_STATE,
                             'pending'],
                            index=pd.to_datetime(['2012-01-01',
                                                  '2012-01-02',
                                                  '2012-01-03',
                                                  '2012-01-04',
                                                  '2012-01-05',
                                                  '2012-01-06',
                                                  '2012-01-07',
                                                  '2012-01-08',
                                                  '2012-01-09',
                                                  '2012-01-10',
                                                  '2012-01-11',
                                                  '2012-01-12']))

        self.assertEquals(cycle_time(history, exit_state=START_STATE), 10)
Пример #4
0
    def testGetCycleTimeIncRepopenedToClosed(self):

        history = pd.Series(
            [START_STATE, END_STATE, REOPENED_STATE, END_STATE],
            index=pd.to_datetime(
                ['2012-01-01', '2012-01-02', '2012-01-03', '2012-01-04']))

        self.assertEquals(cycle_time(history), 4)
Пример #5
0
    def testGetCycleTimeIsStillOpen(self):

        history = pd.Series([START_STATE,
                             'pending'],
                            index=pd.to_datetime(['2012-01-01',
                                                  '2012-01-02']))

        self.assertEquals(cycle_time(history), None)
Пример #6
0
    def testGetCycleTimeWithDropOuts(self):

        history = pd.Series([START_STATE, 'pending', START_STATE, END_STATE],
                            index=pd.to_datetime([
                                '2012-01-01', '2012-01-02', '2012-01-03',
                                '2012-01-04'
                            ]))

        self.assertEquals(cycle_time(history), 4)
Пример #7
0
    def testCycleStartsWithOpen(self):
        """We need to be able to deal with workflows where there is no queue before work actually starts"""

        history = pd.Series(
            ['Open', 'Awaiting Review', 'Reviewing', END_STATE],
            index=pd.to_datetime(
                ['2012-01-01', '2012-01-02', '2012-01-03', '2012-01-04']))

        self.assertEquals(
            cycle_time(history, start_state='Open', end_state='Reviewing'), 3)
Пример #8
0
    def testGetCycleTimeWithDropOuts(self):

        history = pd.Series([START_STATE,
                             'pending',
                             START_STATE,
                             END_STATE],
                            index=pd.to_datetime(['2012-01-01',
                                                  '2012-01-02',
                                                  '2012-01-03',
                                                  '2012-01-04']))

        self.assertEquals(cycle_time(history), 4)
Пример #9
0
    def testGetCycleTimeIncRepopenedToClosed(self):

        history = pd.Series([START_STATE,
                             END_STATE,
                             REOPENED_STATE,
                             END_STATE],
                            index=pd.to_datetime(['2012-01-01',
                                                  '2012-01-02',
                                                  '2012-01-03',
                                                  '2012-01-04']))

        self.assertEquals(cycle_time(history), 4)
Пример #10
0
    def testCycleStartsWithOpen(self):
        """We need to be able to deal with workflows where there is no queue before work actually starts"""

        history = pd.Series(['Open',
                             'Awaiting Review',
                             'Reviewing',
                             END_STATE],
                            index=pd.to_datetime(['2012-01-01',
                                                  '2012-01-02',
                                                  '2012-01-03',
                                                  '2012-01-04']))

        self.assertEquals(cycle_time(history,
                                     start_state='Open',
                                     end_state='Reviewing'), 3)
Пример #11
0
    def testCycleEndsWithExitingAState(self):
        """In some workflows, the cycle we are interested in can end with a transition to more than one state so
           we measure to the exit from the last state rather than the arrival at the end state."""

        history = pd.Series([
            CREATED_STATE, START_STATE, START_STATE, START_STATE, START_STATE,
            START_STATE, START_STATE, START_STATE, START_STATE, START_STATE,
            START_STATE, 'pending'
        ],
                            index=pd.to_datetime([
                                '2012-01-01', '2012-01-02', '2012-01-03',
                                '2012-01-04', '2012-01-05', '2012-01-06',
                                '2012-01-07', '2012-01-08', '2012-01-09',
                                '2012-01-10', '2012-01-11', '2012-01-12'
                            ]))

        self.assertEquals(cycle_time(history, exit_state=START_STATE), 10)
Пример #12
0
    def testGetCycleTime(self):

        history = pd.Series([
            CREATED_STATE, CREATED_STATE, START_STATE, 'pending', 'pending',
            'pending', 'Customer Approval', 'Customer Approval', 'pending',
            'pending', 'Customer Approval', 'Customer Approval',
            'Customer Approval', 'Customer Approval', END_STATE
        ],
                            index=pd.to_datetime([
                                '2012-01-01', '2012-01-02', '2012-01-03',
                                '2012-01-04', '2012-01-05', '2012-01-06',
                                '2012-01-07', '2012-01-08', '2012-01-09',
                                '2012-01-10', '2012-01-11', '2012-01-12',
                                '2012-01-13', '2012-01-14', '2012-01-15'
                            ]))

        self.assertEquals(cycle_time(history), 13)
Пример #13
0
    def testCycleStartsWithExitingAState(self):
        """In some workflows, the cycle we are intertested in can start with a transition into a number of states
            so we measure from the exit of the previous state rather than the arrival at a specific state."""

        history = pd.Series([
            CREATED_STATE, 'queued', START_STATE, START_STATE, START_STATE,
            START_STATE, START_STATE, START_STATE, START_STATE, START_STATE,
            START_STATE, START_STATE, END_STATE
        ],
                            index=pd.to_datetime([
                                '2012-01-01', '2012-01-02', '2012-01-03',
                                '2012-01-04', '2012-01-05', '2012-01-06',
                                '2012-01-07', '2012-01-08', '2012-01-09',
                                '2012-01-10', '2012-01-11', '2012-01-12',
                                '2012-01-13'
                            ]))

        self.assertEquals(cycle_time(history, after_state='queued'), 11)
Пример #14
0
    def testGetCycleTimeForIncludedStates(self):
        """
        For cases where cycle starts by exiting one or more states and
        ends by entering one or more states we measure the cycle by recording
        number of days in the states we are interested in.
        """

        history = pd.Series([
            CREATED_STATE, 'queued', 'one', 'two', 'two', 'three', 'three',
            'three', END_STATE, 'two', 'four', 'five', END_STATE
        ],
                            index=pd.to_datetime([
                                '2012-01-01', '2012-01-02', '2012-01-03',
                                '2012-01-04', '2012-01-05', '2012-01-06',
                                '2012-01-07', '2012-01-08', '2012-01-09',
                                '2012-01-10', '2012-01-11', '2012-01-12',
                                '2012-01-13'
                            ]))

        self.assertEquals(
            cycle_time(history, include_states=['one', 'two', 'three']), 7)
Пример #15
0
    def testGetCycleTimeForExcludedStates(self):
        """
        Like included states above but expressed as the inverse - i.e. the states
        we are not interested in.
        """

        history = pd.Series([CREATED_STATE,
                             'queued',
                             'one',
                             'two',
                             'two',
                             'three',
                             'three',
                             'three',
                             END_STATE,
                             'two',
                             'four',
                             'five',
                             END_STATE],
                            index=pd.to_datetime(['2012-01-01',
                                                  '2012-01-02',
                                                  '2012-01-03',
                                                  '2012-01-04',
                                                  '2012-01-05',
                                                  '2012-01-06',
                                                  '2012-01-07',
                                                  '2012-01-08',
                                                  '2012-01-09',
                                                  '2012-01-10',
                                                  '2012-01-11',
                                                  '2012-01-12',
                                                  '2012-01-13']))

        self.assertEquals(cycle_time(history,
                                     exclude_states=[CREATED_STATE,
                                                     'queued',
                                                     'four',
                                                     'five',
                                                     END_STATE]), 7)
Пример #16
0
    def testGetCycleTimeForExcludedStates(self):
        """
        Like included states above but expressed as the inverse - i.e. the states
        we are not interested in.
        """

        history = pd.Series([
            CREATED_STATE, 'queued', 'one', 'two', 'two', 'three', 'three',
            'three', END_STATE, 'two', 'four', 'five', END_STATE
        ],
                            index=pd.to_datetime([
                                '2012-01-01', '2012-01-02', '2012-01-03',
                                '2012-01-04', '2012-01-05', '2012-01-06',
                                '2012-01-07', '2012-01-08', '2012-01-09',
                                '2012-01-10', '2012-01-11', '2012-01-12',
                                '2012-01-13'
                            ]))

        self.assertEquals(
            cycle_time(history,
                       exclude_states=[
                           CREATED_STATE, 'queued', 'four', 'five', END_STATE
                       ]), 7)
Пример #17
0
    def testGetCycleTimeForIncludedStates(self):
        """
        For cases where cycle starts by exiting one or more states and
        ends by entering one or more states we measure the cycle by recording
        number of days in the states we are interested in.
        """

        history = pd.Series([CREATED_STATE,
                             'queued',
                             'one',
                             'two',
                             'two',
                             'three',
                             'three',
                             'three',
                             END_STATE,
                             'two',
                             'four',
                             'five',
                             END_STATE],
                            index=pd.to_datetime(['2012-01-01',
                                                  '2012-01-02',
                                                  '2012-01-03',
                                                  '2012-01-04',
                                                  '2012-01-05',
                                                  '2012-01-06',
                                                  '2012-01-07',
                                                  '2012-01-08',
                                                  '2012-01-09',
                                                  '2012-01-10',
                                                  '2012-01-11',
                                                  '2012-01-12',
                                                  '2012-01-13']))

        self.assertEquals(cycle_time(history,
                                     include_states=['one', 'two', 'three']), 7)
Пример #18
0
    def testGetCycleTimeIsStillOpen(self):

        history = pd.Series([START_STATE, 'pending'],
                            index=pd.to_datetime(['2012-01-01', '2012-01-02']))

        self.assertEquals(cycle_time(history), None)