def test_store_add_cron_called(self): """ Updates cron events for non-deleted policies by calling store.add_cron_events. """ events = [{ 'tenantId': '1234', 'groupId': 'scal44', 'policyId': 'pol4{}'.format(i), 'trigger': 'now', 'cron': '*', 'bucket': 1 } for i in range(10)] deleted_policy_ids = set(['pol41', 'pol45']) new_events = events[:] new_events.pop(1) new_events.pop(4) [event.update({'trigger': 'next'}) for event in new_events] d = add_cron_events(self.mock_store, self.log, events, deleted_policy_ids) self.assertIsNone(self.successResultOf(d), None) self.assertEqual(self.next_cron_occurrence.call_count, 8) self.mock_store.add_cron_events.assert_called_once_with(new_events)
def test_store_add_cron_called(self): """ Updates cron events for non-deleted policies by calling store.add_cron_events. """ events = [ { "tenantId": "1234", "groupId": "scal44", "policyId": "pol4{}".format(i), "trigger": "now", "cron": "*", "bucket": 1, } for i in range(10) ] deleted_policy_ids = set(["pol41", "pol45"]) new_events = events[:] new_events.pop(1) new_events.pop(4) [event.update({"trigger": "next"}) for event in new_events] d = add_cron_events(self.mock_store, self.log, events, deleted_policy_ids) self.assertIsNone(self.successResultOf(d), None) self.assertEqual(self.next_cron_occurrence.call_count, 8) self.mock_store.add_cron_events.assert_called_once_with(new_events)
def test_no_events(self): """ Does nothing on no events """ d = add_cron_events(self.mock_store, self.log, [], set()) self.assertIsNone(d) self.assertFalse(self.log.msg.called) self.assertFalse(self.next_cron_occurrence.called) self.assertFalse(self.mock_store.add_cron_events.called)
def test_no_events(self): """ Does nothing on no events. """ d = add_cron_events(self.mock_store, self.log, [], set()) self.assertIsNone(d) self.assertFalse(self.log.msg.called) self.assertFalse(self.next_cron_occurrence.called) self.assertFalse(self.mock_store.add_cron_events.called)
def test_no_events_to_add(self): """ When all events passed are to be deleted, then does nothing """ events = [{'tenantId': '1234', 'groupId': 'scal44', 'policyId': 'pol4{}'.format(i), 'trigger': 'now', 'cron': '*', 'bucket': 1} for i in range(3)] d = add_cron_events(self.mock_store, self.log, events, set(['pol4{}'.format(i) for i in range(3)])) self.assertIsNone(d) self.assertFalse(self.log.msg.called) self.assertFalse(self.next_cron_occurrence.called) self.assertFalse(self.mock_store.add_cron_events.called)
def test_store_add_cron_called(self): """ Updates cron events for non-deleted policies by calling store.add_cron_events """ events = [{'tenantId': '1234', 'groupId': 'scal44', 'policyId': 'pol4{}'.format(i), 'trigger': 'now', 'cron': '*', 'bucket': 1} for i in range(10)] deleted_policy_ids = set(['pol41', 'pol45']) new_events = events[:] new_events.pop(1) new_events.pop(4) [event.update({'trigger': 'next'}) for event in new_events] d = add_cron_events(self.mock_store, self.log, events, deleted_policy_ids) self.assertIsNone(self.successResultOf(d), None) self.assertEqual(self.next_cron_occurrence.call_count, 8) self.mock_store.add_cron_events.assert_called_once_with(new_events)
def test_no_events_to_add(self): """ When all events passed are to be deleted, then does nothing """ events = [{ 'tenantId': '1234', 'groupId': 'scal44', 'policyId': 'pol4{}'.format(i), 'trigger': 'now', 'cron': '*', 'bucket': 1 } for i in range(3)] d = add_cron_events(self.mock_store, self.log, events, set(['pol4{}'.format(i) for i in range(3)])) self.assertIsNone(d) self.assertFalse(self.log.msg.called) self.assertFalse(self.next_cron_occurrence.called) self.assertFalse(self.mock_store.add_cron_events.called)
def test_no_events_to_add(self): """ When all events passed are to be deleted, then does nothing """ events = [ { "tenantId": "1234", "groupId": "scal44", "policyId": "pol4{}".format(i), "trigger": "now", "cron": "*", "bucket": 1, } for i in range(3) ] d = add_cron_events(self.mock_store, self.log, events, set(["pol4{}".format(i) for i in range(3)])) self.assertIsNone(d) self.assertFalse(self.log.msg.called) self.assertFalse(self.next_cron_occurrence.called) self.assertFalse(self.mock_store.add_cron_events.called)