def test_no_approvals(self, mock_is_wip, mock_psa, mock_days):
     mock_is_wip.return_value = False
     mock_psa.return_value = False
     auto_abandon.process_changes([FAKE_CHANGE])
     self.assertTrue(mock_is_wip.called)
     self.assertTrue(mock_psa.called)
     self.assertFalse(mock_days.called)
Ejemplo n.º 2
0
 def test_no_approvals(self, mock_is_wip, mock_psa, mock_days):
     mock_is_wip.return_value = False
     mock_psa.return_value = False
     auto_abandon.process_changes([FAKE_CHANGE])
     self.assertTrue(mock_is_wip.called)
     self.assertTrue(mock_psa.called)
     self.assertFalse(mock_days.called)
 def test_approved(self, mock_is_wip, mock_psa):
     change = copy.deepcopy(FAKE_CHANGE)
     change['patchSets'] = [mock.MagicMock()]
     mock_is_wip.return_value = False
     mock_psa.return_value = True
     auto_abandon.process_changes([change])
     self.assertTrue(mock_is_wip.called)
     self.assertTrue(mock_psa.called)
     self.assertFalse(change['patchSets'][0].get.called)
Ejemplo n.º 4
0
 def test_approved(self, mock_is_wip, mock_psa):
     change = copy.deepcopy(FAKE_CHANGE)
     change['patchSets'] = [mock.MagicMock()]
     mock_is_wip.return_value = False
     mock_psa.return_value = True
     auto_abandon.process_changes([change])
     self.assertTrue(mock_is_wip.called)
     self.assertTrue(mock_psa.called)
     self.assertFalse(change['patchSets'][0].get.called)
    def _test_multiple_patch_sets(self, mock_timegm, mock_abandon, good, bad,
                                  should_abandon):
        # 33 instead of 32 because the bad patch set happens after BASE_TS,
        # and due to rounding it ends up looking one full day newer.
        mock_timegm.return_value = BASE_TS + ONE_DAY * 33
        good_patchset = {'approvals': [], 'number': good}
        good_patchset['lastUpdated'] = BASE_TS + 50 * (int(good) - 1)
        fake_pos = copy.deepcopy(FAKE_PLUS_ONE)
        fake_pos['grantedOn'] = good_patchset['lastUpdated']
        good_patchset['approvals'] = [fake_pos]

        bad_patchset = {'approvals': [], 'number': bad}
        bad_patchset['lastUpdated'] = BASE_TS + 50 * (int(bad) - 1)
        fake_neg = copy.deepcopy(FAKE_MINUS_ONE)
        fake_neg['grantedOn'] = bad_patchset['lastUpdated']
        bad_patchset['approvals'] = [fake_neg]

        patchsets = [bad_patchset, good_patchset]
        change = copy.deepcopy(FAKE_CHANGE)
        change['patchSets'] = patchsets
        auto_abandon.process_changes([change])
        self.assertEqual(should_abandon, mock_abandon.called)
Ejemplo n.º 6
0
    def _test_multiple_patch_sets(self, mock_timegm, mock_abandon, good, bad,
                                  should_abandon):
        # 33 instead of 32 because the bad patch set happens after BASE_TS,
        # and due to rounding it ends up looking one full day newer.
        mock_timegm.return_value = BASE_TS + ONE_DAY * 33
        good_patchset = {'approvals': [], 'number': good}
        good_patchset['lastUpdated'] = BASE_TS + 50 * (int(good) - 1)
        fake_pos = copy.deepcopy(FAKE_PLUS_ONE)
        fake_pos['grantedOn'] = good_patchset['lastUpdated']
        good_patchset['approvals'] = [fake_pos]

        bad_patchset = {'approvals': [], 'number': bad}
        bad_patchset['lastUpdated'] = BASE_TS + 50 * (int(bad) - 1)
        fake_neg = copy.deepcopy(FAKE_MINUS_ONE)
        fake_neg['grantedOn'] = bad_patchset['lastUpdated']
        bad_patchset['approvals'] = [fake_neg]

        patchsets = [bad_patchset, good_patchset]
        change = copy.deepcopy(FAKE_CHANGE)
        change['patchSets'] = patchsets
        auto_abandon.process_changes([change])
        self.assertEqual(should_abandon, mock_abandon.called)
 def test_ignore_restored(self, mock_days):
     change = copy.deepcopy(FAKE_CHANGE)
     change['lastUpdated'] = BASE_TS + 100
     change['patchSets'][0]['approvals'] = [FAKE_MINUS_ONE]
     auto_abandon.process_changes([change])
     self.assertFalse(mock_days.called)
 def test_not_abandon_less_than_expiration(self, mock_days, mock_abandon):
     change = copy.deepcopy(FAKE_CHANGE)
     change['patchSets'][0]['approvals'] = [FAKE_MINUS_ONE]
     mock_days.return_value = auto_abandon.ABANDON_DAYS
     auto_abandon.process_changes([change])
     self.assertFalse(mock_abandon.called)
 def test_abandon_after_expiration(self, mock_days, mock_abandon):
     change = copy.deepcopy(FAKE_CHANGE)
     change['patchSets'][0]['approvals'] = [FAKE_MINUS_ONE]
     mock_days.return_value = auto_abandon.ABANDON_DAYS + 1
     auto_abandon.process_changes([change])
     mock_abandon.assert_called_once_with('fake-id')
 def test_wip(self, mock_is_wip, mock_psa):
     mock_is_wip.return_value = True
     auto_abandon.process_changes([FAKE_CHANGE])
     # We should have bailed after the WIP check
     self.assertTrue(mock_is_wip.called)
     self.assertFalse(mock_psa.called)
Ejemplo n.º 11
0
 def test_ignore_restored(self, mock_days):
     change = copy.deepcopy(FAKE_CHANGE)
     change['lastUpdated'] = BASE_TS + 100
     change['patchSets'][0]['approvals'] = [FAKE_MINUS_ONE]
     auto_abandon.process_changes([change])
     self.assertFalse(mock_days.called)
Ejemplo n.º 12
0
 def test_not_abandon_less_than_expiration(self, mock_days, mock_abandon):
     change = copy.deepcopy(FAKE_CHANGE)
     change['patchSets'][0]['approvals'] = [FAKE_MINUS_ONE]
     mock_days.return_value = auto_abandon.ABANDON_DAYS
     auto_abandon.process_changes([change])
     self.assertFalse(mock_abandon.called)
Ejemplo n.º 13
0
 def test_abandon_after_expiration(self, mock_days, mock_abandon):
     change = copy.deepcopy(FAKE_CHANGE)
     change['patchSets'][0]['approvals'] = [FAKE_MINUS_ONE]
     mock_days.return_value = auto_abandon.ABANDON_DAYS + 1
     auto_abandon.process_changes([change])
     mock_abandon.assert_called_once_with('fake-id')
Ejemplo n.º 14
0
 def test_wip(self, mock_is_wip, mock_psa):
     mock_is_wip.return_value = True
     auto_abandon.process_changes([FAKE_CHANGE])
     # We should have bailed after the WIP check
     self.assertTrue(mock_is_wip.called)
     self.assertFalse(mock_psa.called)