def test_issue_in_state_time(self):
        issue = Issue()
        issue.created = '123'
        issue.id = 'BACKEND-671'
        issue = CycleTimeAwareIssue(issue, TestProvider())
        self.assertEqual(
            issue.time_in_state('Open'),
            millis_to_datetime(1362960471944) - issue.created_time)
        self.assertEqual(
            issue.time_in_state('In Progress'),
            millis_to_datetime(1472861471944) -
            millis_to_datetime(1362960471944))
        self.assertEqual(issue.time_in_state('Complete'),
                         datetime.timedelta(0))
        self.assertEqual(issue.cycle_time, datetime.timedelta(1272, 3800))

        self.assertEqual(issue.first_date_in_state('In Progress'),
                         millis_to_datetime(1362960471944))

        self.assertEqual(issue.cycle_time_start,
                         millis_to_datetime(1362960471944))
        self.assertEqual(issue.cycle_time_end,
                         millis_to_datetime(1472861471944))

        self.assertEqual(
            str(issue),
            '[BACKEND-671], (created): 1970-01-01 01:00:00.123000, '
            '(Open->In Progress): 2013-03-11 01:07:51.944000, '
            '(In Progress->Complete): 2016-09-03 02:11:11.944000, cycle time: 1272 days, 1:03:20'
        )
 def test_resolved_date(self):
     issue = Issue()
     issue.created = '123'
     issue.id = 'BACKEND-671'
     issue = CycleTimeAwareIssue(issue, TestProvider())
     self.assertEqual(issue.resolved_date,
                      millis_to_datetime(1472861471941))
 def te_st_live_get_cycle_time(self):
     yt = Connection('https://tickets.i.gini.net', username, password)
     print 'connected to [%s]' % yt.baseUrl
     issue = Issue()
     issue.id = 'BACKEND-671'
     issue.created = '123'
     issue = CycleTimeAwareIssue(issue, YoutrackProvider(yt))
     self.assertEqual(7, issue.cycle_time.days)
 def test_get_cylce_time_for_issue(self):
     issue = Issue()
     issue.created = '123'
     issue.id = 'BACKEND-671'
     issue = CycleTimeAwareIssue(issue, TestProvider())
     self.assertEqual(
         millis_to_datetime(1472861471944) -
         millis_to_datetime(1362960471944), issue.cycle_time)
     self.assertEqual(datetime.datetime(1970, 1, 1, 1, 0, 0, 123000),
                      issue.created_time)